@loaders.gl/schema 3.1.0-beta.4 → 3.1.0

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 (34) hide show
  1. package/dist/es5/bundle.js +1 -1
  2. package/dist/es5/bundle.js.map +1 -1
  3. package/dist/es5/category/mesh/convert-mesh.js +10 -2
  4. package/dist/es5/category/mesh/convert-mesh.js.map +1 -1
  5. package/dist/es5/category/mesh/deduce-mesh-schema.js +8 -8
  6. package/dist/es5/category/mesh/deduce-mesh-schema.js.map +1 -1
  7. package/dist/es5/category/mesh/mesh-utils.js +16 -16
  8. package/dist/es5/category/mesh/mesh-utils.js.map +1 -1
  9. package/dist/es5/category/table/deduce-table-schema.js +9 -9
  10. package/dist/es5/category/table/deduce-table-schema.js.map +1 -1
  11. package/dist/es5/index.js +52 -52
  12. package/dist/es5/lib/arrow/get-type-info.js +3 -3
  13. package/dist/es5/lib/arrow/get-type-info.js.map +1 -1
  14. package/dist/es5/lib/batches/base-table-batch-aggregator.js +53 -42
  15. package/dist/es5/lib/batches/base-table-batch-aggregator.js.map +1 -1
  16. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js +90 -71
  17. package/dist/es5/lib/batches/columnar-table-batch-aggregator.js.map +1 -1
  18. package/dist/es5/lib/batches/row-table-batch-aggregator.js +70 -59
  19. package/dist/es5/lib/batches/row-table-batch-aggregator.js.map +1 -1
  20. package/dist/es5/lib/batches/table-batch-builder.js +133 -113
  21. package/dist/es5/lib/batches/table-batch-builder.js.map +1 -1
  22. package/dist/es5/lib/schema/impl/enum.js +1 -1
  23. package/dist/es5/lib/schema/impl/field.js +32 -19
  24. package/dist/es5/lib/schema/impl/field.js.map +1 -1
  25. package/dist/es5/lib/schema/impl/schema.js +119 -54
  26. package/dist/es5/lib/schema/impl/schema.js.map +1 -1
  27. package/dist/es5/lib/schema/impl/type.js +728 -395
  28. package/dist/es5/lib/schema/impl/type.js.map +1 -1
  29. package/dist/es5/lib/schema/schema.js +37 -37
  30. package/dist/es5/lib/utils/async-queue.js +164 -81
  31. package/dist/es5/lib/utils/async-queue.js.map +1 -1
  32. package/dist/es5/lib/utils/row-utils.js +4 -4
  33. package/dist/es5/lib/utils/row-utils.js.map +1 -1
  34. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- const moduleExports = require('./index');
3
+ var moduleExports = require('./index');
4
4
 
5
5
  globalThis.loaders = globalThis.loaders || {};
6
6
  module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.convertMesh = convertMesh;
7
9
  exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
8
10
 
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+
9
13
  function convertMesh(mesh, shape, options) {
10
14
  switch (shape || 'mesh') {
11
15
  case 'mesh':
@@ -20,9 +24,13 @@ function convertMesh(mesh, shape, options) {
20
24
  }
21
25
 
22
26
  function convertMeshToColumnarTable(mesh) {
23
- const columns = {};
27
+ var columns = {};
28
+
29
+ for (var _i = 0, _Object$entries = Object.entries(mesh.attributes); _i < _Object$entries.length; _i++) {
30
+ var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
31
+ columnName = _Object$entries$_i[0],
32
+ attribute = _Object$entries$_i[1];
24
33
 
25
- for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
26
34
  columns[columnName] = attribute.value;
27
35
  }
28
36
 
@@ -1 +1 @@
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":";;;;;;;;AASO,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;;AAOM,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
+ {"version":3,"sources":["../../../../src/category/mesh/convert-mesh.ts"],"names":["convertMesh","mesh","shape","options","convertMeshToColumnarTable","Error","columns","Object","entries","attributes","columnName","attribute","value","schema","data"],"mappings":";;;;;;;;;;;;AASO,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;;AAOM,SAASE,0BAAT,CAAoCH,IAApC,EAA+D;AACpE,MAAMK,OAAO,GAAG,EAAhB;;AAEA,qCAAsCC,MAAM,CAACC,OAAP,CAAeP,IAAI,CAACQ,UAApB,CAAtC,qCAAuE;AAAlE;AAAA,QAAOC,UAAP;AAAA,QAAmBC,SAAnB;;AACHL,IAAAA,OAAO,CAACI,UAAD,CAAP,GAAsBC,SAAS,CAACC,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"}
@@ -12,22 +12,22 @@ var _schema = require("../../lib/schema/schema");
12
12
  var _arrowLikeTypeUtils = require("../../lib/arrow/arrow-like-type-utils");
13
13
 
14
14
  function deduceMeshSchema(attributes, metadata) {
15
- const fields = deduceMeshFields(attributes);
15
+ var fields = deduceMeshFields(attributes);
16
16
  return new _schema.Schema(fields, metadata);
17
17
  }
18
18
 
19
19
  function deduceMeshField(attributeName, attribute, optionalMetadata) {
20
- const type = (0, _arrowLikeTypeUtils.getArrowTypeFromTypedArray)(attribute.value);
21
- const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
22
- const field = new _schema.Field(attributeName, new _schema.FixedSizeList(attribute.size, new _schema.Field('value', type)), false, metadata);
20
+ var type = (0, _arrowLikeTypeUtils.getArrowTypeFromTypedArray)(attribute.value);
21
+ var metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
22
+ var field = new _schema.Field(attributeName, new _schema.FixedSizeList(attribute.size, new _schema.Field('value', type)), false, metadata);
23
23
  return field;
24
24
  }
25
25
 
26
26
  function deduceMeshFields(attributes) {
27
- const fields = [];
27
+ var fields = [];
28
28
 
29
- for (const attributeName in attributes) {
30
- const attribute = attributes[attributeName];
29
+ for (var attributeName in attributes) {
30
+ var attribute = attributes[attributeName];
31
31
  fields.push(deduceMeshField(attributeName, attribute));
32
32
  }
33
33
 
@@ -35,7 +35,7 @@ function deduceMeshFields(attributes) {
35
35
  }
36
36
 
37
37
  function makeMeshAttributeMetadata(attribute) {
38
- const result = new Map();
38
+ var result = new Map();
39
39
 
40
40
  if ('byteOffset' in attribute) {
41
41
  result.set('byteOffset', attribute.byteOffset.toString(10));
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","Schema","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","Field","FixedSizeList","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":";;;;;;;;;AACA;;AACA;;AAQO,SAASA,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,QAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAII,cAAJ,CAAWF,MAAX,EAAmBD,QAAnB,CAAP;AACD;;AASM,SAASI,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,QAAMC,IAAI,GAAG,oDAA2BF,SAAS,CAACG,KAArC,CAAb;AACA,QAAMT,QAAQ,GAAGO,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,QAAMK,KAAK,GAAG,IAAIC,aAAJ,CACZP,aADY,EAEZ,IAAIQ,qBAAJ,CAAkBP,SAAS,CAACQ,IAA5B,EAAkC,IAAIF,aAAJ,CAAU,OAAV,EAAmBJ,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZR,QAJY,CAAd;AAMA,SAAOW,KAAP;AACD;;AAOD,SAAST,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,QAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,MAAMI,aAAX,IAA4BN,UAA5B,EAAwC;AACtC,UAAMO,SAAwB,GAAGP,UAAU,CAACM,aAAD,CAA3C;AACAJ,IAAAA,MAAM,CAACc,IAAP,CAAYX,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOL,MAAP;AACD;;AAOM,SAASS,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,QAAMU,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBX,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACa,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACe,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACgB,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
+ {"version":3,"sources":["../../../../src/category/mesh/deduce-mesh-schema.ts"],"names":["deduceMeshSchema","attributes","metadata","fields","deduceMeshFields","Schema","deduceMeshField","attributeName","attribute","optionalMetadata","type","value","makeMeshAttributeMetadata","field","Field","FixedSizeList","size","push","result","Map","set","byteOffset","toString","byteStride","normalized"],"mappings":";;;;;;;;;AACA;;AACA;;AAQO,SAASA,gBAAT,CACLC,UADK,EAELC,QAFK,EAGG;AACR,MAAMC,MAAM,GAAGC,gBAAgB,CAACH,UAAD,CAA/B;AACA,SAAO,IAAII,cAAJ,CAAWF,MAAX,EAAmBD,QAAnB,CAAP;AACD;;AASM,SAASI,eAAT,CACLC,aADK,EAELC,SAFK,EAGLC,gBAHK,EAIE;AACP,MAAMC,IAAI,GAAG,oDAA2BF,SAAS,CAACG,KAArC,CAAb;AACA,MAAMT,QAAQ,GAAGO,gBAAgB,GAAGA,gBAAH,GAAsBG,yBAAyB,CAACJ,SAAD,CAAhF;AACA,MAAMK,KAAK,GAAG,IAAIC,aAAJ,CACZP,aADY,EAEZ,IAAIQ,qBAAJ,CAAkBP,SAAS,CAACQ,IAA5B,EAAkC,IAAIF,aAAJ,CAAU,OAAV,EAAmBJ,IAAnB,CAAlC,CAFY,EAGZ,KAHY,EAIZR,QAJY,CAAd;AAMA,SAAOW,KAAP;AACD;;AAOD,SAAST,gBAAT,CAA0BH,UAA1B,EAA+D;AAC7D,MAAME,MAAe,GAAG,EAAxB;;AACA,OAAK,IAAMI,aAAX,IAA4BN,UAA5B,EAAwC;AACtC,QAAMO,SAAwB,GAAGP,UAAU,CAACM,aAAD,CAA3C;AACAJ,IAAAA,MAAM,CAACc,IAAP,CAAYX,eAAe,CAACC,aAAD,EAAgBC,SAAhB,CAA3B;AACD;;AACD,SAAOL,MAAP;AACD;;AAOM,SAASS,yBAAT,CAAmCJ,SAAnC,EAAkF;AACvF,MAAMU,MAAM,GAAG,IAAIC,GAAJ,EAAf;;AACA,MAAI,gBAAgBX,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACa,UAAV,CAAsBC,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACe,UAAV,CAAsBD,QAAtB,CAA+B,EAA/B,CAAzB;AACD;;AACD,MAAI,gBAAgBd,SAApB,EAA+B;AAC7BU,IAAAA,MAAM,CAACE,GAAP,CAAW,YAAX,EAAyBZ,SAAS,CAACgB,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"}
@@ -7,10 +7,10 @@ exports.getMeshSize = getMeshSize;
7
7
  exports.getMeshBoundingBox = getMeshBoundingBox;
8
8
 
9
9
  function getMeshSize(attributes) {
10
- let size = 0;
10
+ var size = 0;
11
11
 
12
- for (const attributeName in attributes) {
13
- const attribute = attributes[attributeName];
12
+ for (var attributeName in attributes) {
13
+ var attribute = attributes[attributeName];
14
14
 
15
15
  if (ArrayBuffer.isView(attribute)) {
16
16
  size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
@@ -21,19 +21,19 @@ function getMeshSize(attributes) {
21
21
  }
22
22
 
23
23
  function getMeshBoundingBox(attributes) {
24
- let minX = Infinity;
25
- let minY = Infinity;
26
- let minZ = Infinity;
27
- let maxX = -Infinity;
28
- let maxY = -Infinity;
29
- let maxZ = -Infinity;
30
- const positions = attributes.POSITION ? attributes.POSITION.value : [];
31
- const len = positions && positions.length;
32
-
33
- for (let i = 0; i < len; i += 3) {
34
- const x = positions[i];
35
- const y = positions[i + 1];
36
- const z = positions[i + 2];
24
+ var minX = Infinity;
25
+ var minY = Infinity;
26
+ var minZ = Infinity;
27
+ var maxX = -Infinity;
28
+ var maxY = -Infinity;
29
+ var maxZ = -Infinity;
30
+ var positions = attributes.POSITION ? attributes.POSITION.value : [];
31
+ var len = positions && positions.length;
32
+
33
+ for (var i = 0; i < len; i += 3) {
34
+ var x = positions[i];
35
+ var y = positions[i + 1];
36
+ var z = positions[i + 2];
37
37
  minX = x < minX ? x : minX;
38
38
  minY = y < minY ? y : minY;
39
39
  minZ = z < minZ ? z : minZ;
@@ -1 +1 @@
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":";;;;;;;;AAiBO,SAASA,WAAT,CAAqBC,UAArB,EAAsD;AAC3D,MAAIC,IAAI,GAAG,CAAX;;AACA,OAAK,MAAMC,aAAX,IAA4BF,UAA5B,EAAwC;AACtC,UAAMG,SAAS,GAAGH,UAAU,CAACE,aAAD,CAA5B;;AACA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,SAAnB,CAAJ,EAAmC;AAEjCF,MAAAA,IAAI,IAAIE,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,iBAAzC;AACD;AACF;;AACD,SAAON,IAAP;AACD;;AAQM,SAASO,kBAAT,CAA4BR,UAA5B,EAAqE;AAC1E,MAAIS,IAAI,GAAGC,QAAX;AACA,MAAIC,IAAI,GAAGD,QAAX;AACA,MAAIE,IAAI,GAAGF,QAAX;AACA,MAAIG,IAAI,GAAG,CAACH,QAAZ;AACA,MAAII,IAAI,GAAG,CAACJ,QAAZ;AACA,MAAIK,IAAI,GAAG,CAACL,QAAZ;AAEA,QAAMM,SAAS,GAAGhB,UAAU,CAACiB,QAAX,GAAsBjB,UAAU,CAACiB,QAAX,CAAoBC,KAA1C,GAAkD,EAApE;AACA,QAAMC,GAAG,GAAGH,SAAS,IAAIA,SAAS,CAACI,MAAnC;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,GAApB,EAAyBE,CAAC,IAAI,CAA9B,EAAiC;AAC/B,UAAMC,CAAC,GAAGN,SAAS,CAACK,CAAD,CAAnB;AACA,UAAME,CAAC,GAAGP,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AACA,UAAMG,CAAC,GAAGR,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AAEAZ,IAAAA,IAAI,GAAGa,CAAC,GAAGb,IAAJ,GAAWa,CAAX,GAAeb,IAAtB;AACAE,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,GAAWY,CAAX,GAAeZ,IAAtB;AACAC,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,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
+ {"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":";;;;;;;;AAiBO,SAASA,WAAT,CAAqBC,UAArB,EAAsD;AAC3D,MAAIC,IAAI,GAAG,CAAX;;AACA,OAAK,IAAMC,aAAX,IAA4BF,UAA5B,EAAwC;AACtC,QAAMG,SAAS,GAAGH,UAAU,CAACE,aAAD,CAA5B;;AACA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,SAAnB,CAAJ,EAAmC;AAEjCF,MAAAA,IAAI,IAAIE,SAAS,CAACG,UAAV,GAAuBH,SAAS,CAACI,iBAAzC;AACD;AACF;;AACD,SAAON,IAAP;AACD;;AAQM,SAASO,kBAAT,CAA4BR,UAA5B,EAAqE;AAC1E,MAAIS,IAAI,GAAGC,QAAX;AACA,MAAIC,IAAI,GAAGD,QAAX;AACA,MAAIE,IAAI,GAAGF,QAAX;AACA,MAAIG,IAAI,GAAG,CAACH,QAAZ;AACA,MAAII,IAAI,GAAG,CAACJ,QAAZ;AACA,MAAIK,IAAI,GAAG,CAACL,QAAZ;AAEA,MAAMM,SAAS,GAAGhB,UAAU,CAACiB,QAAX,GAAsBjB,UAAU,CAACiB,QAAX,CAAoBC,KAA1C,GAAkD,EAApE;AACA,MAAMC,GAAG,GAAGH,SAAS,IAAIA,SAAS,CAACI,MAAnC;;AAEA,OAAK,IAAIC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,GAApB,EAAyBE,CAAC,IAAI,CAA9B,EAAiC;AAC/B,QAAMC,CAAC,GAAGN,SAAS,CAACK,CAAD,CAAnB;AACA,QAAME,CAAC,GAAGP,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AACA,QAAMG,CAAC,GAAGR,SAAS,CAACK,CAAC,GAAG,CAAL,CAAnB;AAEAZ,IAAAA,IAAI,GAAGa,CAAC,GAAGb,IAAJ,GAAWa,CAAX,GAAeb,IAAtB;AACAE,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,GAAWY,CAAX,GAAeZ,IAAtB;AACAC,IAAAA,IAAI,GAAGY,CAAC,GAAGZ,IAAJ,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"}
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.deduceTableSchema = deduceTableSchema;
7
7
 
8
8
  function deduceTableSchema(table, schema) {
9
- const deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
9
+ var deducedSchema = Array.isArray(table) ? deduceSchemaForRowTable(table) : deduceSchemaForColumnarTable(table);
10
10
  return Object.assign(deducedSchema, schema);
11
11
  }
12
12
 
13
13
  function deduceSchemaForColumnarTable(columnarTable) {
14
- const schema = {};
14
+ var schema = {};
15
15
 
16
- for (const field in columnarTable) {
17
- const column = columnarTable[field];
16
+ for (var field in columnarTable) {
17
+ var column = columnarTable[field];
18
18
 
19
19
  if (ArrayBuffer.isView(column)) {
20
20
  schema[field] = column.constructor;
21
21
  } else if (column.length) {
22
- const value = column[0];
22
+ var value = column[0];
23
23
  schema[field] = deduceTypeFromValue(value);
24
24
  }
25
25
 
@@ -30,13 +30,13 @@ function deduceSchemaForColumnarTable(columnarTable) {
30
30
  }
31
31
 
32
32
  function deduceSchemaForRowTable(rowTable) {
33
- const schema = {};
33
+ var schema = {};
34
34
 
35
35
  if (rowTable.length) {
36
- const row = rowTable[0];
36
+ var row = rowTable[0];
37
37
 
38
- for (const field in row) {
39
- const value = row[field];
38
+ for (var field in row) {
39
+ var value = row[field];
40
40
  schema[field] = deduceTypeFromValue(value);
41
41
  }
42
42
  }
@@ -1 +1 @@
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":";;;;;;;AAyCO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkCC,MAAlC,EAAmD;AACxD,QAAMC,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAcJ,KAAd,IAClBK,uBAAuB,CAACL,KAAD,CADL,GAElBM,4BAA4B,CAACN,KAAD,CAFhC;AAIA,SAAOO,MAAM,CAACC,MAAP,CAAcN,aAAd,EAA6BD,MAA7B,CAAP;AACD;;AAED,SAASK,4BAAT,CAAsCG,aAAtC,EAAqD;AACnD,QAAMR,MAAM,GAAG,EAAf;;AACA,OAAK,MAAMS,KAAX,IAAoBD,aAApB,EAAmC;AACjC,UAAME,MAAM,GAAGF,aAAa,CAACC,KAAD,CAA5B;;AAEA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,MAAnB,CAAJ,EAAgC;AAC9BV,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBC,MAAM,CAACG,WAAvB;AAED,KAHD,MAGO,IAAIH,MAAM,CAACI,MAAX,EAAmB;AACxB,YAAMC,KAAK,GAAGL,MAAM,CAAC,CAAD,CAApB;AACAV,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBO,mBAAmB,CAACD,KAAD,CAAnC;AAED;;AAEDf,IAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBT,MAAM,CAACS,KAAD,CAAN,IAAiB,IAAjC;AACD;;AACD,SAAOT,MAAP;AACD;;AAED,SAASI,uBAAT,CAAiCa,QAAjC,EAA2C;AACzC,QAAMjB,MAAM,GAAG,EAAf;;AACA,MAAIiB,QAAQ,CAACH,MAAb,EAAqB;AACnB,UAAMI,GAAG,GAAGD,QAAQ,CAAC,CAAD,CAApB;;AAEA,SAAK,MAAMR,KAAX,IAAoBS,GAApB,EAAyB;AACvB,YAAMH,KAAK,GAAGG,GAAG,CAACT,KAAD,CAAjB;AACAT,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBO,mBAAmB,CAACD,KAAD,CAAnC;AACD;AACF;;AACD,SAAOf,MAAP;AACD;;AAED,SAASgB,mBAAT,CAA6BD,KAA7B,EAAoC;AAClC,MAAIA,KAAK,YAAYI,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
+ {"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":";;;;;;;AAyCO,SAASA,iBAAT,CAA2BC,KAA3B,EAAkCC,MAAlC,EAAmD;AACxD,MAAMC,aAAa,GAAGC,KAAK,CAACC,OAAN,CAAcJ,KAAd,IAClBK,uBAAuB,CAACL,KAAD,CADL,GAElBM,4BAA4B,CAACN,KAAD,CAFhC;AAIA,SAAOO,MAAM,CAACC,MAAP,CAAcN,aAAd,EAA6BD,MAA7B,CAAP;AACD;;AAED,SAASK,4BAAT,CAAsCG,aAAtC,EAAqD;AACnD,MAAMR,MAAM,GAAG,EAAf;;AACA,OAAK,IAAMS,KAAX,IAAoBD,aAApB,EAAmC;AACjC,QAAME,MAAM,GAAGF,aAAa,CAACC,KAAD,CAA5B;;AAEA,QAAIE,WAAW,CAACC,MAAZ,CAAmBF,MAAnB,CAAJ,EAAgC;AAC9BV,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBC,MAAM,CAACG,WAAvB;AAED,KAHD,MAGO,IAAIH,MAAM,CAACI,MAAX,EAAmB;AACxB,UAAMC,KAAK,GAAGL,MAAM,CAAC,CAAD,CAApB;AACAV,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBO,mBAAmB,CAACD,KAAD,CAAnC;AAED;;AAEDf,IAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBT,MAAM,CAACS,KAAD,CAAN,IAAiB,IAAjC;AACD;;AACD,SAAOT,MAAP;AACD;;AAED,SAASI,uBAAT,CAAiCa,QAAjC,EAA2C;AACzC,MAAMjB,MAAM,GAAG,EAAf;;AACA,MAAIiB,QAAQ,CAACH,MAAb,EAAqB;AACnB,QAAMI,GAAG,GAAGD,QAAQ,CAAC,CAAD,CAApB;;AAEA,SAAK,IAAMR,KAAX,IAAoBS,GAApB,EAAyB;AACvB,UAAMH,KAAK,GAAGG,GAAG,CAACT,KAAD,CAAjB;AACAT,MAAAA,MAAM,CAACS,KAAD,CAAN,GAAgBO,mBAAmB,CAACD,KAAD,CAAnC;AACD;AACF;;AACD,SAAOf,MAAP;AACD;;AAED,SAASgB,mBAAT,CAA6BD,KAA7B,EAAoC;AAClC,MAAIA,KAAK,YAAYI,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"}
package/dist/es5/index.js CHANGED
@@ -7,313 +7,313 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "TableBatchBuilder", {
9
9
  enumerable: true,
10
- get: function () {
10
+ get: function get() {
11
11
  return _tableBatchBuilder.default;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "RowTableBatchAggregator", {
15
15
  enumerable: true,
16
- get: function () {
16
+ get: function get() {
17
17
  return _rowTableBatchAggregator.default;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "ColumnarTableBatchAggregator", {
21
21
  enumerable: true,
22
- get: function () {
22
+ get: function get() {
23
23
  return _columnarTableBatchAggregator.default;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "convertToObjectRow", {
27
27
  enumerable: true,
28
- get: function () {
28
+ get: function get() {
29
29
  return _rowUtils.convertToObjectRow;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "convertToArrayRow", {
33
33
  enumerable: true,
34
- get: function () {
34
+ get: function get() {
35
35
  return _rowUtils.convertToArrayRow;
36
36
  }
37
37
  });
38
38
  Object.defineProperty(exports, "getMeshSize", {
39
39
  enumerable: true,
40
- get: function () {
40
+ get: function get() {
41
41
  return _meshUtils.getMeshSize;
42
42
  }
43
43
  });
44
44
  Object.defineProperty(exports, "getMeshBoundingBox", {
45
45
  enumerable: true,
46
- get: function () {
46
+ get: function get() {
47
47
  return _meshUtils.getMeshBoundingBox;
48
48
  }
49
49
  });
50
50
  Object.defineProperty(exports, "convertMesh", {
51
51
  enumerable: true,
52
- get: function () {
52
+ get: function get() {
53
53
  return _convertMesh.convertMesh;
54
54
  }
55
55
  });
56
56
  Object.defineProperty(exports, "deduceMeshSchema", {
57
57
  enumerable: true,
58
- get: function () {
58
+ get: function get() {
59
59
  return _deduceMeshSchema.deduceMeshSchema;
60
60
  }
61
61
  });
62
62
  Object.defineProperty(exports, "deduceMeshField", {
63
63
  enumerable: true,
64
- get: function () {
64
+ get: function get() {
65
65
  return _deduceMeshSchema.deduceMeshField;
66
66
  }
67
67
  });
68
68
  Object.defineProperty(exports, "makeMeshAttributeMetadata", {
69
69
  enumerable: true,
70
- get: function () {
70
+ get: function get() {
71
71
  return _deduceMeshSchema.makeMeshAttributeMetadata;
72
72
  }
73
73
  });
74
74
  Object.defineProperty(exports, "Schema", {
75
75
  enumerable: true,
76
- get: function () {
76
+ get: function get() {
77
77
  return _schema.Schema;
78
78
  }
79
79
  });
80
80
  Object.defineProperty(exports, "Field", {
81
81
  enumerable: true,
82
- get: function () {
82
+ get: function get() {
83
83
  return _schema.Field;
84
84
  }
85
85
  });
86
86
  Object.defineProperty(exports, "DataType", {
87
87
  enumerable: true,
88
- get: function () {
88
+ get: function get() {
89
89
  return _schema.DataType;
90
90
  }
91
91
  });
92
92
  Object.defineProperty(exports, "Null", {
93
93
  enumerable: true,
94
- get: function () {
94
+ get: function get() {
95
95
  return _schema.Null;
96
96
  }
97
97
  });
98
98
  Object.defineProperty(exports, "Binary", {
99
99
  enumerable: true,
100
- get: function () {
100
+ get: function get() {
101
101
  return _schema.Binary;
102
102
  }
103
103
  });
104
104
  Object.defineProperty(exports, "Bool", {
105
105
  enumerable: true,
106
- get: function () {
106
+ get: function get() {
107
107
  return _schema.Bool;
108
108
  }
109
109
  });
110
110
  Object.defineProperty(exports, "Int", {
111
111
  enumerable: true,
112
- get: function () {
112
+ get: function get() {
113
113
  return _schema.Int;
114
114
  }
115
115
  });
116
116
  Object.defineProperty(exports, "Int8", {
117
117
  enumerable: true,
118
- get: function () {
118
+ get: function get() {
119
119
  return _schema.Int8;
120
120
  }
121
121
  });
122
122
  Object.defineProperty(exports, "Int16", {
123
123
  enumerable: true,
124
- get: function () {
124
+ get: function get() {
125
125
  return _schema.Int16;
126
126
  }
127
127
  });
128
128
  Object.defineProperty(exports, "Int32", {
129
129
  enumerable: true,
130
- get: function () {
130
+ get: function get() {
131
131
  return _schema.Int32;
132
132
  }
133
133
  });
134
134
  Object.defineProperty(exports, "Int64", {
135
135
  enumerable: true,
136
- get: function () {
136
+ get: function get() {
137
137
  return _schema.Int64;
138
138
  }
139
139
  });
140
140
  Object.defineProperty(exports, "Uint8", {
141
141
  enumerable: true,
142
- get: function () {
142
+ get: function get() {
143
143
  return _schema.Uint8;
144
144
  }
145
145
  });
146
146
  Object.defineProperty(exports, "Uint16", {
147
147
  enumerable: true,
148
- get: function () {
148
+ get: function get() {
149
149
  return _schema.Uint16;
150
150
  }
151
151
  });
152
152
  Object.defineProperty(exports, "Uint32", {
153
153
  enumerable: true,
154
- get: function () {
154
+ get: function get() {
155
155
  return _schema.Uint32;
156
156
  }
157
157
  });
158
158
  Object.defineProperty(exports, "Uint64", {
159
159
  enumerable: true,
160
- get: function () {
160
+ get: function get() {
161
161
  return _schema.Uint64;
162
162
  }
163
163
  });
164
164
  Object.defineProperty(exports, "Float", {
165
165
  enumerable: true,
166
- get: function () {
166
+ get: function get() {
167
167
  return _schema.Float;
168
168
  }
169
169
  });
170
170
  Object.defineProperty(exports, "Float16", {
171
171
  enumerable: true,
172
- get: function () {
172
+ get: function get() {
173
173
  return _schema.Float16;
174
174
  }
175
175
  });
176
176
  Object.defineProperty(exports, "Float32", {
177
177
  enumerable: true,
178
- get: function () {
178
+ get: function get() {
179
179
  return _schema.Float32;
180
180
  }
181
181
  });
182
182
  Object.defineProperty(exports, "Float64", {
183
183
  enumerable: true,
184
- get: function () {
184
+ get: function get() {
185
185
  return _schema.Float64;
186
186
  }
187
187
  });
188
188
  Object.defineProperty(exports, "Utf8", {
189
189
  enumerable: true,
190
- get: function () {
190
+ get: function get() {
191
191
  return _schema.Utf8;
192
192
  }
193
193
  });
194
194
  Object.defineProperty(exports, "Date", {
195
195
  enumerable: true,
196
- get: function () {
196
+ get: function get() {
197
197
  return _schema.Date;
198
198
  }
199
199
  });
200
200
  Object.defineProperty(exports, "DateDay", {
201
201
  enumerable: true,
202
- get: function () {
202
+ get: function get() {
203
203
  return _schema.DateDay;
204
204
  }
205
205
  });
206
206
  Object.defineProperty(exports, "DateMillisecond", {
207
207
  enumerable: true,
208
- get: function () {
208
+ get: function get() {
209
209
  return _schema.DateMillisecond;
210
210
  }
211
211
  });
212
212
  Object.defineProperty(exports, "Time", {
213
213
  enumerable: true,
214
- get: function () {
214
+ get: function get() {
215
215
  return _schema.Time;
216
216
  }
217
217
  });
218
218
  Object.defineProperty(exports, "TimeMillisecond", {
219
219
  enumerable: true,
220
- get: function () {
220
+ get: function get() {
221
221
  return _schema.TimeMillisecond;
222
222
  }
223
223
  });
224
224
  Object.defineProperty(exports, "TimeSecond", {
225
225
  enumerable: true,
226
- get: function () {
226
+ get: function get() {
227
227
  return _schema.TimeSecond;
228
228
  }
229
229
  });
230
230
  Object.defineProperty(exports, "Timestamp", {
231
231
  enumerable: true,
232
- get: function () {
232
+ get: function get() {
233
233
  return _schema.Timestamp;
234
234
  }
235
235
  });
236
236
  Object.defineProperty(exports, "TimestampSecond", {
237
237
  enumerable: true,
238
- get: function () {
238
+ get: function get() {
239
239
  return _schema.TimestampSecond;
240
240
  }
241
241
  });
242
242
  Object.defineProperty(exports, "TimestampMillisecond", {
243
243
  enumerable: true,
244
- get: function () {
244
+ get: function get() {
245
245
  return _schema.TimestampMillisecond;
246
246
  }
247
247
  });
248
248
  Object.defineProperty(exports, "TimestampMicrosecond", {
249
249
  enumerable: true,
250
- get: function () {
250
+ get: function get() {
251
251
  return _schema.TimestampMicrosecond;
252
252
  }
253
253
  });
254
254
  Object.defineProperty(exports, "TimestampNanosecond", {
255
255
  enumerable: true,
256
- get: function () {
256
+ get: function get() {
257
257
  return _schema.TimestampNanosecond;
258
258
  }
259
259
  });
260
260
  Object.defineProperty(exports, "Interval", {
261
261
  enumerable: true,
262
- get: function () {
262
+ get: function get() {
263
263
  return _schema.Interval;
264
264
  }
265
265
  });
266
266
  Object.defineProperty(exports, "IntervalDayTime", {
267
267
  enumerable: true,
268
- get: function () {
268
+ get: function get() {
269
269
  return _schema.IntervalDayTime;
270
270
  }
271
271
  });
272
272
  Object.defineProperty(exports, "IntervalYearMonth", {
273
273
  enumerable: true,
274
- get: function () {
274
+ get: function get() {
275
275
  return _schema.IntervalYearMonth;
276
276
  }
277
277
  });
278
278
  Object.defineProperty(exports, "FixedSizeList", {
279
279
  enumerable: true,
280
- get: function () {
280
+ get: function get() {
281
281
  return _schema.FixedSizeList;
282
282
  }
283
283
  });
284
284
  Object.defineProperty(exports, "Struct", {
285
285
  enumerable: true,
286
- get: function () {
286
+ get: function get() {
287
287
  return _schema.Struct;
288
288
  }
289
289
  });
290
290
  Object.defineProperty(exports, "deduceTypeFromColumn", {
291
291
  enumerable: true,
292
- get: function () {
292
+ get: function get() {
293
293
  return _deduceColumnType.deduceTypeFromColumn;
294
294
  }
295
295
  });
296
296
  Object.defineProperty(exports, "deduceTypeFromValue", {
297
297
  enumerable: true,
298
- get: function () {
298
+ get: function get() {
299
299
  return _deduceColumnType.deduceTypeFromValue;
300
300
  }
301
301
  });
302
302
  Object.defineProperty(exports, "getTypeInfo", {
303
303
  enumerable: true,
304
- get: function () {
304
+ get: function get() {
305
305
  return _getTypeInfo.getTypeInfo;
306
306
  }
307
307
  });
308
308
  Object.defineProperty(exports, "getArrowTypeFromTypedArray", {
309
309
  enumerable: true,
310
- get: function () {
310
+ get: function get() {
311
311
  return _arrowLikeTypeUtils.getArrowTypeFromTypedArray;
312
312
  }
313
313
  });
314
314
  Object.defineProperty(exports, "AsyncQueue", {
315
315
  enumerable: true,
316
- get: function () {
316
+ get: function get() {
317
317
  return _asyncQueue.default;
318
318
  }
319
319
  });
@@ -17,14 +17,14 @@ function getTypeInfo(arrowTypeLike) {
17
17
  };
18
18
  }
19
19
 
20
- let ReverseType = null;
20
+ var ReverseType = null;
21
21
 
22
22
  function getTypeKey(typeKey) {
23
23
  if (!ReverseType) {
24
24
  ReverseType = {};
25
25
 
26
- for (const key in _schema.Type) {
27
- ReverseType[_schema.Type[key]] = key;
26
+ for (var _key in _schema.Type) {
27
+ ReverseType[_schema.Type[_key]] = _key;
28
28
  }
29
29
  }
30
30
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/arrow/get-type-info.ts"],"names":["getTypeInfo","arrowTypeLike","typeId","ArrayType","typeName","toString","typeEnumName","getTypeKey","precision","ReverseType","typeKey","key","Type"],"mappings":";;;;;;;AAAA;;AAOO,SAASA,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,IAAkBC,YAAlB,EAAwB;AACtBH,MAAAA,WAAW,CAACG,aAAKD,GAAL,CAAD,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
+ {"version":3,"sources":["../../../../src/lib/arrow/get-type-info.ts"],"names":["getTypeInfo","arrowTypeLike","typeId","ArrayType","typeName","toString","typeEnumName","getTypeKey","precision","ReverseType","typeKey","key","Type"],"mappings":";;;;;;;AAAA;;AAOO,SAASA,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,IAAME,IAAX,IAAkBC,YAAlB,EAAwB;AACtBH,MAAAA,WAAW,CAACG,aAAKD,IAAL,CAAD,CAAX,GAAyBA,IAAzB;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"}