@loaders.gl/schema 3.1.3 → 4.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/dist/bundle.js +2 -2
  2. package/dist/bundle.js.map +1 -0
  3. package/dist/category/common.d.ts +1 -2
  4. package/dist/category/common.d.ts.map +1 -1
  5. package/dist/category/common.js +2 -10
  6. package/dist/{es5/category → category}/common.js.map +0 -0
  7. package/dist/category/gis.js +2 -2
  8. package/dist/{es5/category → category}/gis.js.map +0 -0
  9. package/dist/category/image/image.d.ts +18 -0
  10. package/dist/category/image/image.d.ts.map +1 -0
  11. package/dist/category/image/image.js +2 -0
  12. package/dist/{esm/category/gis.js.map → category/image/image.js.map} +1 -1
  13. package/dist/category/mesh/convert-mesh.js +31 -37
  14. package/dist/category/mesh/convert-mesh.js.map +1 -0
  15. package/dist/category/mesh/deduce-mesh-schema.js +37 -57
  16. package/dist/category/mesh/deduce-mesh-schema.js.map +1 -0
  17. package/dist/category/mesh/mesh-to-arrow-table.d.ts +10 -0
  18. package/dist/category/mesh/mesh-to-arrow-table.d.ts.map +1 -1
  19. package/dist/category/mesh/mesh-to-arrow-table.js +15 -28
  20. package/dist/category/mesh/mesh-to-arrow-table.js.map +1 -0
  21. package/dist/category/mesh/mesh-types.js +2 -2
  22. package/dist/{es5/category → category}/mesh/mesh-types.js.map +0 -0
  23. package/dist/category/mesh/mesh-utils.js +35 -48
  24. package/dist/category/mesh/mesh-utils.js.map +1 -0
  25. package/dist/category/table/deduce-table-schema.js +39 -94
  26. package/dist/category/table/deduce-table-schema.js.map +1 -0
  27. package/dist/category/table/table-types.d.ts +1 -3
  28. package/dist/category/table/table-types.d.ts.map +1 -1
  29. package/dist/category/table/table-types.js +2 -2
  30. package/dist/{es5/category → category}/table/table-types.js.map +0 -0
  31. package/dist/category/texture/texture.d.ts +18 -0
  32. package/dist/category/texture/texture.d.ts.map +1 -0
  33. package/dist/category/texture/texture.js +2 -0
  34. package/dist/{esm/category/common.js.map → category/texture/texture.js.map} +1 -1
  35. package/dist/dist.min.js +15078 -208
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +13 -75
  39. package/dist/index.js.map +1 -0
  40. package/dist/lib/arrow/arrow-like-type-utils.js +31 -26
  41. package/dist/lib/arrow/arrow-like-type-utils.js.map +1 -0
  42. package/dist/lib/arrow/arrow-type-utils.d.ts +5 -0
  43. package/dist/lib/arrow/arrow-type-utils.d.ts.map +1 -1
  44. package/dist/lib/arrow/arrow-type-utils.js +20 -28
  45. package/dist/lib/arrow/arrow-type-utils.js.map +1 -0
  46. package/dist/lib/arrow/get-type-info.js +19 -23
  47. package/dist/lib/arrow/get-type-info.js.map +1 -0
  48. package/dist/lib/batches/base-table-batch-aggregator.js +68 -52
  49. package/dist/lib/batches/base-table-batch-aggregator.js.map +1 -0
  50. package/dist/lib/batches/columnar-table-batch-aggregator.js +92 -82
  51. package/dist/lib/batches/columnar-table-batch-aggregator.js.map +1 -0
  52. package/dist/lib/batches/row-table-batch-aggregator.js +88 -72
  53. package/dist/lib/batches/row-table-batch-aggregator.js.map +1 -0
  54. package/dist/lib/batches/table-batch-aggregator.js +2 -2
  55. package/dist/{es5/lib → lib}/batches/table-batch-aggregator.js.map +0 -0
  56. package/dist/lib/batches/table-batch-builder.js +166 -137
  57. package/dist/lib/batches/table-batch-builder.js.map +1 -0
  58. package/dist/lib/schema/impl/enum.js +48 -96
  59. package/dist/lib/schema/impl/enum.js.map +1 -0
  60. package/dist/lib/schema/impl/field.js +34 -31
  61. package/dist/lib/schema/impl/field.js.map +1 -0
  62. package/dist/lib/schema/impl/schema.js +81 -72
  63. package/dist/lib/schema/impl/schema.js.map +1 -0
  64. package/dist/lib/schema/impl/type.js +490 -454
  65. package/dist/lib/schema/impl/type.js.map +1 -0
  66. package/dist/lib/schema/schema.js +5 -90
  67. package/dist/lib/schema/schema.js.map +1 -0
  68. package/dist/lib/schema-utils/deduce-column-type.js +20 -89
  69. package/dist/lib/schema-utils/deduce-column-type.js.map +1 -0
  70. package/dist/lib/utils/assert.js +5 -11
  71. package/dist/lib/utils/assert.js.map +1 -0
  72. package/dist/lib/utils/async-queue.js +109 -82
  73. package/dist/lib/utils/async-queue.js.map +1 -0
  74. package/dist/lib/utils/row-utils.js +33 -31
  75. package/dist/lib/utils/row-utils.js.map +1 -0
  76. package/dist/types.js +2 -2
  77. package/dist/{es5/types.js.map → types.js.map} +0 -0
  78. package/package.json +6 -5
  79. package/src/category/common.ts +1 -2
  80. package/src/category/image/image.ts +19 -0
  81. package/src/category/mesh/convert-mesh.ts +6 -6
  82. package/src/category/mesh/mesh-to-arrow-table.ts +2 -4
  83. package/src/category/table/table-types.ts +1 -4
  84. package/src/category/texture/texture.ts +28 -0
  85. package/src/index.ts +6 -1
  86. package/src/lib/arrow/arrow-type-utils.ts +0 -2
  87. package/dist/es5/bundle.js +0 -7
  88. package/dist/es5/bundle.js.map +0 -1
  89. package/dist/es5/category/common.js +0 -2
  90. package/dist/es5/category/gis.js +0 -2
  91. package/dist/es5/category/mesh/convert-mesh.js +0 -43
  92. package/dist/es5/category/mesh/convert-mesh.js.map +0 -1
  93. package/dist/es5/category/mesh/deduce-mesh-schema.js +0 -54
  94. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +0 -1
  95. package/dist/es5/category/mesh/mesh-to-arrow-table.js +0 -2
  96. package/dist/es5/category/mesh/mesh-to-arrow-table.js.map +0 -1
  97. package/dist/es5/category/mesh/mesh-types.js +0 -2
  98. package/dist/es5/category/mesh/mesh-utils.js +0 -47
  99. package/dist/es5/category/mesh/mesh-utils.js.map +0 -1
  100. package/dist/es5/category/table/deduce-table-schema.js +0 -58
  101. package/dist/es5/category/table/deduce-table-schema.js.map +0 -1
  102. package/dist/es5/category/table/table-types.js +0 -2
  103. package/dist/es5/index.js +0 -344
  104. package/dist/es5/index.js.map +0 -1
  105. package/dist/es5/lib/arrow/arrow-like-type-utils.js +0 -40
  106. package/dist/es5/lib/arrow/arrow-like-type-utils.js.map +0 -1
  107. package/dist/es5/lib/arrow/arrow-type-utils.js +0 -2
  108. package/dist/es5/lib/arrow/arrow-type-utils.js.map +0 -1
  109. package/dist/es5/lib/arrow/get-type-info.js +0 -33
  110. package/dist/es5/lib/arrow/get-type-info.js.map +0 -1
  111. package/dist/es5/lib/batches/base-table-batch-aggregator.js +0 -92
  112. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +0 -1
  113. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +0 -128
  114. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
  115. package/dist/es5/lib/batches/row-table-batch-aggregator.js +0 -113
  116. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +0 -1
  117. package/dist/es5/lib/batches/table-batch-aggregator.js +0 -2
  118. package/dist/es5/lib/batches/table-batch-builder.js +0 -207
  119. package/dist/es5/lib/batches/table-batch-builder.js.map +0 -1
  120. package/dist/es5/lib/schema/impl/enum.js +0 -56
  121. package/dist/es5/lib/schema/impl/enum.js.map +0 -1
  122. package/dist/es5/lib/schema/impl/field.js +0 -56
  123. package/dist/es5/lib/schema/impl/field.js.map +0 -1
  124. package/dist/es5/lib/schema/impl/schema.js +0 -168
  125. package/dist/es5/lib/schema/impl/schema.js.map +0 -1
  126. package/dist/es5/lib/schema/impl/type.js +0 -927
  127. package/dist/es5/lib/schema/impl/type.js.map +0 -1
  128. package/dist/es5/lib/schema/schema.js +0 -236
  129. package/dist/es5/lib/schema/schema.js.map +0 -1
  130. package/dist/es5/lib/schema-utils/deduce-column-type.js +0 -32
  131. package/dist/es5/lib/schema-utils/deduce-column-type.js.map +0 -1
  132. package/dist/es5/lib/utils/assert.js +0 -13
  133. package/dist/es5/lib/utils/assert.js.map +0 -1
  134. package/dist/es5/lib/utils/async-queue.js +0 -213
  135. package/dist/es5/lib/utils/async-queue.js.map +0 -1
  136. package/dist/es5/lib/utils/row-utils.js +0 -44
  137. package/dist/es5/lib/utils/row-utils.js.map +0 -1
  138. package/dist/es5/types.js +0 -2
  139. package/dist/esm/bundle.js +0 -5
  140. package/dist/esm/bundle.js.map +0 -1
  141. package/dist/esm/category/common.js +0 -2
  142. package/dist/esm/category/gis.js +0 -2
  143. package/dist/esm/category/mesh/convert-mesh.js +0 -26
  144. package/dist/esm/category/mesh/convert-mesh.js.map +0 -1
  145. package/dist/esm/category/mesh/deduce-mesh-schema.js +0 -42
  146. package/dist/esm/category/mesh/deduce-mesh-schema.js.map +0 -1
  147. package/dist/esm/category/mesh/mesh-to-arrow-table.js +0 -2
  148. package/dist/esm/category/mesh/mesh-to-arrow-table.js.map +0 -1
  149. package/dist/esm/category/mesh/mesh-types.js +0 -2
  150. package/dist/esm/category/mesh/mesh-types.js.map +0 -1
  151. package/dist/esm/category/mesh/mesh-utils.js +0 -38
  152. package/dist/esm/category/mesh/mesh-utils.js.map +0 -1
  153. package/dist/esm/category/table/deduce-table-schema.js +0 -51
  154. package/dist/esm/category/table/deduce-table-schema.js.map +0 -1
  155. package/dist/esm/category/table/table-types.js +0 -2
  156. package/dist/esm/category/table/table-types.js.map +0 -1
  157. package/dist/esm/index.js +0 -13
  158. package/dist/esm/index.js.map +0 -1
  159. package/dist/esm/lib/arrow/arrow-like-type-utils.js +0 -32
  160. package/dist/esm/lib/arrow/arrow-like-type-utils.js.map +0 -1
  161. package/dist/esm/lib/arrow/arrow-type-utils.js +0 -2
  162. package/dist/esm/lib/arrow/arrow-type-utils.js.map +0 -1
  163. package/dist/esm/lib/arrow/get-type-info.js +0 -24
  164. package/dist/esm/lib/arrow/get-type-info.js.map +0 -1
  165. package/dist/esm/lib/batches/base-table-batch-aggregator.js +0 -74
  166. package/dist/esm/lib/batches/base-table-batch-aggregator.js.map +0 -1
  167. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js +0 -100
  168. package/dist/esm/lib/batches/columnar-table-batch-aggregator.js.map +0 -1
  169. package/dist/esm/lib/batches/row-table-batch-aggregator.js +0 -95
  170. package/dist/esm/lib/batches/row-table-batch-aggregator.js.map +0 -1
  171. package/dist/esm/lib/batches/table-batch-aggregator.js +0 -2
  172. package/dist/esm/lib/batches/table-batch-aggregator.js.map +0 -1
  173. package/dist/esm/lib/batches/table-batch-builder.js +0 -182
  174. package/dist/esm/lib/batches/table-batch-builder.js.map +0 -1
  175. package/dist/esm/lib/schema/impl/enum.js +0 -49
  176. package/dist/esm/lib/schema/impl/enum.js.map +0 -1
  177. package/dist/esm/lib/schema/impl/field.js +0 -35
  178. package/dist/esm/lib/schema/impl/field.js.map +0 -1
  179. package/dist/esm/lib/schema/impl/schema.js +0 -92
  180. package/dist/esm/lib/schema/impl/schema.js.map +0 -1
  181. package/dist/esm/lib/schema/impl/type.js +0 -498
  182. package/dist/esm/lib/schema/impl/type.js.map +0 -1
  183. package/dist/esm/lib/schema/schema.js +0 -5
  184. package/dist/esm/lib/schema/schema.js.map +0 -1
  185. package/dist/esm/lib/schema-utils/deduce-column-type.js +0 -23
  186. package/dist/esm/lib/schema-utils/deduce-column-type.js.map +0 -1
  187. package/dist/esm/lib/utils/assert.js +0 -6
  188. package/dist/esm/lib/utils/assert.js.map +0 -1
  189. package/dist/esm/lib/utils/async-queue.js +0 -119
  190. package/dist/esm/lib/utils/async-queue.js.map +0 -1
  191. package/dist/esm/lib/utils/row-utils.js +0 -35
  192. package/dist/esm/lib/utils/row-utils.js.map +0 -1
  193. package/dist/esm/types.js +0 -2
  194. package/dist/esm/types.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","columnName","attribute","Object","entries","attributes","value","schema","data"],"mappings":"AASA,OAAO,SAASA,WAAT,CACLC,IADK,EAELC,KAFK,EAGLC,OAHK,EAI8B;AACnC,UAAQD,KAAK,IAAI,MAAjB;AACE,SAAK,MAAL;AACE,aAAOD,IAAP;;AACF,SAAK,gBAAL;AACE,aAAOG,0BAA0B,CAACH,IAAD,CAAjC;;AAMF;AACE,YAAM,IAAII,KAAJ,6BAA+BF,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAED,KAAxC,EAAN;AAXJ;AAaD;AAOD,OAAO,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,QAAMK,OAAO,GAAG,EAAhB;;AAEA,OAAK,MAAM,CAACC,UAAD,EAAaC,SAAb,CAAX,IAAsCC,MAAM,CAACC,OAAP,CAAeT,IAAI,CAACU,UAApB,CAAtC,EAAuE;AACrEL,IAAAA,OAAO,CAACC,UAAD,CAAP,GAAsBC,SAAS,CAACI,KAAhC;AACD;;AAED,SAAO;AACLV,IAAAA,KAAK,EAAE,gBADF;AAELW,IAAAA,MAAM,EAAEZ,IAAI,CAACY,MAFR;AAGLC,IAAAA,IAAI,EAAER;AAHD,GAAP;AAKD","sourcesContent":["import type {Mesh} from './mesh-types';\nimport type {ColumnarTable, ArrowTable} from '../table/table-types';\n// import {convertMeshToArrowTable} from './mesh-to-arrow-table';\n\ntype TargetShape = 'mesh' | 'columnar-table' | 'arrow-table';\n\n/**\n * Convert a mesh to a specific shape\n */\nexport function convertMesh(\n mesh: Mesh,\n shape: TargetShape,\n options?: any\n): Mesh | ColumnarTable | ArrowTable {\n switch (shape || 'mesh') {\n case 'mesh':\n return mesh;\n case 'columnar-table':\n return convertMeshToColumnarTable(mesh);\n // case 'arrow-table':\n // return {\n // shape: 'arrow-table',\n // data: convertMeshToArrowTable(mesh)\n // };\n default:\n throw new Error(`Unsupported shape ${options?.shape}`);\n }\n}\n\n/**\n * Convert a loaders.gl Mesh to a Columnar Table\n * @param mesh\n * @returns\n */\nexport function convertMeshToColumnarTable(mesh: Mesh): ColumnarTable {\n const columns = {};\n\n for (const [columnName, attribute] of Object.entries(mesh.attributes)) {\n columns[columnName] = attribute.value;\n }\n\n return {\n shape: 'columnar-table',\n schema: mesh.schema,\n data: columns\n };\n}\n"],"file":"convert-mesh.js"}
@@ -1,42 +0,0 @@
1
- import { Schema, Field, FixedSizeList } from '../../lib/schema/schema';
2
- import { getArrowTypeFromTypedArray } from '../../lib/arrow/arrow-like-type-utils';
3
- export function deduceMeshSchema(attributes, metadata) {
4
- const fields = deduceMeshFields(attributes);
5
- return new Schema(fields, metadata);
6
- }
7
- export function deduceMeshField(attributeName, attribute, optionalMetadata) {
8
- const type = getArrowTypeFromTypedArray(attribute.value);
9
- const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
10
- const field = new Field(attributeName, new FixedSizeList(attribute.size, new Field('value', type)), false, metadata);
11
- return field;
12
- }
13
-
14
- function deduceMeshFields(attributes) {
15
- const fields = [];
16
-
17
- for (const attributeName in attributes) {
18
- const attribute = attributes[attributeName];
19
- fields.push(deduceMeshField(attributeName, attribute));
20
- }
21
-
22
- return fields;
23
- }
24
-
25
- export function makeMeshAttributeMetadata(attribute) {
26
- const result = new Map();
27
-
28
- if ('byteOffset' in attribute) {
29
- result.set('byteOffset', attribute.byteOffset.toString(10));
30
- }
31
-
32
- if ('byteStride' in attribute) {
33
- result.set('byteStride', attribute.byteStride.toString(10));
34
- }
35
-
36
- if ('normalized' in attribute) {
37
- result.set('normalized', attribute.normalized.toString());
38
- }
39
-
40
- return result;
41
- }
42
- //# sourceMappingURL=deduce-mesh-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["Schema","Field","FixedSizeList","getArrowTypeFromTypedArray","deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":"AACA,SAAQA,MAAR,EAAgBC,KAAhB,EAAuBC,aAAvB,QAA2C,yBAA3C;AACA,SAAQC,0BAAR,QAAyC,uCAAzC;AAQA,OAAO,SAASC,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,QAA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D;;AACD,MAAI,gBAAgBZ,SAApB,EAA+B;AAC7BQ,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBV,SAAS,CAACc,UAAV,CAAsBF,QAAtB,EAAzB;AACD;;AACD,SAAOJ,MAAP;AACD","sourcesContent":["import {MeshAttribute, MeshAttributes} from './mesh-types';\nimport {Schema, Field, FixedSizeList} from '../../lib/schema/schema';\nimport {getArrowTypeFromTypedArray} from '../../lib/arrow/arrow-like-type-utils';\n\n/**\n * Create a schema for mesh attributes data\n * @param attributes\n * @param metadata\n * @returns\n */\nexport function deduceMeshSchema(\n attributes: MeshAttributes,\n metadata?: Map<string, string>\n): Schema {\n const fields = deduceMeshFields(attributes);\n return new Schema(fields, metadata);\n}\n\n/**\n * Create arrow-like schema field for mesh attribute\n * @param attributeName\n * @param attribute\n * @param optionalMetadata\n * @returns\n */\nexport function deduceMeshField(\n attributeName: string,\n attribute: MeshAttribute,\n optionalMetadata?: Map<string, string>\n): Field {\n const type = getArrowTypeFromTypedArray(attribute.value);\n const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);\n const field = new Field(\n attributeName,\n new FixedSizeList(attribute.size, new Field('value', type)),\n false,\n metadata\n );\n return field;\n}\n\n/**\n * Create fields array for mesh attributes\n * @param attributes\n * @returns\n */\nfunction deduceMeshFields(attributes: MeshAttributes): Field[] {\n const fields: Field[] = [];\n for (const attributeName in attributes) {\n const attribute: MeshAttribute = attributes[attributeName];\n fields.push(deduceMeshField(attributeName, attribute));\n }\n return fields;\n}\n\n/**\n * Make metadata by mesh attribute properties\n * @param attribute\n * @returns\n */\nexport function makeMeshAttributeMetadata(attribute: MeshAttribute): Map<string, string> {\n const result = new Map();\n if ('byteOffset' in attribute) {\n result.set('byteOffset', attribute.byteOffset!.toString(10));\n }\n if ('byteStride' in attribute) {\n result.set('byteStride', attribute.byteStride!.toString(10));\n }\n if ('normalized' in attribute) {\n result.set('normalized', attribute.normalized!.toString());\n }\n return result;\n}\n"],"file":"deduce-mesh-schema.js"}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=mesh-to-arrow-table.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"mesh-to-arrow-table.js"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mesh-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"mesh-types.js"}
@@ -1,38 +0,0 @@
1
- export function getMeshSize(attributes) {
2
- let size = 0;
3
-
4
- for (const attributeName in attributes) {
5
- const attribute = attributes[attributeName];
6
-
7
- if (ArrayBuffer.isView(attribute)) {
8
- size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
9
- }
10
- }
11
-
12
- return size;
13
- }
14
- export function getMeshBoundingBox(attributes) {
15
- let minX = Infinity;
16
- let minY = Infinity;
17
- let minZ = Infinity;
18
- let maxX = -Infinity;
19
- let maxY = -Infinity;
20
- let maxZ = -Infinity;
21
- const positions = attributes.POSITION ? attributes.POSITION.value : [];
22
- const len = positions && positions.length;
23
-
24
- for (let i = 0; i < len; i += 3) {
25
- const x = positions[i];
26
- const y = positions[i + 1];
27
- const z = positions[i + 2];
28
- minX = x < minX ? x : minX;
29
- minY = y < minY ? y : minY;
30
- minZ = z < minZ ? z : minZ;
31
- maxX = x > maxX ? x : maxX;
32
- maxY = y > maxY ? y : maxY;
33
- maxZ = z > maxZ ? z : maxZ;
34
- }
35
-
36
- return [[minX, minY, minZ], [maxX, maxY, maxZ]];
37
- }
38
- //# sourceMappingURL=mesh-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/category/mesh/mesh-utils.ts"],"names":["getMeshSize","attributes","size","attributeName","attribute","ArrayBuffer","isView","byteLength","BYTES_PER_ELEMENT","getMeshBoundingBox","minX","Infinity","minY","minZ","maxX","maxY","maxZ","positions","POSITION","value","len","length","i","x","y","z"],"mappings":"AAiBA,OAAO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AJ,GAAWY,CAAX,GAAeZ,IAAtB;AAEAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACAC,IAAAA,IAAI,GAAGS,CAAC,GAAGT,IAAJ,GAAWS,CAAX,GAAeT,IAAtB;AACD;;AACD,SAAO,CACL,CAACN,IAAD,EAAOE,IAAP,EAAaC,IAAb,CADK,EAEL,CAACC,IAAD,EAAOC,IAAP,EAAaC,IAAb,CAFK,CAAP;AAID","sourcesContent":["// Mesh category utilities\n// TODO - move to mesh category module, or to math.gl/geometry module\nimport {TypedArray} from '../../types';\nimport {MeshAttributes} from './mesh-types';\n\ntype TypedArrays = {[key: string]: TypedArray};\n\n/**\n * Holds an axis aligned bounding box\n * TODO - make sure AxisAlignedBoundingBox in math.gl/culling understands this format (or change this format)\n */\ntype BoundingBox = [[number, number, number], [number, number, number]];\n\n/**\n * Get number of vertices in mesh\n * @param attributes\n */\nexport function getMeshSize(attributes: TypedArrays): number {\n let size = 0;\n for (const attributeName in attributes) {\n const attribute = attributes[attributeName];\n if (ArrayBuffer.isView(attribute)) {\n // @ts-ignore DataView doesn't have BYTES_PER_ELEMENT\n size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;\n }\n }\n return size;\n}\n\n/**\n * Get the (axis aligned) bounding box of a mesh\n * @param attributes\n * @returns array of two vectors representing the axis aligned bounding box\n */\n// eslint-disable-next-line complexity\nexport function getMeshBoundingBox(attributes: MeshAttributes): BoundingBox {\n let minX = Infinity;\n let minY = Infinity;\n let minZ = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n let maxZ = -Infinity;\n\n const positions = attributes.POSITION ? attributes.POSITION.value : [];\n const len = positions && positions.length;\n\n for (let i = 0; i < len; i += 3) {\n const x = positions[i];\n const y = positions[i + 1];\n const z = positions[i + 2];\n\n minX = x < minX ? x : minX;\n minY = y < minY ? y : minY;\n minZ = z < minZ ? z : minZ;\n\n maxX = x > maxX ? x : maxX;\n maxY = y > maxY ? y : maxY;\n maxZ = z > maxZ ? z : maxZ;\n }\n return [\n [minX, minY, minZ],\n [maxX, maxY, maxZ]\n ];\n}\n"],"file":"mesh-utils.js"}
@@ -1,51 +0,0 @@
1
- export function deduceTableSchema(table, schema) {
2
- const deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
3
- return Object.assign(deducedSchema, schema);
4
- }
5
-
6
- function deduceSchemaForColumnarTable(columnarTable) {
7
- const schema = {};
8
-
9
- for (const field in columnarTable) {
10
- const column = columnarTable[field];
11
-
12
- if (ArrayBuffer.isView(column)) {
13
- schema[field] = column.constructor;
14
- } else if (column.length) {
15
- const value = column[0];
16
- schema[field] = deduceTypeFromValue(value);
17
- }
18
-
19
- schema[field] = schema[field] || null;
20
- }
21
-
22
- return schema;
23
- }
24
-
25
- function deduceSchemaForRowTable(rowTable) {
26
- const schema = {};
27
-
28
- if (rowTable.length) {
29
- const row = rowTable[0];
30
-
31
- for (const field in row) {
32
- const value = row[field];
33
- schema[field] = deduceTypeFromValue(value);
34
- }
35
- }
36
-
37
- return schema;
38
- }
39
-
40
- function deduceTypeFromValue(value) {
41
- if (value instanceof Date) {
42
- return Date;
43
- } else if (value instanceof Number) {
44
- return Float32Array;
45
- } else if (typeof value === 'string') {
46
- return String;
47
- }
48
-
49
- return null;
50
- }
51
- //# sourceMappingURL=deduce-table-schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/category/table/deduce-table-schema.ts"],"names":["deduceTableSchema","table","schema","deducedSchema","Array","isArray","deduceSchemaForRowTable","deduceSchemaForColumnarTable","Object","assign","columnarTable","field","column","ArrayBuffer","isView","constructor","length","value","deduceTypeFromValue","rowTable","row","Date","Number","Float32Array","String"],"mappings":"AAyCA,OAAO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkCC,MAAlC,EAAmD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AAYI,IAArB,EAA2B;AACzB,WAAOA,IAAP;AACD,GAFD,MAEO,IAAIJ,KAAK,YAAYK,MAArB,EAA6B;AAClC,WAAOC,YAAP;AACD,GAFM,MAEA,IAAI,OAAON,KAAP,KAAiB,QAArB,EAA+B;AACpC,WAAOO,MAAP;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["// Type deduction\nimport {\n Schema\n // Int,\n // Int8,\n // Int16,\n // Int32,\n // Uint8,\n // Uint16,\n // Uint32,\n // Float32,\n // Float64\n // Bool,\n // Utf8,\n // TimestampMillisecond,\n // Null\n} from '../../lib/schema/schema';\n\n// const TYPED_ARRAY_TO_TYPE = {\n// Int8Array: new Int8(),\n// Int16Array: new Int16(),\n// Int32Array: new Int32(),\n// Uint8Array: new Uint8(),\n// Uint8ClampedArray: new Uint8(),\n// Uint16Array: new Uint16(),\n// Uint32Array: new Uint32(),\n// Float32Array: new Float32(),\n// Float64Array: new Float64()\n// };\n\n// if (typeof BigInt64Array !== 'undefined') {\n// TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();\n// TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();\n// }\n\n/**\n * SCHEMA SUPPORT - AUTODEDUCTION\n * @param {*} table\n * @param {*} schema\n * @returns\n */\nexport function deduceTableSchema(table, schema?: Schema) {\n const deducedSchema = Array.isArray(table)\n ? deduceSchemaForRowTable(table)\n : deduceSchemaForColumnarTable(table);\n // Deduced schema will fill in missing info from partial options.schema, if provided\n return Object.assign(deducedSchema, schema);\n}\n\nfunction deduceSchemaForColumnarTable(columnarTable) {\n const schema = {};\n for (const field in columnarTable) {\n const column = columnarTable[field];\n // Check if column is typed, if so we are done\n if (ArrayBuffer.isView(column)) {\n schema[field] = column.constructor;\n // else we need data\n } else if (column.length) {\n const value = column[0];\n schema[field] = deduceTypeFromValue(value);\n // TODO - support nested schemas?\n }\n // else we mark as present but unknow\n schema[field] = schema[field] || null;\n }\n return schema;\n}\n\nfunction deduceSchemaForRowTable(rowTable) {\n const schema = {};\n if (rowTable.length) {\n const row = rowTable[0];\n // TODO - Could look at additional rows if nulls in first row\n for (const field in row) {\n const value = row[field];\n schema[field] = deduceTypeFromValue(value);\n }\n }\n return schema;\n}\n\nfunction deduceTypeFromValue(value) {\n if (value instanceof Date) {\n return Date;\n } else if (value instanceof Number) {\n return Float32Array;\n } else if (typeof value === 'string') {\n return String;\n }\n return null;\n}\n\n/*\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction deduceSchema(rows) {\n const row = rows[0];\n\n const schema = {};\n let i = 0;\n for (const columnName in row) {\n const value = row[columnName];\n switch (typeof value) {\n case 'number':\n case 'boolean':\n // TODO - booleans could be handled differently...\n schema[columnName] = {name: String(columnName), index: i, type: Float32Array};\n break;\n\n case 'object':\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n break;\n\n case 'string':\n default:\n schema[columnName] = {name: String(columnName), index: i, type: Array};\n // We currently only handle numeric rows\n // TODO we could offer a function to map strings to numbers?\n }\n i++;\n }\n return schema;\n}\n*/\n"],"file":"deduce-table-schema.js"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=table-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"table-types.js"}
package/dist/esm/index.js DELETED
@@ -1,13 +0,0 @@
1
- export { default as TableBatchBuilder } from './lib/batches/table-batch-builder';
2
- export { default as RowTableBatchAggregator } from './lib/batches/row-table-batch-aggregator';
3
- export { default as ColumnarTableBatchAggregator } from './lib/batches/columnar-table-batch-aggregator';
4
- export { convertToObjectRow, convertToArrayRow } from './lib/utils/row-utils';
5
- export { getMeshSize, getMeshBoundingBox } from './category/mesh/mesh-utils';
6
- export { convertMesh } from './category/mesh/convert-mesh';
7
- export { deduceMeshSchema, deduceMeshField, makeMeshAttributeMetadata } from './category/mesh/deduce-mesh-schema';
8
- export { Schema, Field, DataType, Null, Binary, Bool, Int, Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32, Uint64, Float, Float16, Float32, Float64, Utf8, Date, DateDay, DateMillisecond, Time, TimeMillisecond, TimeSecond, Timestamp, TimestampSecond, TimestampMillisecond, TimestampMicrosecond, TimestampNanosecond, Interval, IntervalDayTime, IntervalYearMonth, FixedSizeList, Struct } from './lib/schema/schema';
9
- export { deduceTypeFromColumn, deduceTypeFromValue } from './lib/schema-utils/deduce-column-type';
10
- export { getTypeInfo } from './lib/arrow/get-type-info';
11
- export { getArrowTypeFromTypedArray } from './lib/arrow/arrow-like-type-utils';
12
- export { default as AsyncQueue } from './lib/utils/async-queue';
13
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":["default","TableBatchBuilder","RowTableBatchAggregator","ColumnarTableBatchAggregator","convertToObjectRow","convertToArrayRow","getMeshSize","getMeshBoundingBox","convertMesh","deduceMeshSchema","deduceMeshField","makeMeshAttributeMetadata","Schema","Field","DataType","Null","Binary","Bool","Int","Int8","Int16","Int32","Int64","Uint8","Uint16","Uint32","Uint64","Float","Float16","Float32","Float64","Utf8","Date","DateDay","DateMillisecond","Time","TimeMillisecond","TimeSecond","Timestamp","TimestampSecond","TimestampMillisecond","TimestampMicrosecond","TimestampNanosecond","Interval","IntervalDayTime","IntervalYearMonth","FixedSizeList","Struct","deduceTypeFromColumn","deduceTypeFromValue","getTypeInfo","getArrowTypeFromTypedArray","AsyncQueue"],"mappings":"AAuBA,SAAQA,OAAO,IAAIC,iBAAnB,QAA2C,mCAA3C;AAEA,SAAQD,OAAO,IAAIE,uBAAnB,QAAiD,0CAAjD;AACA,SAAQF,OAAO,IAAIG,4BAAnB,QAAsD,+CAAtD;AAEA,SAAQC,kBAAR,EAA4BC,iBAA5B,QAAoD,uBAApD;AAYA,SAAQC,WAAR,EAAqBC,kBAArB,QAA8C,4BAA9C;AACA,SAAQC,WAAR,QAA0B,8BAA1B;AACA,SACEC,gBADF,EAEEC,eAFF,EAGEC,yBAHF,QAIO,oCAJP;AAiDA,SACEC,MADF,EAEEC,KAFF,EAGEC,QAHF,EAIEC,IAJF,EAKEC,MALF,EAMEC,IANF,EAOEC,GAPF,EAQEC,IARF,EASEC,KATF,EAUEC,KAVF,EAWEC,KAXF,EAYEC,KAZF,EAaEC,MAbF,EAcEC,MAdF,EAeEC,MAfF,EAgBEC,KAhBF,EAiBEC,OAjBF,EAkBEC,OAlBF,EAmBEC,OAnBF,EAoBEC,IApBF,EAqBEC,IArBF,EAsBEC,OAtBF,EAuBEC,eAvBF,EAwBEC,IAxBF,EAyBEC,eAzBF,EA0BEC,UA1BF,EA2BEC,SA3BF,EA4BEC,eA5BF,EA6BEC,oBA7BF,EA8BEC,oBA9BF,EA+BEC,mBA/BF,EAgCEC,QAhCF,EAiCEC,eAjCF,EAkCEC,iBAlCF,EAmCEC,aAnCF,EAoCEC,MApCF,QAqCO,qBArCP;AA0CA,SAAQC,oBAAR,EAA8BC,mBAA9B,QAAwD,uCAAxD;AACA,SAAQC,WAAR,QAA0B,2BAA1B;AACA,SAAQC,0BAAR,QAAyC,mCAAzC;AAEA,SAAQnD,OAAO,IAAIoD,UAAnB,QAAoC,yBAApC","sourcesContent":["// COMMON CATEGORY\nexport type {TypedArray, NumberArray, AnyArray} from './types';\n\nexport type {Batch} from './category/common';\n\n// TABLE CATEGORY TYPES\n\nexport type {\n Table,\n ArrayRowTable,\n ObjectRowTable,\n ColumnarTable,\n ArrowTable\n} from './category/table/table-types';\nexport type {\n TableBatch,\n RowArrayTableBatch,\n RowObjectTableBatch,\n ColumnarTableBatch,\n ArrowTableBatch\n} from './category/table/table-types';\n\n// TABLE CATEGORY UTILS\nexport {default as TableBatchBuilder} from './lib/batches/table-batch-builder';\nexport type {TableBatchAggregator} from './lib/batches/table-batch-aggregator';\nexport {default as RowTableBatchAggregator} from './lib/batches/row-table-batch-aggregator';\nexport {default as ColumnarTableBatchAggregator} from './lib/batches/columnar-table-batch-aggregator';\n\nexport {convertToObjectRow, convertToArrayRow} from './lib/utils/row-utils';\n\n// MESH CATEGORY\nexport type {\n MeshTable,\n MeshArrowTable,\n Mesh,\n MeshGeometry,\n MeshAttribute,\n MeshAttributes\n} from './category/mesh/mesh-types';\n\nexport {getMeshSize, getMeshBoundingBox} from './category/mesh/mesh-utils';\nexport {convertMesh} from './category/mesh/convert-mesh';\nexport {\n deduceMeshSchema,\n deduceMeshField,\n makeMeshAttributeMetadata\n} from './category/mesh/deduce-mesh-schema';\n\n// TYPES\n// GIS CATEGORY - GEOJSON\nexport type {GeoJSON, Feature, Geometry, Position, GeoJsonProperties} from './category/gis';\nexport type {\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n Polygon,\n MultiPolygon,\n GeometryCollection\n} from './category/gis';\n\nexport type {GeojsonGeometryInfo} from './category/gis';\n\n// GIS CATEGORY - FLAT GEOJSON\nexport type {\n FlatFeature,\n FlatIndexedGeometry,\n FlatGeometry,\n FlatGeometryType,\n FlatPoint,\n FlatLineString,\n FlatPolygon\n} from './category/gis';\n\n// GIS CATEGORY - BINARY\nexport type {\n BinaryGeometryType,\n BinaryGeometry,\n BinaryPointGeometry,\n BinaryLineGeometry,\n BinaryPolygonGeometry,\n BinaryAttribute\n} from './category/gis';\nexport type {\n BinaryFeatures,\n BinaryPointFeatures,\n BinaryLineFeatures,\n BinaryPolygonFeatures\n} from './category/gis';\n\n// SCHEMA\nexport {\n Schema,\n Field,\n DataType,\n Null,\n Binary,\n Bool,\n Int,\n Int8,\n Int16,\n Int32,\n Int64,\n Uint8,\n Uint16,\n Uint32,\n Uint64,\n Float,\n Float16,\n Float32,\n Float64,\n Utf8,\n Date,\n DateDay,\n DateMillisecond,\n Time,\n TimeMillisecond,\n TimeSecond,\n Timestamp,\n TimestampSecond,\n TimestampMillisecond,\n TimestampMicrosecond,\n TimestampNanosecond,\n Interval,\n IntervalDayTime,\n IntervalYearMonth,\n FixedSizeList,\n Struct\n} from './lib/schema/schema';\n\n// EXPERIMENTAL APIs\n\n// SCHEMA UTILS\nexport {deduceTypeFromColumn, deduceTypeFromValue} from './lib/schema-utils/deduce-column-type';\nexport {getTypeInfo} from './lib/arrow/get-type-info';\nexport {getArrowTypeFromTypedArray} from './lib/arrow/arrow-like-type-utils';\n\nexport {default as AsyncQueue} from './lib/utils/async-queue';\n"],"file":"index.js"}
@@ -1,32 +0,0 @@
1
- import { Float32, Float64, Int16, Int32, Int8, Uint16, Uint32, Uint8 } from '../schema/schema';
2
- export function getArrowTypeFromTypedArray(array) {
3
- switch (array.constructor) {
4
- case Int8Array:
5
- return new Int8();
6
-
7
- case Uint8Array:
8
- return new Uint8();
9
-
10
- case Int16Array:
11
- return new Int16();
12
-
13
- case Uint16Array:
14
- return new Uint16();
15
-
16
- case Int32Array:
17
- return new Int32();
18
-
19
- case Uint32Array:
20
- return new Uint32();
21
-
22
- case Float32Array:
23
- return new Float32();
24
-
25
- case Float64Array:
26
- return new Float64();
27
-
28
- default:
29
- throw new Error('array type not supported');
30
- }
31
- }
32
- //# sourceMappingURL=arrow-like-type-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/arrow/arrow-like-type-utils.ts"],"names":["Float32","Float64","Int16","Int32","Int8","Uint16","Uint32","Uint8","getArrowTypeFromTypedArray","array","constructor","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","Error"],"mappings":"AACA,SAEEA,OAFF,EAGEC,OAHF,EAIEC,KAJF,EAKEC,KALF,EAMEC,IANF,EAOEC,MAPF,EAQEC,MARF,EASEC,KATF,QAUO,kBAVP;AAYA,OAAO,SAASC,0BAAT,CAAoCC,KAApC,EAAiE;AACtE,UAAQA,KAAK,CAACC,WAAd;AACE,SAAKC,SAAL;AACE,aAAO,IAAIP,IAAJ,EAAP;;AACF,SAAKQ,UAAL;AACE,aAAO,IAAIL,KAAJ,EAAP;;AACF,SAAKM,UAAL;AACE,aAAO,IAAIX,KAAJ,EAAP;;AACF,SAAKY,WAAL;AACE,aAAO,IAAIT,MAAJ,EAAP;;AACF,SAAKU,UAAL;AACE,aAAO,IAAIZ,KAAJ,EAAP;;AACF,SAAKa,WAAL;AACE,aAAO,IAAIV,MAAJ,EAAP;;AACF,SAAKW,YAAL;AACE,aAAO,IAAIjB,OAAJ,EAAP;;AACF,SAAKkB,YAAL;AACE,aAAO,IAAIjB,OAAJ,EAAP;;AACF;AACE,YAAM,IAAIkB,KAAJ,CAAU,0BAAV,CAAN;AAlBJ;AAoBD","sourcesContent":["import type {TypedArray} from '../../types';\nimport {\n DataType,\n Float32,\n Float64,\n Int16,\n Int32,\n Int8,\n Uint16,\n Uint32,\n Uint8\n} from '../schema/schema';\n\nexport function getArrowTypeFromTypedArray(array: TypedArray): DataType {\n switch (array.constructor) {\n case Int8Array:\n return new Int8();\n case Uint8Array:\n return new Uint8();\n case Int16Array:\n return new Int16();\n case Uint16Array:\n return new Uint16();\n case Int32Array:\n return new Int32();\n case Uint32Array:\n return new Uint32();\n case Float32Array:\n return new Float32();\n case Float64Array:\n return new Float64();\n default:\n throw new Error('array type not supported');\n }\n}\n"],"file":"arrow-like-type-utils.js"}
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=arrow-type-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"arrow-type-utils.js"}
@@ -1,24 +0,0 @@
1
- import { Type } from '../schema/schema';
2
- export function getTypeInfo(arrowTypeLike) {
3
- return {
4
- typeId: arrowTypeLike.typeId,
5
- ArrayType: arrowTypeLike.ArrayType,
6
- typeName: arrowTypeLike.toString(),
7
- typeEnumName: getTypeKey(arrowTypeLike.typeId),
8
- precision: arrowTypeLike.precision
9
- };
10
- }
11
- let ReverseType = null;
12
-
13
- function getTypeKey(typeKey) {
14
- if (!ReverseType) {
15
- ReverseType = {};
16
-
17
- for (const key in Type) {
18
- ReverseType[Type[key]] = key;
19
- }
20
- }
21
-
22
- return ReverseType[typeKey];
23
- }
24
- //# sourceMappingURL=get-type-info.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/arrow/get-type-info.ts"],"names":["Type","getTypeInfo","arrowTypeLike","typeId","ArrayType","typeName","toString","typeEnumName","getTypeKey","precision","ReverseType","typeKey","key"],"mappings":"AAAA,SAAQA,IAAR,QAAmB,kBAAnB;AAOA,OAAO,SAASC,WAAT,CAAqBC,aAArB,EAML;AACA,SAAO;AACLC,IAAAA,MAAM,EAAED,aAAa,CAACC,MADjB;AAELC,IAAAA,SAAS,EAAEF,aAAa,CAACE,SAFpB;AAGLC,IAAAA,QAAQ,EAAEH,aAAa,CAACI,QAAd,EAHL;AAILC,IAAAA,YAAY,EAAEC,UAAU,CAACN,aAAa,CAACC,MAAf,CAJnB;AAKLM,IAAAA,SAAS,EAAEP,aAAa,CAACO;AALpB,GAAP;AAOD;AAED,IAAIC,WAA2C,GAAG,IAAlD;;AAEA,SAASF,UAAT,CAAoBG,OAApB,EAA6B;AAC3B,MAAI,CAACD,WAAL,EAAkB;AAChBA,IAAAA,WAAW,GAAG,EAAd;;AACA,SAAK,MAAME,GAAX,IAAkBZ,IAAlB,EAAwB;AACtBU,MAAAA,WAAW,CAACV,IAAI,CAACY,GAAD,CAAL,CAAX,GAAyBA,GAAzB;AACD;AACF;;AAED,SAAOF,WAAW,CAACC,OAAD,CAAlB;AACD","sourcesContent":["import {Type} from '../schema/schema';\nimport {AnyArray} from '../../types';\n\n/**\n * Gets type information from an Arrow type object or \"mock\" Arrow type object\n * @param arrowTypeLike Arrow Type or type object of similar shape\n */\nexport function getTypeInfo(arrowTypeLike: any): {\n typeId: Type;\n ArrayType: AnyArray;\n typeName: string;\n typeEnumName?: string;\n precision?: number;\n} {\n return {\n typeId: arrowTypeLike.typeId,\n ArrayType: arrowTypeLike.ArrayType,\n typeName: arrowTypeLike.toString(),\n typeEnumName: getTypeKey(arrowTypeLike.typeId),\n precision: arrowTypeLike.precision\n };\n}\n\nlet ReverseType: {[key: string]: string} | null = null;\n\nfunction getTypeKey(typeKey) {\n if (!ReverseType) {\n ReverseType = {};\n for (const key in Type) {\n ReverseType[Type[key]] = key;\n }\n }\n\n return ReverseType[typeKey];\n}\n"],"file":"get-type-info.js"}
@@ -1,74 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- const DEFAULT_ROW_COUNT = 100;
3
- export default class RowTableBatchAggregator {
4
- constructor(schema, options) {
5
- _defineProperty(this, "schema", void 0);
6
-
7
- _defineProperty(this, "options", void 0);
8
-
9
- _defineProperty(this, "length", 0);
10
-
11
- _defineProperty(this, "rows", null);
12
-
13
- _defineProperty(this, "cursor", 0);
14
-
15
- _defineProperty(this, "_headers", []);
16
-
17
- this.options = options;
18
- this.schema = schema;
19
-
20
- if (!Array.isArray(schema)) {
21
- this._headers = [];
22
-
23
- for (const key in schema) {
24
- this._headers[schema[key].index] = schema[key].name;
25
- }
26
- }
27
- }
28
-
29
- rowCount() {
30
- return this.length;
31
- }
32
-
33
- addArrayRow(row, cursor) {
34
- if (Number.isFinite(cursor)) {
35
- this.cursor = cursor;
36
- }
37
-
38
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
39
- this.rows[this.length] = row;
40
- this.length++;
41
- }
42
-
43
- addObjectRow(row, cursor) {
44
- if (Number.isFinite(cursor)) {
45
- this.cursor = cursor;
46
- }
47
-
48
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
49
- this.rows[this.length] = row;
50
- this.length++;
51
- }
52
-
53
- getBatch() {
54
- let rows = this.rows;
55
-
56
- if (!rows) {
57
- return null;
58
- }
59
-
60
- rows = rows.slice(0, this.length);
61
- this.rows = null;
62
- const batch = {
63
- shape: this.options.shape,
64
- batchType: 'data',
65
- data: rows,
66
- length: this.length,
67
- schema: this.schema,
68
- cursor: this.cursor
69
- };
70
- return batch;
71
- }
72
-
73
- }
74
- //# sourceMappingURL=base-table-batch-aggregator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/batches/base-table-batch-aggregator.ts"],"names":["DEFAULT_ROW_COUNT","RowTableBatchAggregator","constructor","schema","options","Array","isArray","_headers","key","index","name","rowCount","length","addArrayRow","row","cursor","Number","isFinite","rows","addObjectRow","getBatch","slice","batch","shape","batchType","data"],"mappings":";AAIA,MAAMA,iBAAiB,GAAG,GAA1B;AAEA,eAAe,MAAMC,uBAAN,CAA8D;AAS3EC,EAAAA,WAAW,CAACC,MAAD,EAAiBC,OAAjB,EAA6C;AAAA;;AAAA;;AAAA,oCALvC,CAKuC;;AAAA,kCAJnC,IAImC;;AAAA,oCAHvC,CAGuC;;AAAA,sCAF3B,EAE2B;;AACtD,SAAKA,OAAL,GAAeA,OAAf;AACA,SAAKD,MAAL,GAAcA,MAAd;;AAIA,QAAI,CAACE,KAAK,CAACC,OAAN,CAAcH,MAAd,CAAL,EAA4B;AAC1B,WAAKI,QAAL,GAAgB,EAAhB;;AACA,WAAK,MAAMC,GAAX,IAAkBL,MAAlB,EAA0B;AACxB,aAAKI,QAAL,CAAcJ,MAAM,CAACK,GAAD,CAAN,CAAYC,KAA1B,IAAmCN,MAAM,CAACK,GAAD,CAAN,CAAYE,IAA/C;AACD;AACF;AACF;;AAEDC,EAAAA,QAAQ,GAAW;AACjB,WAAO,KAAKC,MAAZ;AACD;;AAEDC,EAAAA,WAAW,CAACC,GAAD,EAAaC,MAAb,EAAoC;AAC7C,QAAIC,MAAM,CAACC,QAAP,CAAgBF,MAAhB,CAAJ,EAA6B;AAC3B,WAAKA,MAAL,GAAcA,MAAd;AACD;;AAED,SAAKG,IAAL,GAAY,KAAKA,IAAL,IAAa,IAAIb,KAAJ,CAAUL,iBAAV,CAAzB;AACA,SAAKkB,IAAL,CAAU,KAAKN,MAAf,IAAyBE,GAAzB;AACA,SAAKF,MAAL;AACD;;AAEDO,EAAAA,YAAY,CAACL,GAAD,EAAmCC,MAAnC,EAA0D;AACpE,QAAIC,MAAM,CAACC,QAAP,CAAgBF,MAAhB,CAAJ,EAA6B;AAC3B,WAAKA,MAAL,GAAcA,MAAd;AACD;;AAED,SAAKG,IAAL,GAAY,KAAKA,IAAL,IAAa,IAAIb,KAAJ,CAAUL,iBAAV,CAAzB;AACA,SAAKkB,IAAL,CAAU,KAAKN,MAAf,IAAyBE,GAAzB;AACA,SAAKF,MAAL;AACD;;AAEDQ,EAAAA,QAAQ,GAAsB;AAC5B,QAAIF,IAAI,GAAG,KAAKA,IAAhB;;AACA,QAAI,CAACA,IAAL,EAAW;AACT,aAAO,IAAP;AACD;;AAEDA,IAAAA,IAAI,GAAGA,IAAI,CAACG,KAAL,CAAW,CAAX,EAAc,KAAKT,MAAnB,CAAP;AACA,SAAKM,IAAL,GAAY,IAAZ;AAEA,UAAMI,KAAiB,GAAG;AACxBC,MAAAA,KAAK,EAAE,KAAKnB,OAAL,CAAamB,KADI;AAExBC,MAAAA,SAAS,EAAE,MAFa;AAGxBC,MAAAA,IAAI,EAAEP,IAHkB;AAIxBN,MAAAA,MAAM,EAAE,KAAKA,MAJW;AAKxBT,MAAAA,MAAM,EAAE,KAAKA,MALW;AAMxBY,MAAAA,MAAM,EAAE,KAAKA;AANW,KAA1B;AASA,WAAOO,KAAP;AACD;;AAlE0E","sourcesContent":["import type {Schema} from '../schema/schema';\nimport type {TableBatch} from '../../category/table/table-types';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport default class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n rows: any[] | null = null;\n cursor: number = 0;\n private _headers: string[] = [];\n\n constructor(schema: Schema, options: TableBatchOptions) {\n this.options = options;\n this.schema = schema;\n\n // schema is an array if there're no headers\n // object if there are headers\n if (!Array.isArray(schema)) {\n this._headers = [];\n for (const key in schema) {\n this._headers[schema[key].index] = schema[key].name;\n }\n }\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[], cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);\n this.rows[this.length] = row;\n this.length++;\n }\n\n addObjectRow(row: {[columnName: string]: any}, cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);\n this.rows[this.length] = row;\n this.length++;\n }\n\n getBatch(): TableBatch | null {\n let rows = this.rows;\n if (!rows) {\n return null;\n }\n\n rows = rows.slice(0, this.length);\n this.rows = null;\n\n const batch: TableBatch = {\n shape: this.options.shape,\n batchType: 'data',\n data: rows,\n length: this.length,\n schema: this.schema,\n cursor: this.cursor\n };\n\n return batch;\n }\n}\n"],"file":"base-table-batch-aggregator.js"}
@@ -1,100 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- const DEFAULT_ROW_COUNT = 100;
3
- export default class ColumnarTableBatchAggregator {
4
- constructor(schema, options) {
5
- _defineProperty(this, "schema", void 0);
6
-
7
- _defineProperty(this, "length", 0);
8
-
9
- _defineProperty(this, "allocated", 0);
10
-
11
- _defineProperty(this, "columns", {});
12
-
13
- this.schema = schema;
14
-
15
- this._reallocateColumns();
16
- }
17
-
18
- rowCount() {
19
- return this.length;
20
- }
21
-
22
- addArrayRow(row) {
23
- this._reallocateColumns();
24
-
25
- let i = 0;
26
-
27
- for (const fieldName in this.columns) {
28
- this.columns[fieldName][this.length] = row[i++];
29
- }
30
-
31
- this.length++;
32
- }
33
-
34
- addObjectRow(row) {
35
- this._reallocateColumns();
36
-
37
- for (const fieldName in row) {
38
- this.columns[fieldName][this.length] = row[fieldName];
39
- }
40
-
41
- this.length++;
42
- }
43
-
44
- getBatch() {
45
- this._pruneColumns();
46
-
47
- const columns = Array.isArray(this.schema) ? this.columns : {};
48
-
49
- if (!Array.isArray(this.schema)) {
50
- for (const fieldName in this.schema) {
51
- const field = this.schema[fieldName];
52
- columns[field.name] = this.columns[field.index];
53
- }
54
- }
55
-
56
- this.columns = {};
57
- const batch = {
58
- shape: 'columnar-table',
59
- batchType: 'data',
60
- data: columns,
61
- schema: this.schema,
62
- length: this.length
63
- };
64
- return batch;
65
- }
66
-
67
- _reallocateColumns() {
68
- if (this.length < this.allocated) {
69
- return;
70
- }
71
-
72
- this.allocated = this.allocated > 0 ? this.allocated *= 2 : DEFAULT_ROW_COUNT;
73
- this.columns = {};
74
-
75
- for (const fieldName in this.schema) {
76
- const field = this.schema[fieldName];
77
- const ArrayType = field.type || Float32Array;
78
- const oldColumn = this.columns[field.index];
79
-
80
- if (oldColumn && ArrayBuffer.isView(oldColumn)) {
81
- const typedArray = new ArrayType(this.allocated);
82
- typedArray.set(oldColumn);
83
- this.columns[field.index] = typedArray;
84
- } else if (oldColumn) {
85
- oldColumn.length = this.allocated;
86
- this.columns[field.index] = oldColumn;
87
- } else {
88
- this.columns[field.index] = new ArrayType(this.allocated);
89
- }
90
- }
91
- }
92
-
93
- _pruneColumns() {
94
- for (const [columnName, column] of Object.entries(this.columns)) {
95
- this.columns[columnName] = column.slice(0, this.length);
96
- }
97
- }
98
-
99
- }
100
- //# sourceMappingURL=columnar-table-batch-aggregator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/batches/columnar-table-batch-aggregator.ts"],"names":["DEFAULT_ROW_COUNT","ColumnarTableBatchAggregator","constructor","schema","options","_reallocateColumns","rowCount","length","addArrayRow","row","i","fieldName","columns","addObjectRow","getBatch","_pruneColumns","Array","isArray","field","name","index","batch","shape","batchType","data","allocated","ArrayType","type","Float32Array","oldColumn","ArrayBuffer","isView","typedArray","set","columnName","column","Object","entries","slice"],"mappings":";AAMA,MAAMA,iBAAiB,GAAG,GAA1B;AAEA,eAAe,MAAMC,4BAAN,CAAmE;AAMhFC,EAAAA,WAAW,CAACC,MAAD,EAAiBC,OAAjB,EAAqD;AAAA;;AAAA,oCAJ/C,CAI+C;;AAAA,uCAH5C,CAG4C;;AAAA,qCAFvB,EAEuB;;AAC9D,SAAKD,MAA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KzB,OAApB,CAAnC,EAAiE;AAC/D,WAAKA,OAAL,CAAasB,UAAb,IAA2BC,MAAM,CAACG,KAAP,CAAa,CAAb,EAAgB,KAAK/B,MAArB,CAA3B;AACD;AACF;;AAlG+E","sourcesContent":["import type {Schema} from '../schema/schema';\nimport type {ColumnarTableBatch, ArrowTableBatch} from '../../category/table/table-types';\nimport {TableBatchAggregator} from './table-batch-aggregator';\n\ntype ColumnarTableBatchOptions = {};\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport default class ColumnarTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n length: number = 0;\n allocated: number = 0;\n columns: {[columnName: string]: any[]} = {};\n\n constructor(schema: Schema, options: ColumnarTableBatchOptions) {\n this.schema = schema;\n this._reallocateColumns();\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[]) {\n // If user keeps pushing rows beyond batch size, reallocate\n this._reallocateColumns();\n let i = 0;\n // TODO what if no csv header, columns not populated?\n for (const fieldName in this.columns) {\n this.columns[fieldName][this.length] = row[i++];\n }\n this.length++;\n }\n\n addObjectRow(row: {[columnName: string]: any}): void {\n // If user keeps pushing rows beyond batch size, reallocate\n this._reallocateColumns();\n for (const fieldName in row) {\n this.columns[fieldName][this.length] = row[fieldName];\n }\n this.length++;\n }\n\n getBatch(): ColumnarTableBatch | ArrowTableBatch | null {\n this._pruneColumns();\n const columns = Array.isArray(this.schema) ? this.columns : {};\n\n // schema is an array if there're no headers\n // object if there are headers\n // columns should match schema format\n if (!Array.isArray(this.schema)) {\n for (const fieldName in this.schema) {\n const field = this.schema[fieldName];\n columns[field.name] = this.columns[field.index];\n }\n }\n\n this.columns = {};\n\n const batch: ColumnarTableBatch = {\n shape: 'columnar-table',\n batchType: 'data',\n data: columns,\n schema: this.schema,\n length: this.length\n };\n\n return batch;\n }\n\n // HELPERS\n\n _reallocateColumns() {\n if (this.length < this.allocated) {\n return;\n }\n\n // @ts-ignore TODO\n this.allocated = this.allocated > 0 ? (this.allocated *= 2) : DEFAULT_ROW_COUNT;\n this.columns = {};\n\n for (const fieldName in this.schema) {\n const field = this.schema[fieldName];\n const ArrayType = field.type || Float32Array;\n const oldColumn = this.columns[field.index];\n\n if (oldColumn && ArrayBuffer.isView(oldColumn)) {\n // Copy the old data to the new array\n const typedArray = new ArrayType(this.allocated);\n typedArray.set(oldColumn);\n this.columns[field.index] = typedArray;\n } else if (oldColumn) {\n // Plain array\n oldColumn.length = this.allocated;\n this.columns[field.index] = oldColumn;\n } else {\n // Create new\n this.columns[field.index] = new ArrayType(this.allocated);\n }\n }\n }\n\n _pruneColumns() {\n for (const [columnName, column] of Object.entries(this.columns)) {\n this.columns[columnName] = column.slice(0, this.length);\n }\n }\n}\n"],"file":"columnar-table-batch-aggregator.js"}
@@ -1,95 +0,0 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { convertToArrayRow, convertToObjectRow } from '../utils/row-utils';
3
- const DEFAULT_ROW_COUNT = 100;
4
- export default class RowTableBatchAggregator {
5
- constructor(schema, options) {
6
- _defineProperty(this, "schema", void 0);
7
-
8
- _defineProperty(this, "options", void 0);
9
-
10
- _defineProperty(this, "length", 0);
11
-
12
- _defineProperty(this, "objectRows", null);
13
-
14
- _defineProperty(this, "arrayRows", null);
15
-
16
- _defineProperty(this, "cursor", 0);
17
-
18
- _defineProperty(this, "_headers", []);
19
-
20
- this.options = options;
21
- this.schema = schema;
22
-
23
- if (!Array.isArray(schema)) {
24
- this._headers = [];
25
-
26
- for (const key in schema) {
27
- this._headers[schema[key].index] = schema[key].name;
28
- }
29
- }
30
- }
31
-
32
- rowCount() {
33
- return this.length;
34
- }
35
-
36
- addArrayRow(row, cursor) {
37
- if (Number.isFinite(cursor)) {
38
- this.cursor = cursor;
39
- }
40
-
41
- switch (this.options.shape) {
42
- case 'object-row-table':
43
- const rowObject = convertToObjectRow(row, this._headers);
44
- this.addObjectRow(rowObject, cursor);
45
- break;
46
-
47
- case 'array-row-table':
48
- this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT);
49
- this.arrayRows[this.length] = row;
50
- this.length++;
51
- break;
52
- }
53
- }
54
-
55
- addObjectRow(row, cursor) {
56
- if (Number.isFinite(cursor)) {
57
- this.cursor = cursor;
58
- }
59
-
60
- switch (this.options.shape) {
61
- case 'array-row-table':
62
- const rowArray = convertToArrayRow(row, this._headers);
63
- this.addArrayRow(rowArray, cursor);
64
- break;
65
-
66
- case 'object-row-table':
67
- this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT);
68
- this.objectRows[this.length] = row;
69
- this.length++;
70
- break;
71
- }
72
- }
73
-
74
- getBatch() {
75
- let rows = this.arrayRows || this.objectRows;
76
-
77
- if (!rows) {
78
- return null;
79
- }
80
-
81
- rows = rows.slice(0, this.length);
82
- this.arrayRows = null;
83
- this.objectRows = null;
84
- return {
85
- shape: this.options.shape,
86
- batchType: 'data',
87
- data: rows,
88
- length: this.length,
89
- schema: this.schema,
90
- cursor: this.cursor
91
- };
92
- }
93
-
94
- }
95
- //# sourceMappingURL=row-table-batch-aggregator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../../src/lib/batches/row-table-batch-aggregator.ts"],"names":["convertToArrayRow","convertToObjectRow","DEFAULT_ROW_COUNT","RowTableBatchAggregator","constructor","schema","options","Array","isArray","_headers","key","index","name","rowCount","length","addArrayRow","row","cursor","Number","isFinite","shape","rowObject","addObjectRow","arrayRows","rowArray","objectRows","getBatch","rows","slice","batchType","data"],"mappings":";AAGA,SAAQA,iBAAR,EAA2BC,kBAA3B,QAAoD,oBAApD;AAGA,MAAMC,iBAAiB,GAAG,GAA1B;AAEA,eAAe,MAAMC,uBAAN,CAA8D;AAU3EC,EAAAA,WAAW,CAACC,MAAD,EAAiBC,OAAjB,EAA6C;AAAA;;AAAA;;AAAA,oCANvC,CAMuC;;AAAA,wCALP,IAKO;;AAAA,uCAJ9B,IAI8B;;AAAA,oCAHvC,CAGuC;;AAAA,sCAF3B,EAE2B;;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,WAAL,CAAiBS,QAAjB,EAA2BP,MAA3B;AACA;;AACF,WAAK,kBAAL;AACE,aAAKQ,UAAL,GAAkB,KAAKA,UAAL,IAAmB,IAAIlB,KAAJ,CAAUL,iBAAV,CAArC;AACA,aAAKuB,UAAL,CAAgB,KAAKX,MAArB,IAA+BE,GAA/B;AACA,aAAKF,MAAL;AACA;AATJ;AAWD;;AAEDY,EAAAA,QAAQ,GAAsB;AAC5B,QAAIC,IAAI,GAAG,KAAKJ,SAAL,IAAkB,KAAKE,UAAlC;;AACA,QAAI,CAACE,IAAL,EAAW;AACT,aAAO,IAAP;AACD;;AAEDA,IAAAA,IAAI,GAAGA,IAAI,CAACC,KAAL,CAAW,CAAX,EAAc,KAAKd,MAAnB,CAAP;AACA,SAAKS,SAAL,GAAiB,IAAjB;AACA,SAAKE,UAAL,GAAkB,IAAlB;AAEA,WAAO;AACLL,MAAAA,KAAK,EAAE,KAAKd,OAAL,CAAac,KADf;AAELS,MAAAA,SAAS,EAAE,MAFN;AAGLC,MAAAA,IAAI,EAAEH,IAHD;AAILb,MAAAA,MAAM,EAAE,KAAKA,MAJR;AAKLT,MAAAA,MAAM,EAAE,KAAKA,MALR;AAMLY,MAAAA,MAAM,EAAE,KAAKA;AANR,KAAP;AAQD;;AApF0E","sourcesContent":["import type {Schema} from '../schema/schema';\nimport type {TableBatch} from '../../category/table/table-types';\n// import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';\nimport {convertToArrayRow, convertToObjectRow} from '../utils/row-utils';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport default class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n objectRows: {[columnName: string]: any} | null = null;\n arrayRows: any[] | null = null;\n cursor: number = 0;\n private _headers: string[] = [];\n\n constructor(schema: Schema, options: TableBatchOptions) {\n this.options = options;\n this.schema = schema;\n\n // schema is an array if there're no headers\n // object if there are headers\n if (!Array.isArray(schema)) {\n this._headers = [];\n for (const key in schema) {\n this._headers[schema[key].index] = schema[key].name;\n }\n }\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[], cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'object-row-table':\n const rowObject = convertToObjectRow(row, this._headers);\n this.addObjectRow(rowObject, cursor);\n break;\n case 'array-row-table':\n this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT);\n this.arrayRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n addObjectRow(row: {[columnName: string]: any}, cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'array-row-table':\n const rowArray = convertToArrayRow(row, this._headers);\n this.addArrayRow(rowArray, cursor);\n break;\n case 'object-row-table':\n this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT);\n this.objectRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n getBatch(): TableBatch | null {\n let rows = this.arrayRows || this.objectRows;\n if (!rows) {\n return null;\n }\n\n rows = rows.slice(0, this.length);\n this.arrayRows = null;\n this.objectRows = null;\n\n return {\n shape: this.options.shape,\n batchType: 'data',\n data: rows,\n length: this.length,\n schema: this.schema,\n cursor: this.cursor\n };\n }\n}\n"],"file":"row-table-batch-aggregator.js"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=table-batch-aggregator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"table-batch-aggregator.js"}