@loaders.gl/schema 3.4.10 → 3.4.12

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 (32) hide show
  1. package/package.json +2 -2
  2. package/dist/bundle.js +0 -5
  3. package/dist/category/common.js +0 -10
  4. package/dist/category/gis.js +0 -2
  5. package/dist/category/image/image.js +0 -2
  6. package/dist/category/mesh/convert-mesh.js +0 -40
  7. package/dist/category/mesh/deduce-mesh-schema.js +0 -62
  8. package/dist/category/mesh/mesh-to-arrow-table.js +0 -34
  9. package/dist/category/mesh/mesh-types.js +0 -2
  10. package/dist/category/mesh/mesh-utils.js +0 -51
  11. package/dist/category/table/deduce-table-schema.js +0 -106
  12. package/dist/category/table/table-types.js +0 -2
  13. package/dist/category/texture/texture.js +0 -2
  14. package/dist/index.js +0 -75
  15. package/dist/lib/arrow/arrow-like-type-utils.js +0 -27
  16. package/dist/lib/arrow/arrow-type-utils.js +0 -50
  17. package/dist/lib/arrow/get-type-info.js +0 -28
  18. package/dist/lib/batches/base-table-batch-aggregator.js +0 -58
  19. package/dist/lib/batches/columnar-table-batch-aggregator.js +0 -90
  20. package/dist/lib/batches/row-table-batch-aggregator.js +0 -79
  21. package/dist/lib/batches/table-batch-aggregator.js +0 -2
  22. package/dist/lib/batches/table-batch-builder.js +0 -153
  23. package/dist/lib/schema/impl/enum.js +0 -97
  24. package/dist/lib/schema/impl/field.js +0 -32
  25. package/dist/lib/schema/impl/schema.js +0 -83
  26. package/dist/lib/schema/impl/type.js +0 -462
  27. package/dist/lib/schema/schema.js +0 -90
  28. package/dist/lib/schema-utils/deduce-column-type.js +0 -92
  29. package/dist/lib/utils/assert.js +0 -12
  30. package/dist/lib/utils/async-queue.js +0 -92
  31. package/dist/lib/utils/row-utils.js +0 -33
  32. package/dist/types.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/schema",
3
- "version": "3.4.10",
3
+ "version": "3.4.12",
4
4
  "description": "Table format APIs for JSON, CSV, etc...",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -34,5 +34,5 @@
34
34
  "dependencies": {
35
35
  "@types/geojson": "^7946.0.7"
36
36
  },
37
- "gitHead": "4568459c96eaf0480a50ab77cace355307f61f04"
37
+ "gitHead": "85254762ae3082f608a863291deef09f2b40c6cf"
38
38
  }
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /*
4
- export type Batch = {
5
- bytesUsed?: number;
6
- count?: number;
7
- cursor?: number;
8
- [key: string]: any;
9
- }
10
- */
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertMeshToColumnarTable = exports.convertMesh = void 0;
4
- const mesh_to_arrow_table_1 = require("./mesh-to-arrow-table");
5
- /**
6
- * Convert a mesh to a specific shape
7
- */
8
- function convertMesh(mesh, shape, options) {
9
- switch (shape || 'mesh') {
10
- case 'mesh':
11
- return mesh;
12
- case 'columnar-table':
13
- return convertMeshToColumnarTable(mesh);
14
- case 'arrow-table':
15
- return {
16
- shape: 'arrow-table',
17
- data: (0, mesh_to_arrow_table_1.convertMeshToArrowTable)(mesh)
18
- };
19
- default:
20
- throw new Error(`Unsupported shape ${options?.shape}`);
21
- }
22
- }
23
- exports.convertMesh = convertMesh;
24
- /**
25
- * Convert a loaders.gl Mesh to a Columnar Table
26
- * @param mesh
27
- * @returns
28
- */
29
- function convertMeshToColumnarTable(mesh) {
30
- const columns = {};
31
- for (const [columnName, attribute] of Object.entries(mesh.attributes)) {
32
- columns[columnName] = attribute.value;
33
- }
34
- return {
35
- shape: 'columnar-table',
36
- schema: mesh.schema,
37
- data: columns
38
- };
39
- }
40
- exports.convertMeshToColumnarTable = convertMeshToColumnarTable;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = void 0;
4
- const schema_1 = require("../../lib/schema/schema");
5
- const arrow_like_type_utils_1 = require("../../lib/arrow/arrow-like-type-utils");
6
- /**
7
- * Create a schema for mesh attributes data
8
- * @param attributes
9
- * @param metadata
10
- * @returns
11
- */
12
- function deduceMeshSchema(attributes, metadata) {
13
- const fields = deduceMeshFields(attributes);
14
- return new schema_1.Schema(fields, metadata);
15
- }
16
- exports.deduceMeshSchema = deduceMeshSchema;
17
- /**
18
- * Create arrow-like schema field for mesh attribute
19
- * @param attributeName
20
- * @param attribute
21
- * @param optionalMetadata
22
- * @returns
23
- */
24
- function deduceMeshField(attributeName, attribute, optionalMetadata) {
25
- const type = (0, arrow_like_type_utils_1.getArrowTypeFromTypedArray)(attribute.value);
26
- const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
27
- const field = new schema_1.Field(attributeName, new schema_1.FixedSizeList(attribute.size, new schema_1.Field('value', type)), false, metadata);
28
- return field;
29
- }
30
- exports.deduceMeshField = deduceMeshField;
31
- /**
32
- * Create fields array for mesh attributes
33
- * @param attributes
34
- * @returns
35
- */
36
- function deduceMeshFields(attributes) {
37
- const fields = [];
38
- for (const attributeName in attributes) {
39
- const attribute = attributes[attributeName];
40
- fields.push(deduceMeshField(attributeName, attribute));
41
- }
42
- return fields;
43
- }
44
- /**
45
- * Make metadata by mesh attribute properties
46
- * @param attribute
47
- * @returns
48
- */
49
- function makeMeshAttributeMetadata(attribute) {
50
- const result = new Map();
51
- if ('byteOffset' in attribute) {
52
- result.set('byteOffset', attribute.byteOffset.toString(10));
53
- }
54
- if ('byteStride' in attribute) {
55
- result.set('byteStride', attribute.byteStride.toString(10));
56
- }
57
- if ('normalized' in attribute) {
58
- result.set('normalized', attribute.normalized.toString());
59
- }
60
- return result;
61
- }
62
- exports.makeMeshAttributeMetadata = makeMeshAttributeMetadata;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.convertMeshToArrowTable = void 0;
4
- const Arrow_dom_1 = require("apache-arrow/Arrow.dom");
5
- const arrow_type_utils_1 = require("../../lib/arrow/arrow-type-utils");
6
- const deduce_mesh_schema_1 = require("./deduce-mesh-schema");
7
- /**
8
- * * Convert a loaders.gl Mesh to an Apache Arrow Table
9
- * @param mesh
10
- * @param metadata
11
- * @param batchSize
12
- * @returns
13
- */
14
- function convertMeshToArrowTable(mesh, batchSize) {
15
- const vectors = [];
16
- const fields = [];
17
- for (const attributeKey in mesh.attributes) {
18
- const attribute = mesh.attributes[attributeKey];
19
- const { value, size = 1 } = attribute;
20
- const type = (0, arrow_type_utils_1.getArrowType)(value);
21
- const vector = (0, arrow_type_utils_1.getArrowVector)(value);
22
- const listType = new Arrow_dom_1.FixedSizeList(size, new Arrow_dom_1.Field('value', type));
23
- const field = new Arrow_dom_1.Field(attributeKey, listType, false, (0, deduce_mesh_schema_1.makeMeshAttributeMetadata)(attribute));
24
- const data = new Arrow_dom_1.Data(listType, 0, value.length / size, 0, undefined, [vector]);
25
- const listVector = new Arrow_dom_1.FixedSizeListVector(data);
26
- vectors.push(listVector);
27
- fields.push(field);
28
- }
29
- const schema = new Arrow_dom_1.Schema(fields, mesh?.schema?.metadata || new Map());
30
- const recordBatch = new Arrow_dom_1.RecordBatch(schema, vectors[0].length, vectors);
31
- const table = new Arrow_dom_1.Table(schema, recordBatch);
32
- return table;
33
- }
34
- exports.convertMeshToArrowTable = convertMeshToArrowTable;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMeshBoundingBox = exports.getMeshSize = void 0;
4
- /**
5
- * Get number of vertices in mesh
6
- * @param attributes
7
- */
8
- function getMeshSize(attributes) {
9
- let size = 0;
10
- for (const attributeName in attributes) {
11
- const attribute = attributes[attributeName];
12
- if (ArrayBuffer.isView(attribute)) {
13
- // @ts-ignore DataView doesn't have BYTES_PER_ELEMENT
14
- size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
15
- }
16
- }
17
- return size;
18
- }
19
- exports.getMeshSize = getMeshSize;
20
- /**
21
- * Get the (axis aligned) bounding box of a mesh
22
- * @param attributes
23
- * @returns array of two vectors representing the axis aligned bounding box
24
- */
25
- // eslint-disable-next-line complexity
26
- function getMeshBoundingBox(attributes) {
27
- let minX = Infinity;
28
- let minY = Infinity;
29
- let minZ = Infinity;
30
- let maxX = -Infinity;
31
- let maxY = -Infinity;
32
- let maxZ = -Infinity;
33
- const positions = attributes.POSITION ? attributes.POSITION.value : [];
34
- const len = positions && positions.length;
35
- for (let i = 0; i < len; i += 3) {
36
- const x = positions[i];
37
- const y = positions[i + 1];
38
- const z = positions[i + 2];
39
- minX = x < minX ? x : minX;
40
- minY = y < minY ? y : minY;
41
- minZ = z < minZ ? z : minZ;
42
- maxX = x > maxX ? x : maxX;
43
- maxY = y > maxY ? y : maxY;
44
- maxZ = z > maxZ ? z : maxZ;
45
- }
46
- return [
47
- [minX, minY, minZ],
48
- [maxX, maxY, maxZ]
49
- ];
50
- }
51
- exports.getMeshBoundingBox = getMeshBoundingBox;
@@ -1,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deduceTableSchema = void 0;
4
- // const TYPED_ARRAY_TO_TYPE = {
5
- // Int8Array: new Int8(),
6
- // Int16Array: new Int16(),
7
- // Int32Array: new Int32(),
8
- // Uint8Array: new Uint8(),
9
- // Uint8ClampedArray: new Uint8(),
10
- // Uint16Array: new Uint16(),
11
- // Uint32Array: new Uint32(),
12
- // Float32Array: new Float32(),
13
- // Float64Array: new Float64()
14
- // };
15
- // if (typeof BigInt64Array !== 'undefined') {
16
- // TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();
17
- // TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
18
- // }
19
- /**
20
- * SCHEMA SUPPORT - AUTODEDUCTION
21
- * @param {*} table
22
- * @param {*} schema
23
- * @returns
24
- */
25
- function deduceTableSchema(table, schema) {
26
- const deducedSchema = Array.isArray(table)
27
- ? deduceSchemaForRowTable(table)
28
- : deduceSchemaForColumnarTable(table);
29
- // Deduced schema will fill in missing info from partial options.schema, if provided
30
- return Object.assign(deducedSchema, schema);
31
- }
32
- exports.deduceTableSchema = deduceTableSchema;
33
- function deduceSchemaForColumnarTable(columnarTable) {
34
- const schema = {};
35
- for (const field in columnarTable) {
36
- const column = columnarTable[field];
37
- // Check if column is typed, if so we are done
38
- if (ArrayBuffer.isView(column)) {
39
- schema[field] = column.constructor;
40
- // else we need data
41
- }
42
- else if (column.length) {
43
- const value = column[0];
44
- schema[field] = deduceTypeFromValue(value);
45
- // TODO - support nested schemas?
46
- }
47
- // else we mark as present but unknow
48
- schema[field] = schema[field] || null;
49
- }
50
- return schema;
51
- }
52
- function deduceSchemaForRowTable(rowTable) {
53
- const schema = {};
54
- if (rowTable.length) {
55
- const row = rowTable[0];
56
- // TODO - Could look at additional rows if nulls in first row
57
- for (const field in row) {
58
- const value = row[field];
59
- schema[field] = deduceTypeFromValue(value);
60
- }
61
- }
62
- return schema;
63
- }
64
- function deduceTypeFromValue(value) {
65
- if (value instanceof Date) {
66
- return Date;
67
- }
68
- else if (value instanceof Number) {
69
- return Float32Array;
70
- }
71
- else if (typeof value === 'string') {
72
- return String;
73
- }
74
- return null;
75
- }
76
- /*
77
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
78
- function deduceSchema(rows) {
79
- const row = rows[0];
80
-
81
- const schema = {};
82
- let i = 0;
83
- for (const columnName in row) {
84
- const value = row[columnName];
85
- switch (typeof value) {
86
- case 'number':
87
- case 'boolean':
88
- // TODO - booleans could be handled differently...
89
- schema[columnName] = {name: String(columnName), index: i, type: Float32Array};
90
- break;
91
-
92
- case 'object':
93
- schema[columnName] = {name: String(columnName), index: i, type: Array};
94
- break;
95
-
96
- case 'string':
97
- default:
98
- schema[columnName] = {name: String(columnName), index: i, type: Array};
99
- // We currently only handle numeric rows
100
- // TODO we could offer a function to map strings to numbers?
101
- }
102
- i++;
103
- }
104
- return schema;
105
- }
106
- */
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.js DELETED
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getArrowTypeFromTypedArray = exports.getTypeInfo = exports.deduceTypeFromValue = exports.deduceTypeFromColumn = exports.Struct = exports.FixedSizeList = exports.IntervalYearMonth = exports.IntervalDayTime = exports.Interval = exports.TimestampNanosecond = exports.TimestampMicrosecond = exports.TimestampMillisecond = exports.TimestampSecond = exports.Timestamp = exports.TimeSecond = exports.TimeMillisecond = exports.Time = exports.DateMillisecond = exports.DateDay = exports.Date = exports.Utf8 = exports.Float64 = exports.Float32 = exports.Float16 = exports.Float = exports.Uint64 = exports.Uint32 = exports.Uint16 = exports.Uint8 = exports.Int64 = exports.Int32 = exports.Int16 = exports.Int8 = exports.Int = exports.Bool = exports.Binary = exports.Null = exports.DataType = exports.Field = exports.Schema = exports.makeMeshAttributeMetadata = exports.deduceMeshField = exports.deduceMeshSchema = exports.getMeshBoundingBox = exports.getMeshSize = exports.convertToArrayRow = exports.convertToObjectRow = exports.ColumnarTableBatchAggregator = exports.RowTableBatchAggregator = exports.TableBatchBuilder = void 0;
7
- exports.AsyncQueue = void 0;
8
- // TABLE CATEGORY UTILS
9
- var table_batch_builder_1 = require("./lib/batches/table-batch-builder");
10
- Object.defineProperty(exports, "TableBatchBuilder", { enumerable: true, get: function () { return __importDefault(table_batch_builder_1).default; } });
11
- var row_table_batch_aggregator_1 = require("./lib/batches/row-table-batch-aggregator");
12
- Object.defineProperty(exports, "RowTableBatchAggregator", { enumerable: true, get: function () { return __importDefault(row_table_batch_aggregator_1).default; } });
13
- var columnar_table_batch_aggregator_1 = require("./lib/batches/columnar-table-batch-aggregator");
14
- Object.defineProperty(exports, "ColumnarTableBatchAggregator", { enumerable: true, get: function () { return __importDefault(columnar_table_batch_aggregator_1).default; } });
15
- var row_utils_1 = require("./lib/utils/row-utils");
16
- Object.defineProperty(exports, "convertToObjectRow", { enumerable: true, get: function () { return row_utils_1.convertToObjectRow; } });
17
- Object.defineProperty(exports, "convertToArrayRow", { enumerable: true, get: function () { return row_utils_1.convertToArrayRow; } });
18
- var mesh_utils_1 = require("./category/mesh/mesh-utils");
19
- Object.defineProperty(exports, "getMeshSize", { enumerable: true, get: function () { return mesh_utils_1.getMeshSize; } });
20
- Object.defineProperty(exports, "getMeshBoundingBox", { enumerable: true, get: function () { return mesh_utils_1.getMeshBoundingBox; } });
21
- // Commented out due to https://github.com/visgl/deck.gl/issues/6906 and https://github.com/visgl/loaders.gl/issues/2177
22
- // export {convertMesh} from './category/mesh/convert-mesh';
23
- var deduce_mesh_schema_1 = require("./category/mesh/deduce-mesh-schema");
24
- Object.defineProperty(exports, "deduceMeshSchema", { enumerable: true, get: function () { return deduce_mesh_schema_1.deduceMeshSchema; } });
25
- Object.defineProperty(exports, "deduceMeshField", { enumerable: true, get: function () { return deduce_mesh_schema_1.deduceMeshField; } });
26
- Object.defineProperty(exports, "makeMeshAttributeMetadata", { enumerable: true, get: function () { return deduce_mesh_schema_1.makeMeshAttributeMetadata; } });
27
- // SCHEMA
28
- var schema_1 = require("./lib/schema/schema");
29
- Object.defineProperty(exports, "Schema", { enumerable: true, get: function () { return schema_1.Schema; } });
30
- Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return schema_1.Field; } });
31
- Object.defineProperty(exports, "DataType", { enumerable: true, get: function () { return schema_1.DataType; } });
32
- Object.defineProperty(exports, "Null", { enumerable: true, get: function () { return schema_1.Null; } });
33
- Object.defineProperty(exports, "Binary", { enumerable: true, get: function () { return schema_1.Binary; } });
34
- Object.defineProperty(exports, "Bool", { enumerable: true, get: function () { return schema_1.Bool; } });
35
- Object.defineProperty(exports, "Int", { enumerable: true, get: function () { return schema_1.Int; } });
36
- Object.defineProperty(exports, "Int8", { enumerable: true, get: function () { return schema_1.Int8; } });
37
- Object.defineProperty(exports, "Int16", { enumerable: true, get: function () { return schema_1.Int16; } });
38
- Object.defineProperty(exports, "Int32", { enumerable: true, get: function () { return schema_1.Int32; } });
39
- Object.defineProperty(exports, "Int64", { enumerable: true, get: function () { return schema_1.Int64; } });
40
- Object.defineProperty(exports, "Uint8", { enumerable: true, get: function () { return schema_1.Uint8; } });
41
- Object.defineProperty(exports, "Uint16", { enumerable: true, get: function () { return schema_1.Uint16; } });
42
- Object.defineProperty(exports, "Uint32", { enumerable: true, get: function () { return schema_1.Uint32; } });
43
- Object.defineProperty(exports, "Uint64", { enumerable: true, get: function () { return schema_1.Uint64; } });
44
- Object.defineProperty(exports, "Float", { enumerable: true, get: function () { return schema_1.Float; } });
45
- Object.defineProperty(exports, "Float16", { enumerable: true, get: function () { return schema_1.Float16; } });
46
- Object.defineProperty(exports, "Float32", { enumerable: true, get: function () { return schema_1.Float32; } });
47
- Object.defineProperty(exports, "Float64", { enumerable: true, get: function () { return schema_1.Float64; } });
48
- Object.defineProperty(exports, "Utf8", { enumerable: true, get: function () { return schema_1.Utf8; } });
49
- Object.defineProperty(exports, "Date", { enumerable: true, get: function () { return schema_1.Date; } });
50
- Object.defineProperty(exports, "DateDay", { enumerable: true, get: function () { return schema_1.DateDay; } });
51
- Object.defineProperty(exports, "DateMillisecond", { enumerable: true, get: function () { return schema_1.DateMillisecond; } });
52
- Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return schema_1.Time; } });
53
- Object.defineProperty(exports, "TimeMillisecond", { enumerable: true, get: function () { return schema_1.TimeMillisecond; } });
54
- Object.defineProperty(exports, "TimeSecond", { enumerable: true, get: function () { return schema_1.TimeSecond; } });
55
- Object.defineProperty(exports, "Timestamp", { enumerable: true, get: function () { return schema_1.Timestamp; } });
56
- Object.defineProperty(exports, "TimestampSecond", { enumerable: true, get: function () { return schema_1.TimestampSecond; } });
57
- Object.defineProperty(exports, "TimestampMillisecond", { enumerable: true, get: function () { return schema_1.TimestampMillisecond; } });
58
- Object.defineProperty(exports, "TimestampMicrosecond", { enumerable: true, get: function () { return schema_1.TimestampMicrosecond; } });
59
- Object.defineProperty(exports, "TimestampNanosecond", { enumerable: true, get: function () { return schema_1.TimestampNanosecond; } });
60
- Object.defineProperty(exports, "Interval", { enumerable: true, get: function () { return schema_1.Interval; } });
61
- Object.defineProperty(exports, "IntervalDayTime", { enumerable: true, get: function () { return schema_1.IntervalDayTime; } });
62
- Object.defineProperty(exports, "IntervalYearMonth", { enumerable: true, get: function () { return schema_1.IntervalYearMonth; } });
63
- Object.defineProperty(exports, "FixedSizeList", { enumerable: true, get: function () { return schema_1.FixedSizeList; } });
64
- Object.defineProperty(exports, "Struct", { enumerable: true, get: function () { return schema_1.Struct; } });
65
- // EXPERIMENTAL APIs
66
- // SCHEMA UTILS
67
- var deduce_column_type_1 = require("./lib/schema-utils/deduce-column-type");
68
- Object.defineProperty(exports, "deduceTypeFromColumn", { enumerable: true, get: function () { return deduce_column_type_1.deduceTypeFromColumn; } });
69
- Object.defineProperty(exports, "deduceTypeFromValue", { enumerable: true, get: function () { return deduce_column_type_1.deduceTypeFromValue; } });
70
- var get_type_info_1 = require("./lib/arrow/get-type-info");
71
- Object.defineProperty(exports, "getTypeInfo", { enumerable: true, get: function () { return get_type_info_1.getTypeInfo; } });
72
- var arrow_like_type_utils_1 = require("./lib/arrow/arrow-like-type-utils");
73
- Object.defineProperty(exports, "getArrowTypeFromTypedArray", { enumerable: true, get: function () { return arrow_like_type_utils_1.getArrowTypeFromTypedArray; } });
74
- var async_queue_1 = require("./lib/utils/async-queue");
75
- Object.defineProperty(exports, "AsyncQueue", { enumerable: true, get: function () { return __importDefault(async_queue_1).default; } });
@@ -1,27 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getArrowTypeFromTypedArray = void 0;
4
- const schema_1 = require("../schema/schema");
5
- function getArrowTypeFromTypedArray(array) {
6
- switch (array.constructor) {
7
- case Int8Array:
8
- return new schema_1.Int8();
9
- case Uint8Array:
10
- return new schema_1.Uint8();
11
- case Int16Array:
12
- return new schema_1.Int16();
13
- case Uint16Array:
14
- return new schema_1.Uint16();
15
- case Int32Array:
16
- return new schema_1.Int32();
17
- case Uint32Array:
18
- return new schema_1.Uint32();
19
- case Float32Array:
20
- return new schema_1.Float32();
21
- case Float64Array:
22
- return new schema_1.Float64();
23
- default:
24
- throw new Error('array type not supported');
25
- }
26
- }
27
- exports.getArrowTypeFromTypedArray = getArrowTypeFromTypedArray;
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getArrowVector = exports.getArrowType = void 0;
4
- const Arrow_dom_1 = require("apache-arrow/Arrow.dom");
5
- function getArrowType(array) {
6
- switch (array.constructor) {
7
- case Int8Array:
8
- return new Arrow_dom_1.Int8();
9
- case Uint8Array:
10
- return new Arrow_dom_1.Uint8();
11
- case Int16Array:
12
- return new Arrow_dom_1.Int16();
13
- case Uint16Array:
14
- return new Arrow_dom_1.Uint16();
15
- case Int32Array:
16
- return new Arrow_dom_1.Int32();
17
- case Uint32Array:
18
- return new Arrow_dom_1.Uint32();
19
- case Float32Array:
20
- return new Arrow_dom_1.Float32();
21
- case Float64Array:
22
- return new Arrow_dom_1.Float64();
23
- default:
24
- throw new Error('array type not supported');
25
- }
26
- }
27
- exports.getArrowType = getArrowType;
28
- function getArrowVector(array) {
29
- switch (array.constructor) {
30
- case Int8Array:
31
- return Arrow_dom_1.Int8Vector.from(array);
32
- case Uint8Array:
33
- return Arrow_dom_1.Uint8Vector.from(array);
34
- case Int16Array:
35
- return Arrow_dom_1.Int16Vector.from(array);
36
- case Uint16Array:
37
- return Arrow_dom_1.Uint16Vector.from(array);
38
- case Int32Array:
39
- return Arrow_dom_1.Int32Vector.from(array);
40
- case Uint32Array:
41
- return Arrow_dom_1.Uint32Vector.from(array);
42
- case Float32Array:
43
- return Arrow_dom_1.Float32Vector.from(array);
44
- case Float64Array:
45
- return Arrow_dom_1.Float64Vector.from(array);
46
- default:
47
- throw new Error('array type not supported');
48
- }
49
- }
50
- exports.getArrowVector = getArrowVector;
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTypeInfo = void 0;
4
- const schema_1 = require("../schema/schema");
5
- /**
6
- * Gets type information from an Arrow type object or "mock" Arrow type object
7
- * @param arrowTypeLike Arrow Type or type object of similar shape
8
- */
9
- function getTypeInfo(arrowTypeLike) {
10
- return {
11
- typeId: arrowTypeLike.typeId,
12
- ArrayType: arrowTypeLike.ArrayType,
13
- typeName: arrowTypeLike.toString(),
14
- typeEnumName: getTypeKey(arrowTypeLike.typeId),
15
- precision: arrowTypeLike.precision
16
- };
17
- }
18
- exports.getTypeInfo = getTypeInfo;
19
- let ReverseType = null;
20
- function getTypeKey(typeKey) {
21
- if (!ReverseType) {
22
- ReverseType = {};
23
- for (const key in schema_1.Type) {
24
- ReverseType[schema_1.Type[key]] = key;
25
- }
26
- }
27
- return ReverseType[typeKey];
28
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const DEFAULT_ROW_COUNT = 100;
4
- class RowTableBatchAggregator {
5
- constructor(schema, options) {
6
- this.length = 0;
7
- this.rows = null;
8
- this.cursor = 0;
9
- this._headers = [];
10
- this.options = options;
11
- this.schema = schema;
12
- // schema is an array if there're no headers
13
- // object if there are headers
14
- if (!Array.isArray(schema)) {
15
- this._headers = [];
16
- for (const key in schema) {
17
- this._headers[schema[key].index] = schema[key].name;
18
- }
19
- }
20
- }
21
- rowCount() {
22
- return this.length;
23
- }
24
- addArrayRow(row, cursor) {
25
- if (Number.isFinite(cursor)) {
26
- this.cursor = cursor;
27
- }
28
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
29
- this.rows[this.length] = row;
30
- this.length++;
31
- }
32
- addObjectRow(row, cursor) {
33
- if (Number.isFinite(cursor)) {
34
- this.cursor = cursor;
35
- }
36
- this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
37
- this.rows[this.length] = row;
38
- this.length++;
39
- }
40
- getBatch() {
41
- let rows = this.rows;
42
- if (!rows) {
43
- return null;
44
- }
45
- rows = rows.slice(0, this.length);
46
- this.rows = null;
47
- const batch = {
48
- shape: this.options.shape,
49
- batchType: 'data',
50
- data: rows,
51
- length: this.length,
52
- schema: this.schema,
53
- cursor: this.cursor
54
- };
55
- return batch;
56
- }
57
- }
58
- exports.default = RowTableBatchAggregator;