@loaders.gl/schema 4.0.0-beta.2 → 4.0.0-beta.4
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.
- package/dist/dist.dev.js +1672 -0
- package/dist/index.cjs +1692 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/{esm/lib → lib}/mesh/convert-mesh.js +1 -1
- package/dist/lib/mesh/convert-mesh.js.map +1 -0
- package/dist/{esm/lib → lib}/mesh/deduce-mesh-schema.js +1 -1
- package/dist/lib/mesh/deduce-mesh-schema.js.map +1 -0
- package/dist/lib/mesh/mesh-to-arrow-table.js.map +1 -0
- package/dist/lib/mesh/mesh-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-field.js +5 -6
- package/dist/lib/table/arrow-api/arrow-like-field.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-schema.js +3 -4
- package/dist/lib/table/arrow-api/arrow-like-schema.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-table.js +7 -8
- package/dist/lib/table/arrow-api/arrow-like-table.js.map +1 -0
- package/dist/lib/table/arrow-api/arrow-like-type.d.ts +1 -1
- package/dist/lib/table/arrow-api/arrow-like-type.d.ts.map +1 -1
- package/dist/{esm/lib → lib}/table/arrow-api/arrow-like-type.js +22 -23
- package/dist/lib/table/arrow-api/arrow-like-type.js.map +1 -0
- package/dist/lib/table/arrow-api/enum.js.map +1 -0
- package/dist/{esm/lib → lib}/table/arrow-api/get-type-info.js +1 -1
- package/dist/lib/table/arrow-api/get-type-info.js.map +1 -0
- package/dist/lib/table/arrow-api/index.js +5 -0
- package/dist/lib/table/arrow-api/index.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/base-table-batch-aggregator.js +6 -7
- package/dist/lib/table/batches/base-table-batch-aggregator.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/columnar-table-batch-aggregator.js +4 -5
- package/dist/lib/table/batches/columnar-table-batch-aggregator.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/row-table-batch-aggregator.js +8 -9
- package/dist/lib/table/batches/row-table-batch-aggregator.js.map +1 -0
- package/dist/lib/table/batches/table-batch-aggregator.js.map +1 -0
- package/dist/{esm/lib → lib}/table/batches/table-batch-builder.js +14 -15
- package/dist/lib/table/batches/table-batch-builder.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/convert-table.js +3 -3
- package/dist/lib/table/simple-table/convert-table.js.map +1 -0
- package/dist/lib/table/simple-table/data-type.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/make-table.js +1 -1
- package/dist/lib/table/simple-table/make-table.js.map +1 -0
- package/dist/lib/table/simple-table/row-utils.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/table-accessors.js +2 -2
- package/dist/lib/table/simple-table/table-accessors.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/table-column.js +1 -1
- package/dist/lib/table/simple-table/table-column.js.map +1 -0
- package/dist/{esm/lib → lib}/table/simple-table/table-schema.js +1 -1
- package/dist/lib/table/simple-table/table-schema.js.map +1 -0
- package/dist/lib/utils/assert.js.map +1 -0
- package/dist/{esm/lib → lib}/utils/async-queue.js +3 -4
- package/dist/lib/utils/async-queue.js.map +1 -0
- package/dist/types/batch.d.ts +3 -2
- package/dist/types/batch.d.ts.map +1 -1
- package/dist/types/batch.js.map +1 -0
- package/dist/types/binary-geometries.js.map +1 -0
- package/dist/types/category-gis.js.map +1 -0
- package/dist/types/category-image.js.map +1 -0
- package/dist/types/category-mesh.js.map +1 -0
- package/dist/types/category-table.js.map +1 -0
- package/dist/types/category-texture.js.map +1 -0
- package/dist/types/flat-geometries.js.map +1 -0
- package/dist/types/schema.js.map +1 -0
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/types.js.map +1 -0
- package/package.json +14 -6
- package/src/index.ts +0 -1
- package/src/lib/table/arrow-api/arrow-like-type.ts +0 -2
- package/src/types/batch.ts +4 -2
- package/src/types/types.ts +0 -2
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/dist.min.js +0 -13204
- package/dist/es5/bundle.js +0 -6
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -413
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/mesh/convert-mesh.js +0 -34
- package/dist/es5/lib/mesh/convert-mesh.js.map +0 -1
- package/dist/es5/lib/mesh/deduce-mesh-schema.js +0 -56
- package/dist/es5/lib/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/es5/lib/mesh/mesh-to-arrow-table.js +0 -2
- package/dist/es5/lib/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/es5/lib/mesh/mesh-utils.js +0 -40
- package/dist/es5/lib/mesh/mesh-utils.js.map +0 -1
- package/dist/es5/lib/table/arrow/arrow-type-utils.js +0 -30
- package/dist/es5/lib/table/arrow/arrow-type-utils.js.map +0 -1
- package/dist/es5/lib/table/arrow/convert-schema-arrow.js +0 -179
- package/dist/es5/lib/table/arrow/convert-schema-arrow.js.map +0 -1
- package/dist/es5/lib/table/arrow/convert-table-to-arrow.js +0 -2
- package/dist/es5/lib/table/arrow/convert-table-to-arrow.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-field.js +0 -49
- package/dist/es5/lib/table/arrow-api/arrow-like-field.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-schema.js +0 -118
- package/dist/es5/lib/table/arrow-api/arrow-like-schema.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js +0 -81
- package/dist/es5/lib/table/arrow-api/arrow-like-table.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/arrow-like-type.js +0 -740
- package/dist/es5/lib/table/arrow-api/arrow-like-type.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/enum.js +0 -55
- package/dist/es5/lib/table/arrow-api/enum.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/get-type-info.js +0 -27
- package/dist/es5/lib/table/arrow-api/get-type-info.js.map +0 -1
- package/dist/es5/lib/table/arrow-api/index.js +0 -44
- package/dist/es5/lib/table/arrow-api/index.js.map +0 -1
- package/dist/es5/lib/table/batches/base-table-batch-aggregator.js +0 -78
- package/dist/es5/lib/table/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/columnar-table-batch-aggregator.js +0 -106
- package/dist/es5/lib/table/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js +0 -96
- package/dist/es5/lib/table/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/table-batch-aggregator.js +0 -2
- package/dist/es5/lib/table/batches/table-batch-aggregator.js.map +0 -1
- package/dist/es5/lib/table/batches/table-batch-builder.js +0 -173
- package/dist/es5/lib/table/batches/table-batch-builder.js.map +0 -1
- package/dist/es5/lib/table/simple-table/convert-table.js +0 -106
- package/dist/es5/lib/table/simple-table/convert-table.js.map +0 -1
- package/dist/es5/lib/table/simple-table/data-type.js +0 -94
- package/dist/es5/lib/table/simple-table/data-type.js.map +0 -1
- package/dist/es5/lib/table/simple-table/make-table.js +0 -60
- package/dist/es5/lib/table/simple-table/make-table.js.map +0 -1
- package/dist/es5/lib/table/simple-table/row-utils.js +0 -34
- package/dist/es5/lib/table/simple-table/row-utils.js.map +0 -1
- package/dist/es5/lib/table/simple-table/table-accessors.js +0 -370
- package/dist/es5/lib/table/simple-table/table-accessors.js.map +0 -1
- package/dist/es5/lib/table/simple-table/table-column.js +0 -12
- package/dist/es5/lib/table/simple-table/table-column.js.map +0 -1
- package/dist/es5/lib/table/simple-table/table-schema.js +0 -85
- package/dist/es5/lib/table/simple-table/table-schema.js.map +0 -1
- package/dist/es5/lib/utils/assert.js +0 -12
- package/dist/es5/lib/utils/assert.js.map +0 -1
- package/dist/es5/lib/utils/async-queue.js +0 -169
- package/dist/es5/lib/utils/async-queue.js.map +0 -1
- package/dist/es5/types/batch.js +0 -2
- package/dist/es5/types/batch.js.map +0 -1
- package/dist/es5/types/binary-geometries.js +0 -2
- package/dist/es5/types/binary-geometries.js.map +0 -1
- package/dist/es5/types/category-gis.js +0 -2
- package/dist/es5/types/category-gis.js.map +0 -1
- package/dist/es5/types/category-image.js +0 -2
- package/dist/es5/types/category-image.js.map +0 -1
- package/dist/es5/types/category-mesh.js +0 -2
- package/dist/es5/types/category-mesh.js.map +0 -1
- package/dist/es5/types/category-table.js +0 -2
- package/dist/es5/types/category-table.js.map +0 -1
- package/dist/es5/types/category-texture.js +0 -2
- package/dist/es5/types/category-texture.js.map +0 -1
- package/dist/es5/types/flat-geometries.js +0 -2
- package/dist/es5/types/flat-geometries.js.map +0 -1
- package/dist/es5/types/schema.js +0 -2
- package/dist/es5/types/schema.js.map +0 -1
- package/dist/es5/types/types.js +0 -2
- package/dist/es5/types/types.js.map +0 -1
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -17
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/mesh/convert-mesh.js.map +0 -1
- package/dist/esm/lib/mesh/deduce-mesh-schema.js.map +0 -1
- package/dist/esm/lib/mesh/mesh-to-arrow-table.js.map +0 -1
- package/dist/esm/lib/mesh/mesh-utils.js.map +0 -1
- package/dist/esm/lib/table/arrow/arrow-type-utils.js +0 -24
- package/dist/esm/lib/table/arrow/arrow-type-utils.js.map +0 -1
- package/dist/esm/lib/table/arrow/convert-schema-arrow.js +0 -158
- package/dist/esm/lib/table/arrow/convert-schema-arrow.js.map +0 -1
- package/dist/esm/lib/table/arrow/convert-table-to-arrow.js +0 -2
- package/dist/esm/lib/table/arrow/convert-table-to-arrow.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-field.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-schema.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-table.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/arrow-like-type.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/enum.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/get-type-info.js.map +0 -1
- package/dist/esm/lib/table/arrow-api/index.js +0 -5
- package/dist/esm/lib/table/arrow-api/index.js.map +0 -1
- package/dist/esm/lib/table/batches/base-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/columnar-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/row-table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/table-batch-aggregator.js.map +0 -1
- package/dist/esm/lib/table/batches/table-batch-builder.js.map +0 -1
- package/dist/esm/lib/table/simple-table/convert-table.js.map +0 -1
- package/dist/esm/lib/table/simple-table/data-type.js.map +0 -1
- package/dist/esm/lib/table/simple-table/make-table.js.map +0 -1
- package/dist/esm/lib/table/simple-table/row-utils.js.map +0 -1
- package/dist/esm/lib/table/simple-table/table-accessors.js.map +0 -1
- package/dist/esm/lib/table/simple-table/table-column.js.map +0 -1
- package/dist/esm/lib/table/simple-table/table-schema.js.map +0 -1
- package/dist/esm/lib/utils/assert.js.map +0 -1
- package/dist/esm/lib/utils/async-queue.js.map +0 -1
- package/dist/esm/types/batch.js.map +0 -1
- package/dist/esm/types/binary-geometries.js.map +0 -1
- package/dist/esm/types/category-gis.js.map +0 -1
- package/dist/esm/types/category-image.js.map +0 -1
- package/dist/esm/types/category-mesh.js.map +0 -1
- package/dist/esm/types/category-table.js.map +0 -1
- package/dist/esm/types/category-texture.js.map +0 -1
- package/dist/esm/types/flat-geometries.js.map +0 -1
- package/dist/esm/types/schema.js.map +0 -1
- package/dist/esm/types/types.js.map +0 -1
- package/dist/lib/table/arrow/arrow-type-utils.d.ts +0 -4
- package/dist/lib/table/arrow/arrow-type-utils.d.ts.map +0 -1
- package/dist/lib/table/arrow/convert-schema-arrow.d.ts +0 -13
- package/dist/lib/table/arrow/convert-schema-arrow.d.ts.map +0 -1
- package/dist/lib/table/arrow/convert-table-to-arrow.d.ts +0 -42
- package/dist/lib/table/arrow/convert-table-to-arrow.d.ts.map +0 -1
- package/src/bundle.ts +0 -4
- package/src/lib/table/arrow/arrow-type-utils.ts +0 -71
- package/src/lib/table/arrow/convert-schema-arrow.ts +0 -232
- package/src/lib/table/arrow/convert-table-to-arrow.ts +0 -59
- /package/dist/{esm/lib → lib}/mesh/mesh-to-arrow-table.js +0 -0
- /package/dist/{esm/lib → lib}/mesh/mesh-utils.js +0 -0
- /package/dist/{esm/lib → lib}/table/arrow-api/enum.js +0 -0
- /package/dist/{esm/lib → lib}/table/batches/table-batch-aggregator.js +0 -0
- /package/dist/{esm/lib → lib}/table/simple-table/data-type.js +0 -0
- /package/dist/{esm/lib → lib}/table/simple-table/row-utils.js +0 -0
- /package/dist/{esm/lib → lib}/utils/assert.js +0 -0
- /package/dist/{esm/types → types}/batch.js +0 -0
- /package/dist/{esm/types → types}/binary-geometries.js +0 -0
- /package/dist/{esm/types → types}/category-gis.js +0 -0
- /package/dist/{esm/types → types}/category-image.js +0 -0
- /package/dist/{esm/types → types}/category-mesh.js +0 -0
- /package/dist/{esm/types → types}/category-table.js +0 -0
- /package/dist/{esm/types → types}/category-texture.js +0 -0
- /package/dist/{esm/types → types}/flat-geometries.js +0 -0
- /package/dist/{esm/types → types}/schema.js +0 -0
- /package/dist/{esm/types → types}/types.js +0 -0
package/dist/dist.dev.js
ADDED
|
@@ -0,0 +1,1672 @@
|
|
|
1
|
+
(function webpackUniversalModuleDefinition(root, factory) {
|
|
2
|
+
if (typeof exports === 'object' && typeof module === 'object')
|
|
3
|
+
module.exports = factory();
|
|
4
|
+
else if (typeof define === 'function' && define.amd) define([], factory);
|
|
5
|
+
else if (typeof exports === 'object') exports['loader'] = factory();
|
|
6
|
+
else root['loader'] = factory();})(globalThis, function () {
|
|
7
|
+
"use strict";
|
|
8
|
+
var __exports__ = (() => {
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
|
|
27
|
+
// src/index.ts
|
|
28
|
+
var src_exports = {};
|
|
29
|
+
__export(src_exports, {
|
|
30
|
+
ArrowLikeDataType: () => DataType,
|
|
31
|
+
ArrowLikeField: () => ArrowLikeField,
|
|
32
|
+
ArrowLikeSchema: () => ArrowLikeSchema,
|
|
33
|
+
ArrowLikeTable: () => ArrowLikeTable,
|
|
34
|
+
AsyncQueue: () => AsyncQueue,
|
|
35
|
+
Binary: () => Binary,
|
|
36
|
+
Bool: () => Bool,
|
|
37
|
+
ColumnarTableBatchAggregator: () => ColumnarTableBatchAggregator,
|
|
38
|
+
Date: () => Date2,
|
|
39
|
+
DateDay: () => DateDay,
|
|
40
|
+
DateMillisecond: () => DateMillisecond,
|
|
41
|
+
FixedSizeList: () => FixedSizeList,
|
|
42
|
+
Float: () => Float,
|
|
43
|
+
Float16: () => Float16,
|
|
44
|
+
Float32: () => Float32,
|
|
45
|
+
Float64: () => Float64,
|
|
46
|
+
Int: () => Int,
|
|
47
|
+
Int16: () => Int16,
|
|
48
|
+
Int32: () => Int32,
|
|
49
|
+
Int64: () => Int64,
|
|
50
|
+
Int8: () => Int8,
|
|
51
|
+
Interval: () => Interval,
|
|
52
|
+
IntervalDayTime: () => IntervalDayTime,
|
|
53
|
+
IntervalYearMonth: () => IntervalYearMonth,
|
|
54
|
+
Null: () => Null,
|
|
55
|
+
RowTableBatchAggregator: () => RowTableBatchAggregator,
|
|
56
|
+
Struct: () => Struct,
|
|
57
|
+
TableBatchBuilder: () => TableBatchBuilder,
|
|
58
|
+
Time: () => Time,
|
|
59
|
+
TimeMillisecond: () => TimeMillisecond,
|
|
60
|
+
TimeSecond: () => TimeSecond,
|
|
61
|
+
Timestamp: () => Timestamp,
|
|
62
|
+
TimestampMicrosecond: () => TimestampMicrosecond,
|
|
63
|
+
TimestampMillisecond: () => TimestampMillisecond,
|
|
64
|
+
TimestampNanosecond: () => TimestampNanosecond,
|
|
65
|
+
TimestampSecond: () => TimestampSecond,
|
|
66
|
+
Uint16: () => Uint16,
|
|
67
|
+
Uint32: () => Uint32,
|
|
68
|
+
Uint64: () => Uint64,
|
|
69
|
+
Uint8: () => Uint8,
|
|
70
|
+
Utf8: () => Utf8,
|
|
71
|
+
convertTable: () => convertTable,
|
|
72
|
+
convertToArrayRow: () => convertToArrayRow,
|
|
73
|
+
convertToObjectRow: () => convertToObjectRow,
|
|
74
|
+
deduceMeshField: () => deduceMeshField,
|
|
75
|
+
deduceMeshSchema: () => deduceMeshSchema,
|
|
76
|
+
deduceTableSchema: () => deduceTableSchema,
|
|
77
|
+
getDataTypeFromArray: () => getDataTypeFromArray,
|
|
78
|
+
getMeshBoundingBox: () => getMeshBoundingBox,
|
|
79
|
+
getMeshSize: () => getMeshSize,
|
|
80
|
+
getTableCell: () => getTableCell,
|
|
81
|
+
getTableColumnIndex: () => getTableColumnIndex,
|
|
82
|
+
getTableColumnName: () => getTableColumnName,
|
|
83
|
+
getTableLength: () => getTableLength,
|
|
84
|
+
getTableNumCols: () => getTableNumCols,
|
|
85
|
+
getTableRowAsArray: () => getTableRowAsArray,
|
|
86
|
+
getTableRowAsObject: () => getTableRowAsObject,
|
|
87
|
+
getTableRowShape: () => getTableRowShape,
|
|
88
|
+
getTypeInfo: () => getTypeInfo,
|
|
89
|
+
makeArrayRowIterator: () => makeArrayRowIterator,
|
|
90
|
+
makeMeshAttributeMetadata: () => makeMeshAttributeMetadata,
|
|
91
|
+
makeObjectRowIterator: () => makeObjectRowIterator,
|
|
92
|
+
makeRowIterator: () => makeRowIterator,
|
|
93
|
+
makeTableFromData: () => makeTableFromData
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
// src/lib/table/batches/base-table-batch-aggregator.ts
|
|
97
|
+
var DEFAULT_ROW_COUNT = 100;
|
|
98
|
+
var BaseTableBatchAggregator = class {
|
|
99
|
+
length = 0;
|
|
100
|
+
rows = null;
|
|
101
|
+
cursor = 0;
|
|
102
|
+
_headers = [];
|
|
103
|
+
constructor(schema, options) {
|
|
104
|
+
this.options = options;
|
|
105
|
+
this.schema = schema;
|
|
106
|
+
if (!Array.isArray(schema)) {
|
|
107
|
+
this._headers = [];
|
|
108
|
+
for (const key in schema) {
|
|
109
|
+
this._headers[schema[key].index] = schema[key].name;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
rowCount() {
|
|
114
|
+
return this.length;
|
|
115
|
+
}
|
|
116
|
+
addArrayRow(row, cursor) {
|
|
117
|
+
if (Number.isFinite(cursor)) {
|
|
118
|
+
this.cursor = cursor;
|
|
119
|
+
}
|
|
120
|
+
this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
|
|
121
|
+
this.rows[this.length] = row;
|
|
122
|
+
this.length++;
|
|
123
|
+
}
|
|
124
|
+
addObjectRow(row, cursor) {
|
|
125
|
+
if (Number.isFinite(cursor)) {
|
|
126
|
+
this.cursor = cursor;
|
|
127
|
+
}
|
|
128
|
+
this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
|
|
129
|
+
this.rows[this.length] = row;
|
|
130
|
+
this.length++;
|
|
131
|
+
}
|
|
132
|
+
getBatch() {
|
|
133
|
+
let rows = this.rows;
|
|
134
|
+
if (!rows) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
rows = rows.slice(0, this.length);
|
|
138
|
+
this.rows = null;
|
|
139
|
+
const batch = {
|
|
140
|
+
shape: this.options.shape,
|
|
141
|
+
batchType: "data",
|
|
142
|
+
data: rows,
|
|
143
|
+
length: this.length,
|
|
144
|
+
schema: this.schema,
|
|
145
|
+
cursor: this.cursor
|
|
146
|
+
};
|
|
147
|
+
return batch;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// src/lib/table/simple-table/row-utils.ts
|
|
152
|
+
function convertToObjectRow(arrayRow, headers) {
|
|
153
|
+
if (!arrayRow) {
|
|
154
|
+
throw new Error("null row");
|
|
155
|
+
}
|
|
156
|
+
if (!headers) {
|
|
157
|
+
throw new Error("no headers");
|
|
158
|
+
}
|
|
159
|
+
const objectRow = {};
|
|
160
|
+
for (let i = 0; i < headers.length; i++) {
|
|
161
|
+
objectRow[headers[i]] = arrayRow[i];
|
|
162
|
+
}
|
|
163
|
+
return objectRow;
|
|
164
|
+
}
|
|
165
|
+
function convertToArrayRow(objectRow, headers) {
|
|
166
|
+
if (!objectRow) {
|
|
167
|
+
throw new Error("null row");
|
|
168
|
+
}
|
|
169
|
+
if (!headers) {
|
|
170
|
+
throw new Error("no headers");
|
|
171
|
+
}
|
|
172
|
+
const arrayRow = new Array(headers.length);
|
|
173
|
+
for (let i = 0; i < headers.length; i++) {
|
|
174
|
+
arrayRow[i] = objectRow[headers[i]];
|
|
175
|
+
}
|
|
176
|
+
return arrayRow;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// src/lib/table/batches/row-table-batch-aggregator.ts
|
|
180
|
+
var DEFAULT_ROW_COUNT2 = 100;
|
|
181
|
+
var RowTableBatchAggregator = class {
|
|
182
|
+
length = 0;
|
|
183
|
+
objectRows = null;
|
|
184
|
+
arrayRows = null;
|
|
185
|
+
cursor = 0;
|
|
186
|
+
_headers = [];
|
|
187
|
+
constructor(schema, options) {
|
|
188
|
+
this.options = options;
|
|
189
|
+
this.schema = schema;
|
|
190
|
+
if (!Array.isArray(schema)) {
|
|
191
|
+
this._headers = [];
|
|
192
|
+
for (const key in schema) {
|
|
193
|
+
this._headers[schema[key].index] = schema[key].name;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
rowCount() {
|
|
198
|
+
return this.length;
|
|
199
|
+
}
|
|
200
|
+
addArrayRow(row, cursor) {
|
|
201
|
+
if (Number.isFinite(cursor)) {
|
|
202
|
+
this.cursor = cursor;
|
|
203
|
+
}
|
|
204
|
+
switch (this.options.shape) {
|
|
205
|
+
case "object-row-table":
|
|
206
|
+
const rowObject = convertToObjectRow(row, this._headers);
|
|
207
|
+
this.addObjectRow(rowObject, cursor);
|
|
208
|
+
break;
|
|
209
|
+
case "array-row-table":
|
|
210
|
+
this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT2);
|
|
211
|
+
this.arrayRows[this.length] = row;
|
|
212
|
+
this.length++;
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
addObjectRow(row, cursor) {
|
|
217
|
+
if (Number.isFinite(cursor)) {
|
|
218
|
+
this.cursor = cursor;
|
|
219
|
+
}
|
|
220
|
+
switch (this.options.shape) {
|
|
221
|
+
case "array-row-table":
|
|
222
|
+
const rowArray = convertToArrayRow(row, this._headers);
|
|
223
|
+
this.addArrayRow(rowArray, cursor);
|
|
224
|
+
break;
|
|
225
|
+
case "object-row-table":
|
|
226
|
+
this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT2);
|
|
227
|
+
this.objectRows[this.length] = row;
|
|
228
|
+
this.length++;
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getBatch() {
|
|
233
|
+
let rows = this.arrayRows || this.objectRows;
|
|
234
|
+
if (!rows) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
rows = rows.slice(0, this.length);
|
|
238
|
+
this.arrayRows = null;
|
|
239
|
+
this.objectRows = null;
|
|
240
|
+
return {
|
|
241
|
+
shape: this.options.shape,
|
|
242
|
+
batchType: "data",
|
|
243
|
+
data: rows,
|
|
244
|
+
length: this.length,
|
|
245
|
+
schema: this.schema,
|
|
246
|
+
cursor: this.cursor
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
// src/lib/table/batches/columnar-table-batch-aggregator.ts
|
|
252
|
+
var DEFAULT_ROW_COUNT3 = 100;
|
|
253
|
+
var ColumnarTableBatchAggregator = class {
|
|
254
|
+
length = 0;
|
|
255
|
+
allocated = 0;
|
|
256
|
+
columns = {};
|
|
257
|
+
constructor(schema, options) {
|
|
258
|
+
this.schema = schema;
|
|
259
|
+
this._reallocateColumns();
|
|
260
|
+
}
|
|
261
|
+
rowCount() {
|
|
262
|
+
return this.length;
|
|
263
|
+
}
|
|
264
|
+
addArrayRow(row) {
|
|
265
|
+
this._reallocateColumns();
|
|
266
|
+
let i = 0;
|
|
267
|
+
for (const fieldName in this.columns) {
|
|
268
|
+
this.columns[fieldName][this.length] = row[i++];
|
|
269
|
+
}
|
|
270
|
+
this.length++;
|
|
271
|
+
}
|
|
272
|
+
addObjectRow(row) {
|
|
273
|
+
this._reallocateColumns();
|
|
274
|
+
for (const fieldName in row) {
|
|
275
|
+
this.columns[fieldName][this.length] = row[fieldName];
|
|
276
|
+
}
|
|
277
|
+
this.length++;
|
|
278
|
+
}
|
|
279
|
+
getBatch() {
|
|
280
|
+
this._pruneColumns();
|
|
281
|
+
const columns = Array.isArray(this.schema) ? this.columns : {};
|
|
282
|
+
if (!Array.isArray(this.schema)) {
|
|
283
|
+
for (const fieldName in this.schema) {
|
|
284
|
+
const field = this.schema[fieldName];
|
|
285
|
+
columns[field.name] = this.columns[field.index];
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
this.columns = {};
|
|
289
|
+
const batch = {
|
|
290
|
+
shape: "columnar-table",
|
|
291
|
+
batchType: "data",
|
|
292
|
+
data: columns,
|
|
293
|
+
schema: this.schema,
|
|
294
|
+
length: this.length
|
|
295
|
+
};
|
|
296
|
+
return batch;
|
|
297
|
+
}
|
|
298
|
+
_reallocateColumns() {
|
|
299
|
+
if (this.length < this.allocated) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
this.allocated = this.allocated > 0 ? this.allocated *= 2 : DEFAULT_ROW_COUNT3;
|
|
303
|
+
this.columns = {};
|
|
304
|
+
for (const fieldName in this.schema) {
|
|
305
|
+
const field = this.schema[fieldName];
|
|
306
|
+
const ArrayType = field.type || Float32Array;
|
|
307
|
+
const oldColumn = this.columns[field.index];
|
|
308
|
+
if (oldColumn && ArrayBuffer.isView(oldColumn)) {
|
|
309
|
+
const typedArray = new ArrayType(this.allocated);
|
|
310
|
+
typedArray.set(oldColumn);
|
|
311
|
+
this.columns[field.index] = typedArray;
|
|
312
|
+
} else if (oldColumn) {
|
|
313
|
+
oldColumn.length = this.allocated;
|
|
314
|
+
this.columns[field.index] = oldColumn;
|
|
315
|
+
} else {
|
|
316
|
+
this.columns[field.index] = new ArrayType(this.allocated);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
_pruneColumns() {
|
|
321
|
+
for (const [columnName, column] of Object.entries(this.columns)) {
|
|
322
|
+
this.columns[columnName] = column.slice(0, this.length);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/lib/table/batches/table-batch-builder.ts
|
|
328
|
+
var DEFAULT_OPTIONS = {
|
|
329
|
+
shape: "array-row-table",
|
|
330
|
+
batchSize: "auto",
|
|
331
|
+
batchDebounceMs: 0,
|
|
332
|
+
limit: 0,
|
|
333
|
+
_limitMB: 0
|
|
334
|
+
};
|
|
335
|
+
var ERR_MESSAGE = "TableBatchBuilder";
|
|
336
|
+
var TableBatchBuilder = class {
|
|
337
|
+
aggregator = null;
|
|
338
|
+
batchCount = 0;
|
|
339
|
+
bytesUsed = 0;
|
|
340
|
+
isChunkComplete = false;
|
|
341
|
+
lastBatchEmittedMs = Date.now();
|
|
342
|
+
totalLength = 0;
|
|
343
|
+
totalBytes = 0;
|
|
344
|
+
rowBytes = 0;
|
|
345
|
+
constructor(schema, options) {
|
|
346
|
+
this.schema = schema;
|
|
347
|
+
this.options = {
|
|
348
|
+
...DEFAULT_OPTIONS,
|
|
349
|
+
...options
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
limitReached() {
|
|
353
|
+
if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
|
|
354
|
+
return true;
|
|
355
|
+
}
|
|
356
|
+
if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
|
|
357
|
+
return true;
|
|
358
|
+
}
|
|
359
|
+
return false;
|
|
360
|
+
}
|
|
361
|
+
addRow(row) {
|
|
362
|
+
if (this.limitReached()) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
this.totalLength++;
|
|
366
|
+
this.rowBytes = this.rowBytes || this._estimateRowMB(row);
|
|
367
|
+
this.totalBytes += this.rowBytes;
|
|
368
|
+
if (Array.isArray(row)) {
|
|
369
|
+
this.addArrayRow(row);
|
|
370
|
+
} else {
|
|
371
|
+
this.addObjectRow(row);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
addArrayRow(row) {
|
|
375
|
+
if (!this.aggregator) {
|
|
376
|
+
const TableBatchType = this._getTableBatchType();
|
|
377
|
+
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
378
|
+
}
|
|
379
|
+
this.aggregator.addArrayRow(row);
|
|
380
|
+
}
|
|
381
|
+
addObjectRow(row) {
|
|
382
|
+
if (!this.aggregator) {
|
|
383
|
+
const TableBatchType = this._getTableBatchType();
|
|
384
|
+
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
385
|
+
}
|
|
386
|
+
this.aggregator.addObjectRow(row);
|
|
387
|
+
}
|
|
388
|
+
chunkComplete(chunk) {
|
|
389
|
+
if (chunk instanceof ArrayBuffer) {
|
|
390
|
+
this.bytesUsed += chunk.byteLength;
|
|
391
|
+
}
|
|
392
|
+
if (typeof chunk === "string") {
|
|
393
|
+
this.bytesUsed += chunk.length;
|
|
394
|
+
}
|
|
395
|
+
this.isChunkComplete = true;
|
|
396
|
+
}
|
|
397
|
+
getFullBatch(options) {
|
|
398
|
+
return this._isFull() ? this._getBatch(options) : null;
|
|
399
|
+
}
|
|
400
|
+
getFinalBatch(options) {
|
|
401
|
+
return this._getBatch(options);
|
|
402
|
+
}
|
|
403
|
+
_estimateRowMB(row) {
|
|
404
|
+
return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
|
|
405
|
+
}
|
|
406
|
+
_isFull() {
|
|
407
|
+
if (!this.aggregator || this.aggregator.rowCount() === 0) {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
if (this.options.batchSize === "auto") {
|
|
411
|
+
if (!this.isChunkComplete) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
} else if (this.options.batchSize > this.aggregator.rowCount()) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
this.isChunkComplete = false;
|
|
421
|
+
this.lastBatchEmittedMs = Date.now();
|
|
422
|
+
return true;
|
|
423
|
+
}
|
|
424
|
+
_getBatch(options) {
|
|
425
|
+
if (!this.aggregator) {
|
|
426
|
+
return null;
|
|
427
|
+
}
|
|
428
|
+
if (options?.bytesUsed) {
|
|
429
|
+
this.bytesUsed = options.bytesUsed;
|
|
430
|
+
}
|
|
431
|
+
const normalizedBatch = this.aggregator.getBatch();
|
|
432
|
+
normalizedBatch.count = this.batchCount;
|
|
433
|
+
normalizedBatch.bytesUsed = this.bytesUsed;
|
|
434
|
+
Object.assign(normalizedBatch, options);
|
|
435
|
+
this.batchCount++;
|
|
436
|
+
this.aggregator = null;
|
|
437
|
+
return normalizedBatch;
|
|
438
|
+
}
|
|
439
|
+
_getTableBatchType() {
|
|
440
|
+
switch (this.options.shape) {
|
|
441
|
+
case "row-table":
|
|
442
|
+
return BaseTableBatchAggregator;
|
|
443
|
+
case "array-row-table":
|
|
444
|
+
case "object-row-table":
|
|
445
|
+
return RowTableBatchAggregator;
|
|
446
|
+
case "columnar-table":
|
|
447
|
+
return ColumnarTableBatchAggregator;
|
|
448
|
+
case "arrow-table":
|
|
449
|
+
if (!TableBatchBuilder.ArrowBatch) {
|
|
450
|
+
throw new Error(ERR_MESSAGE);
|
|
451
|
+
}
|
|
452
|
+
return TableBatchBuilder.ArrowBatch;
|
|
453
|
+
default:
|
|
454
|
+
throw new Error(ERR_MESSAGE);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
// src/lib/table/simple-table/table-accessors.ts
|
|
460
|
+
function getTableLength(table) {
|
|
461
|
+
switch (table.shape) {
|
|
462
|
+
case "array-row-table":
|
|
463
|
+
case "object-row-table":
|
|
464
|
+
return table.data.length;
|
|
465
|
+
case "geojson-table":
|
|
466
|
+
return table.features.length;
|
|
467
|
+
case "arrow-table":
|
|
468
|
+
const arrowTable = table.data;
|
|
469
|
+
return arrowTable.numRows;
|
|
470
|
+
case "columnar-table":
|
|
471
|
+
for (const column of Object.values(table.data)) {
|
|
472
|
+
return column.length || 0;
|
|
473
|
+
}
|
|
474
|
+
return 0;
|
|
475
|
+
default:
|
|
476
|
+
throw new Error("table");
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
function getTableNumCols(table) {
|
|
480
|
+
if (table.schema) {
|
|
481
|
+
return table.schema.fields.length;
|
|
482
|
+
}
|
|
483
|
+
if (getTableLength(table) === 0) {
|
|
484
|
+
throw new Error("empty table");
|
|
485
|
+
}
|
|
486
|
+
switch (table.shape) {
|
|
487
|
+
case "array-row-table":
|
|
488
|
+
return table.data[0].length;
|
|
489
|
+
case "object-row-table":
|
|
490
|
+
return Object.keys(table.data[0]).length;
|
|
491
|
+
case "geojson-table":
|
|
492
|
+
return Object.keys(table.features[0]).length;
|
|
493
|
+
case "columnar-table":
|
|
494
|
+
return Object.keys(table.data).length;
|
|
495
|
+
case "arrow-table":
|
|
496
|
+
const arrowTable = table.data;
|
|
497
|
+
return arrowTable.numCols;
|
|
498
|
+
default:
|
|
499
|
+
throw new Error("table");
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function getTableCell(table, rowIndex, columnName) {
|
|
503
|
+
switch (table.shape) {
|
|
504
|
+
case "array-row-table":
|
|
505
|
+
const columnIndex = getTableColumnIndex(table, columnName);
|
|
506
|
+
return table.data[rowIndex][columnIndex];
|
|
507
|
+
case "object-row-table":
|
|
508
|
+
return table.data[rowIndex][columnName];
|
|
509
|
+
case "geojson-table":
|
|
510
|
+
return table.features[rowIndex][columnName];
|
|
511
|
+
case "columnar-table":
|
|
512
|
+
const column = table.data[columnName];
|
|
513
|
+
return column[rowIndex];
|
|
514
|
+
case "arrow-table":
|
|
515
|
+
const arrowTable = table.data;
|
|
516
|
+
const arrowColumnIndex = arrowTable.schema.fields.findIndex((field) => field.name === columnName);
|
|
517
|
+
return arrowTable.getChildAt(arrowColumnIndex)?.get(rowIndex);
|
|
518
|
+
default:
|
|
519
|
+
throw new Error("todo");
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
function getTableRowShape(table) {
|
|
523
|
+
switch (table.shape) {
|
|
524
|
+
case "array-row-table":
|
|
525
|
+
case "object-row-table":
|
|
526
|
+
return table.shape;
|
|
527
|
+
case "geojson-table":
|
|
528
|
+
return "object-row-table";
|
|
529
|
+
case "columnar-table":
|
|
530
|
+
default:
|
|
531
|
+
throw new Error("Not a row table");
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
function getTableColumnIndex(table, columnName) {
|
|
535
|
+
const columnIndex = table.schema?.fields.findIndex((field) => field.name === columnName);
|
|
536
|
+
if (columnIndex === void 0) {
|
|
537
|
+
throw new Error(columnName);
|
|
538
|
+
}
|
|
539
|
+
return columnIndex;
|
|
540
|
+
}
|
|
541
|
+
function getTableColumnName(table, columnIndex) {
|
|
542
|
+
const columnName = table.schema?.fields[columnIndex]?.name;
|
|
543
|
+
if (!columnName) {
|
|
544
|
+
throw new Error(`${columnIndex}`);
|
|
545
|
+
}
|
|
546
|
+
return columnName;
|
|
547
|
+
}
|
|
548
|
+
function getTableRowAsObject(table, rowIndex, target, copy) {
|
|
549
|
+
switch (table.shape) {
|
|
550
|
+
case "object-row-table":
|
|
551
|
+
return copy ? Object.fromEntries(Object.entries(table.data[rowIndex])) : table.data[rowIndex];
|
|
552
|
+
case "array-row-table":
|
|
553
|
+
if (table.schema) {
|
|
554
|
+
const objectRow2 = target || {};
|
|
555
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
556
|
+
objectRow2[table.schema.fields[i].name] = table.data[rowIndex][i];
|
|
557
|
+
}
|
|
558
|
+
return objectRow2;
|
|
559
|
+
}
|
|
560
|
+
throw new Error("no schema");
|
|
561
|
+
case "geojson-table":
|
|
562
|
+
if (table.schema) {
|
|
563
|
+
const objectRow2 = target || {};
|
|
564
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
565
|
+
objectRow2[table.schema.fields[i].name] = table.features[rowIndex][i];
|
|
566
|
+
}
|
|
567
|
+
return objectRow2;
|
|
568
|
+
}
|
|
569
|
+
throw new Error("no schema");
|
|
570
|
+
case "columnar-table":
|
|
571
|
+
if (table.schema) {
|
|
572
|
+
const objectRow2 = target || {};
|
|
573
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
574
|
+
objectRow2[table.schema.fields[i].name] = table.data[table.schema.fields[i].name][rowIndex];
|
|
575
|
+
}
|
|
576
|
+
return objectRow2;
|
|
577
|
+
} else {
|
|
578
|
+
const objectRow2 = target || {};
|
|
579
|
+
for (const [name, column] of Object.entries(table.data)) {
|
|
580
|
+
objectRow2[name] = column[rowIndex];
|
|
581
|
+
}
|
|
582
|
+
return objectRow2;
|
|
583
|
+
}
|
|
584
|
+
case "arrow-table":
|
|
585
|
+
const arrowTable = table.data;
|
|
586
|
+
const objectRow = target || {};
|
|
587
|
+
const row = arrowTable.get(rowIndex);
|
|
588
|
+
const schema = arrowTable.schema;
|
|
589
|
+
for (let i = 0; i < schema.fields.length; i++) {
|
|
590
|
+
objectRow[schema.fields[i].name] = row?.[schema.fields[i].name];
|
|
591
|
+
}
|
|
592
|
+
return objectRow;
|
|
593
|
+
default:
|
|
594
|
+
throw new Error("shape");
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
function getTableRowAsArray(table, rowIndex, target, copy) {
|
|
598
|
+
switch (table.shape) {
|
|
599
|
+
case "array-row-table":
|
|
600
|
+
return copy ? Array.from(table.data[rowIndex]) : table.data[rowIndex];
|
|
601
|
+
case "object-row-table":
|
|
602
|
+
if (table.schema) {
|
|
603
|
+
const arrayRow2 = target || [];
|
|
604
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
605
|
+
arrayRow2[i] = table.data[rowIndex][table.schema.fields[i].name];
|
|
606
|
+
}
|
|
607
|
+
return arrayRow2;
|
|
608
|
+
}
|
|
609
|
+
return Object.values(table.data[rowIndex]);
|
|
610
|
+
case "geojson-table":
|
|
611
|
+
if (table.schema) {
|
|
612
|
+
const arrayRow2 = target || [];
|
|
613
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
614
|
+
arrayRow2[i] = table.features[rowIndex][table.schema.fields[i].name];
|
|
615
|
+
}
|
|
616
|
+
return arrayRow2;
|
|
617
|
+
}
|
|
618
|
+
return Object.values(table.features[rowIndex]);
|
|
619
|
+
case "columnar-table":
|
|
620
|
+
if (table.schema) {
|
|
621
|
+
const arrayRow2 = target || [];
|
|
622
|
+
for (let i = 0; i < table.schema.fields.length; i++) {
|
|
623
|
+
arrayRow2[i] = table.data[table.schema.fields[i].name][rowIndex];
|
|
624
|
+
}
|
|
625
|
+
return arrayRow2;
|
|
626
|
+
} else {
|
|
627
|
+
const arrayRow2 = target || [];
|
|
628
|
+
let i = 0;
|
|
629
|
+
for (const column of Object.values(table.data)) {
|
|
630
|
+
arrayRow2[i] = column[rowIndex];
|
|
631
|
+
i++;
|
|
632
|
+
}
|
|
633
|
+
return arrayRow2;
|
|
634
|
+
}
|
|
635
|
+
case "arrow-table":
|
|
636
|
+
const arrowTable = table.data;
|
|
637
|
+
const arrayRow = target || [];
|
|
638
|
+
const row = arrowTable.get(rowIndex);
|
|
639
|
+
const schema = arrowTable.schema;
|
|
640
|
+
for (let i = 0; i < schema.fields.length; i++) {
|
|
641
|
+
arrayRow[i] = row?.[schema.fields[i].name];
|
|
642
|
+
}
|
|
643
|
+
return arrayRow;
|
|
644
|
+
default:
|
|
645
|
+
throw new Error("shape");
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function* makeRowIterator(table, shape) {
|
|
649
|
+
switch (shape) {
|
|
650
|
+
case "array-row-table":
|
|
651
|
+
yield* makeArrayRowIterator(table);
|
|
652
|
+
break;
|
|
653
|
+
case "object-row-table":
|
|
654
|
+
yield* makeObjectRowIterator(table);
|
|
655
|
+
break;
|
|
656
|
+
default:
|
|
657
|
+
throw new Error(`Unknown row type ${shape}`);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
function* makeArrayRowIterator(table, target = []) {
|
|
661
|
+
const length = getTableLength(table);
|
|
662
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
663
|
+
yield getTableRowAsArray(table, rowIndex, target);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
function* makeObjectRowIterator(table, target = {}) {
|
|
667
|
+
const length = getTableLength(table);
|
|
668
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
669
|
+
yield getTableRowAsObject(table, rowIndex, target);
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
// src/lib/table/arrow-api/arrow-like-field.ts
|
|
674
|
+
var ArrowLikeField = class {
|
|
675
|
+
constructor(name, type, nullable = false, metadata = /* @__PURE__ */ new Map()) {
|
|
676
|
+
this.name = name;
|
|
677
|
+
this.type = type;
|
|
678
|
+
this.nullable = nullable;
|
|
679
|
+
this.metadata = metadata;
|
|
680
|
+
}
|
|
681
|
+
get typeId() {
|
|
682
|
+
return this.type && this.type.typeId;
|
|
683
|
+
}
|
|
684
|
+
clone() {
|
|
685
|
+
return new ArrowLikeField(this.name, this.type, this.nullable, this.metadata);
|
|
686
|
+
}
|
|
687
|
+
compareTo(other) {
|
|
688
|
+
return this.name === other.name && this.type === other.type && this.nullable === other.nullable && this.metadata === other.metadata;
|
|
689
|
+
}
|
|
690
|
+
toString() {
|
|
691
|
+
return `${this.type}${this.nullable ? ", nullable" : ""}${this.metadata ? `, metadata: ${this.metadata}` : ""}`;
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
// src/lib/table/arrow-api/arrow-like-schema.ts
|
|
696
|
+
var ArrowLikeSchema = class {
|
|
697
|
+
constructor(fields, metadata = /* @__PURE__ */ new Map()) {
|
|
698
|
+
this.fields = fields.map((field) => new ArrowLikeField(field.name, field.type, field.nullable, field.metadata));
|
|
699
|
+
this.metadata = metadata instanceof Map ? metadata : new Map(Object.entries(metadata));
|
|
700
|
+
}
|
|
701
|
+
compareTo(other) {
|
|
702
|
+
if (this.metadata !== other.metadata) {
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
if (this.fields.length !== other.fields.length) {
|
|
706
|
+
return false;
|
|
707
|
+
}
|
|
708
|
+
for (let i = 0; i < this.fields.length; ++i) {
|
|
709
|
+
if (!this.fields[i].compareTo(other.fields[i])) {
|
|
710
|
+
return false;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
select(...columnNames) {
|
|
716
|
+
const nameMap = /* @__PURE__ */ Object.create(null);
|
|
717
|
+
for (const name of columnNames) {
|
|
718
|
+
nameMap[name] = true;
|
|
719
|
+
}
|
|
720
|
+
const selectedFields = this.fields.filter((field) => nameMap[field.name]);
|
|
721
|
+
return new ArrowLikeSchema(selectedFields, this.metadata);
|
|
722
|
+
}
|
|
723
|
+
selectAt(...columnIndices) {
|
|
724
|
+
const selectedFields = columnIndices.map((index) => this.fields[index]).filter(Boolean);
|
|
725
|
+
return new ArrowLikeSchema(selectedFields, this.metadata);
|
|
726
|
+
}
|
|
727
|
+
assign(schemaOrFields) {
|
|
728
|
+
let fields;
|
|
729
|
+
let metadata = this.metadata;
|
|
730
|
+
if (schemaOrFields instanceof ArrowLikeSchema) {
|
|
731
|
+
const otherArrowLikeSchema = schemaOrFields;
|
|
732
|
+
fields = otherArrowLikeSchema.fields;
|
|
733
|
+
metadata = mergeMaps(mergeMaps(/* @__PURE__ */ new Map(), this.metadata), otherArrowLikeSchema.metadata);
|
|
734
|
+
} else {
|
|
735
|
+
fields = schemaOrFields;
|
|
736
|
+
}
|
|
737
|
+
const fieldMap = /* @__PURE__ */ Object.create(null);
|
|
738
|
+
for (const field of this.fields) {
|
|
739
|
+
fieldMap[field.name] = field;
|
|
740
|
+
}
|
|
741
|
+
for (const field of fields) {
|
|
742
|
+
fieldMap[field.name] = field;
|
|
743
|
+
}
|
|
744
|
+
const mergedFields = Object.values(fieldMap);
|
|
745
|
+
return new ArrowLikeSchema(mergedFields, metadata);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
function mergeMaps(m1, m2) {
|
|
749
|
+
return new Map([...m1 || /* @__PURE__ */ new Map(), ...m2 || /* @__PURE__ */ new Map()]);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
// src/lib/table/simple-table/data-type.ts
|
|
753
|
+
function getDataTypeFromValue(value, defaultNumberType = "float32") {
|
|
754
|
+
if (value instanceof Date) {
|
|
755
|
+
return "date-millisecond";
|
|
756
|
+
}
|
|
757
|
+
if (value instanceof Number) {
|
|
758
|
+
return defaultNumberType;
|
|
759
|
+
}
|
|
760
|
+
if (typeof value === "string") {
|
|
761
|
+
return "utf8";
|
|
762
|
+
}
|
|
763
|
+
if (value === null || value === "undefined") {
|
|
764
|
+
return "null";
|
|
765
|
+
}
|
|
766
|
+
return "null";
|
|
767
|
+
}
|
|
768
|
+
function getDataTypeFromArray(array) {
|
|
769
|
+
let type = getDataTypeFromTypedArray(array);
|
|
770
|
+
if (type !== "null") {
|
|
771
|
+
return {
|
|
772
|
+
type,
|
|
773
|
+
nullable: false
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
if (array.length > 0) {
|
|
777
|
+
type = getDataTypeFromValue(array[0]);
|
|
778
|
+
return {
|
|
779
|
+
type,
|
|
780
|
+
nullable: true
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
return {
|
|
784
|
+
type: "null",
|
|
785
|
+
nullable: true
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function getDataTypeFromTypedArray(array) {
|
|
789
|
+
switch (array.constructor) {
|
|
790
|
+
case Int8Array:
|
|
791
|
+
return "int8";
|
|
792
|
+
case Uint8Array:
|
|
793
|
+
case Uint8ClampedArray:
|
|
794
|
+
return "uint8";
|
|
795
|
+
case Int16Array:
|
|
796
|
+
return "int16";
|
|
797
|
+
case Uint16Array:
|
|
798
|
+
return "uint16";
|
|
799
|
+
case Int32Array:
|
|
800
|
+
return "int32";
|
|
801
|
+
case Uint32Array:
|
|
802
|
+
return "uint32";
|
|
803
|
+
case Float32Array:
|
|
804
|
+
return "float32";
|
|
805
|
+
case Float64Array:
|
|
806
|
+
return "float64";
|
|
807
|
+
default:
|
|
808
|
+
return "null";
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
function getArrayTypeFromDataType(type, nullable) {
|
|
812
|
+
if (!nullable) {
|
|
813
|
+
switch (type) {
|
|
814
|
+
case "int8":
|
|
815
|
+
return Int8Array;
|
|
816
|
+
case "uint8":
|
|
817
|
+
return Uint8Array;
|
|
818
|
+
case "int16":
|
|
819
|
+
return Int16Array;
|
|
820
|
+
case "uint16":
|
|
821
|
+
return Uint16Array;
|
|
822
|
+
case "int32":
|
|
823
|
+
return Int32Array;
|
|
824
|
+
case "uint32":
|
|
825
|
+
return Uint32Array;
|
|
826
|
+
case "float32":
|
|
827
|
+
return Float32Array;
|
|
828
|
+
case "float64":
|
|
829
|
+
return Float64Array;
|
|
830
|
+
default:
|
|
831
|
+
break;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return Array;
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// src/lib/table/simple-table/table-schema.ts
|
|
838
|
+
function deduceTableSchema(table) {
|
|
839
|
+
switch (table.shape) {
|
|
840
|
+
case "array-row-table":
|
|
841
|
+
case "object-row-table":
|
|
842
|
+
return deduceSchemaFromRows(table.data);
|
|
843
|
+
case "columnar-table":
|
|
844
|
+
return deduceSchemaFromColumns(table.data);
|
|
845
|
+
case "arrow-table":
|
|
846
|
+
default:
|
|
847
|
+
throw new Error("Deduce schema");
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
851
|
+
const fields = [];
|
|
852
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
853
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
854
|
+
fields.push(field);
|
|
855
|
+
}
|
|
856
|
+
return {
|
|
857
|
+
fields,
|
|
858
|
+
metadata: {}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
861
|
+
function deduceSchemaFromRows(rowTable) {
|
|
862
|
+
if (!rowTable.length) {
|
|
863
|
+
throw new Error("deduce from empty table");
|
|
864
|
+
}
|
|
865
|
+
const fields = [];
|
|
866
|
+
const row0 = rowTable[0];
|
|
867
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
868
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
869
|
+
}
|
|
870
|
+
return {
|
|
871
|
+
fields,
|
|
872
|
+
metadata: {}
|
|
873
|
+
};
|
|
874
|
+
}
|
|
875
|
+
function deduceFieldFromColumn(column, name) {
|
|
876
|
+
if (ArrayBuffer.isView(column)) {
|
|
877
|
+
const type = getDataTypeFromArray(column);
|
|
878
|
+
return {
|
|
879
|
+
name,
|
|
880
|
+
type: type.type || "null",
|
|
881
|
+
nullable: type.nullable
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
885
|
+
const value = column[0];
|
|
886
|
+
const type = getDataTypeFromValue(value);
|
|
887
|
+
return {
|
|
888
|
+
name,
|
|
889
|
+
type,
|
|
890
|
+
nullable: true
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
throw new Error("empty table");
|
|
894
|
+
}
|
|
895
|
+
function deduceFieldFromValue(value, name) {
|
|
896
|
+
const type = getDataTypeFromValue(value);
|
|
897
|
+
return {
|
|
898
|
+
name,
|
|
899
|
+
type,
|
|
900
|
+
nullable: true
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
// src/lib/table/arrow-api/arrow-like-table.ts
|
|
905
|
+
var ArrowLikeVector = class {
|
|
906
|
+
constructor(table, columnName) {
|
|
907
|
+
this.table = table;
|
|
908
|
+
this.columnName = columnName;
|
|
909
|
+
}
|
|
910
|
+
get(rowIndex) {
|
|
911
|
+
return getTableCell(this.table, rowIndex, this.columnName);
|
|
912
|
+
}
|
|
913
|
+
toArray() {
|
|
914
|
+
switch (this.table.shape) {
|
|
915
|
+
case "arrow-table":
|
|
916
|
+
const arrowTable = this.table.data;
|
|
917
|
+
return arrowTable.getChild(this.columnName)?.toArray();
|
|
918
|
+
case "columnar-table":
|
|
919
|
+
return this.table.data[this.columnName];
|
|
920
|
+
default:
|
|
921
|
+
throw new Error(this.table.shape);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
};
|
|
925
|
+
var ArrowLikeTable = class {
|
|
926
|
+
constructor(table) {
|
|
927
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
928
|
+
this.schema = new ArrowLikeSchema(schema.fields, schema.metadata);
|
|
929
|
+
this.table = {
|
|
930
|
+
...table,
|
|
931
|
+
schema
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
get data() {
|
|
935
|
+
return this.table.shape === "geojson-table" ? this.table.features : this.table.data;
|
|
936
|
+
}
|
|
937
|
+
get numCols() {
|
|
938
|
+
return getTableNumCols(this.table);
|
|
939
|
+
}
|
|
940
|
+
get length() {
|
|
941
|
+
return getTableLength(this.table);
|
|
942
|
+
}
|
|
943
|
+
getChild(columnName) {
|
|
944
|
+
return new ArrowLikeVector(this.table, columnName);
|
|
945
|
+
}
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
// src/lib/table/simple-table/make-table.ts
|
|
949
|
+
function makeTableFromData(data) {
|
|
950
|
+
let table;
|
|
951
|
+
switch (getTableShapeFromData(data)) {
|
|
952
|
+
case "array-row-table":
|
|
953
|
+
table = {
|
|
954
|
+
shape: "array-row-table",
|
|
955
|
+
data
|
|
956
|
+
};
|
|
957
|
+
break;
|
|
958
|
+
case "object-row-table":
|
|
959
|
+
table = {
|
|
960
|
+
shape: "object-row-table",
|
|
961
|
+
data
|
|
962
|
+
};
|
|
963
|
+
break;
|
|
964
|
+
case "columnar-table":
|
|
965
|
+
table = {
|
|
966
|
+
shape: "columnar-table",
|
|
967
|
+
data
|
|
968
|
+
};
|
|
969
|
+
break;
|
|
970
|
+
default:
|
|
971
|
+
throw new Error("table");
|
|
972
|
+
}
|
|
973
|
+
const schema = deduceTableSchema(table);
|
|
974
|
+
return {
|
|
975
|
+
...table,
|
|
976
|
+
schema
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
function getTableShapeFromData(data) {
|
|
980
|
+
if (Array.isArray(data)) {
|
|
981
|
+
if (data.length === 0) {
|
|
982
|
+
throw new Error("cannot deduce type of empty table");
|
|
983
|
+
}
|
|
984
|
+
const firstRow = data[0];
|
|
985
|
+
if (Array.isArray(firstRow)) {
|
|
986
|
+
return "array-row-table";
|
|
987
|
+
}
|
|
988
|
+
if (firstRow && typeof firstRow === "object") {
|
|
989
|
+
return "object-row-table";
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
if (data && typeof data === "object") {
|
|
993
|
+
return "columnar-table";
|
|
994
|
+
}
|
|
995
|
+
throw new Error("invalid table");
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// src/lib/table/simple-table/table-column.ts
|
|
999
|
+
function makeColumnFromField(field, length) {
|
|
1000
|
+
const ArrayType = getArrayTypeFromDataType(field.type, field.nullable);
|
|
1001
|
+
return new ArrayType(length);
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
// src/lib/table/simple-table/convert-table.ts
|
|
1005
|
+
function convertTable(table, shape) {
|
|
1006
|
+
switch (shape) {
|
|
1007
|
+
case "object-row-table":
|
|
1008
|
+
return makeObjectRowTable(table);
|
|
1009
|
+
case "array-row-table":
|
|
1010
|
+
return makeArrayRowTable(table);
|
|
1011
|
+
case "columnar-table":
|
|
1012
|
+
return makeColumnarTable(table);
|
|
1013
|
+
case "arrow-table":
|
|
1014
|
+
return makeArrowTable(table);
|
|
1015
|
+
default:
|
|
1016
|
+
throw new Error(shape);
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
function makeArrowTable(table) {
|
|
1020
|
+
const _makeArrowTable = globalThis.__luma?._makeArrowTable;
|
|
1021
|
+
if (!_makeArrowTable) {
|
|
1022
|
+
throw new Error("");
|
|
1023
|
+
}
|
|
1024
|
+
return _makeArrowTable(table);
|
|
1025
|
+
}
|
|
1026
|
+
function makeColumnarTable(table) {
|
|
1027
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
1028
|
+
const fields = table.schema?.fields || [];
|
|
1029
|
+
if (table.shape === "columnar-table") {
|
|
1030
|
+
return {
|
|
1031
|
+
...table,
|
|
1032
|
+
schema
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
const length = getTableLength(table);
|
|
1036
|
+
const columns = {};
|
|
1037
|
+
for (const field of fields) {
|
|
1038
|
+
const column = makeColumnFromField(field, length);
|
|
1039
|
+
columns[field.name] = column;
|
|
1040
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1041
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
return {
|
|
1045
|
+
shape: "columnar-table",
|
|
1046
|
+
schema,
|
|
1047
|
+
data: columns
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
function makeArrayRowTable(table) {
|
|
1051
|
+
if (table.shape === "array-row-table") {
|
|
1052
|
+
return table;
|
|
1053
|
+
}
|
|
1054
|
+
const length = getTableLength(table);
|
|
1055
|
+
const data = new Array(length);
|
|
1056
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1057
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
1058
|
+
}
|
|
1059
|
+
return {
|
|
1060
|
+
shape: "array-row-table",
|
|
1061
|
+
schema: table.schema,
|
|
1062
|
+
data
|
|
1063
|
+
};
|
|
1064
|
+
}
|
|
1065
|
+
function makeObjectRowTable(table) {
|
|
1066
|
+
if (table.shape === "object-row-table") {
|
|
1067
|
+
return table;
|
|
1068
|
+
}
|
|
1069
|
+
const length = getTableLength(table);
|
|
1070
|
+
const data = new Array(length);
|
|
1071
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1072
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
1073
|
+
}
|
|
1074
|
+
return {
|
|
1075
|
+
shape: "object-row-table",
|
|
1076
|
+
schema: table.schema,
|
|
1077
|
+
data
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// src/lib/mesh/mesh-utils.ts
|
|
1082
|
+
function getMeshSize(attributes) {
|
|
1083
|
+
let size = 0;
|
|
1084
|
+
for (const attributeName in attributes) {
|
|
1085
|
+
const attribute = attributes[attributeName];
|
|
1086
|
+
if (ArrayBuffer.isView(attribute)) {
|
|
1087
|
+
size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
return size;
|
|
1091
|
+
}
|
|
1092
|
+
function getMeshBoundingBox(attributes) {
|
|
1093
|
+
let minX = Infinity;
|
|
1094
|
+
let minY = Infinity;
|
|
1095
|
+
let minZ = Infinity;
|
|
1096
|
+
let maxX = -Infinity;
|
|
1097
|
+
let maxY = -Infinity;
|
|
1098
|
+
let maxZ = -Infinity;
|
|
1099
|
+
const positions = attributes.POSITION ? attributes.POSITION.value : [];
|
|
1100
|
+
const len = positions && positions.length;
|
|
1101
|
+
for (let i = 0; i < len; i += 3) {
|
|
1102
|
+
const x = positions[i];
|
|
1103
|
+
const y = positions[i + 1];
|
|
1104
|
+
const z = positions[i + 2];
|
|
1105
|
+
minX = x < minX ? x : minX;
|
|
1106
|
+
minY = y < minY ? y : minY;
|
|
1107
|
+
minZ = z < minZ ? z : minZ;
|
|
1108
|
+
maxX = x > maxX ? x : maxX;
|
|
1109
|
+
maxY = y > maxY ? y : maxY;
|
|
1110
|
+
maxZ = z > maxZ ? z : maxZ;
|
|
1111
|
+
}
|
|
1112
|
+
return [[minX, minY, minZ], [maxX, maxY, maxZ]];
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
// src/lib/mesh/deduce-mesh-schema.ts
|
|
1116
|
+
function deduceMeshSchema(attributes, metadata = {}) {
|
|
1117
|
+
const fields = deduceMeshFields(attributes);
|
|
1118
|
+
return {
|
|
1119
|
+
fields,
|
|
1120
|
+
metadata
|
|
1121
|
+
};
|
|
1122
|
+
}
|
|
1123
|
+
function deduceMeshField(name, attribute, optionalMetadata) {
|
|
1124
|
+
const type = getDataTypeFromTypedArray(attribute.value);
|
|
1125
|
+
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
1126
|
+
return {
|
|
1127
|
+
name,
|
|
1128
|
+
type: {
|
|
1129
|
+
type: "fixed-size-list",
|
|
1130
|
+
listSize: attribute.size,
|
|
1131
|
+
children: [{
|
|
1132
|
+
name: "value",
|
|
1133
|
+
type
|
|
1134
|
+
}]
|
|
1135
|
+
},
|
|
1136
|
+
nullable: false,
|
|
1137
|
+
metadata
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1140
|
+
function deduceMeshFields(attributes) {
|
|
1141
|
+
const fields = [];
|
|
1142
|
+
for (const attributeName in attributes) {
|
|
1143
|
+
const attribute = attributes[attributeName];
|
|
1144
|
+
fields.push(deduceMeshField(attributeName, attribute));
|
|
1145
|
+
}
|
|
1146
|
+
return fields;
|
|
1147
|
+
}
|
|
1148
|
+
function makeMeshAttributeMetadata(attribute) {
|
|
1149
|
+
const result = {};
|
|
1150
|
+
if ("byteOffset" in attribute) {
|
|
1151
|
+
result.byteOffset = attribute.byteOffset.toString(10);
|
|
1152
|
+
}
|
|
1153
|
+
if ("byteStride" in attribute) {
|
|
1154
|
+
result.byteStride = attribute.byteStride.toString(10);
|
|
1155
|
+
}
|
|
1156
|
+
if ("normalized" in attribute) {
|
|
1157
|
+
result.normalized = attribute.normalized.toString();
|
|
1158
|
+
}
|
|
1159
|
+
return result;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
// src/lib/table/arrow-api/enum.ts
|
|
1163
|
+
var Type = function(Type2) {
|
|
1164
|
+
Type2[Type2["NONE"] = 0] = "NONE";
|
|
1165
|
+
Type2[Type2["Null"] = 1] = "Null";
|
|
1166
|
+
Type2[Type2["Int"] = 2] = "Int";
|
|
1167
|
+
Type2[Type2["Float"] = 3] = "Float";
|
|
1168
|
+
Type2[Type2["Binary"] = 4] = "Binary";
|
|
1169
|
+
Type2[Type2["Utf8"] = 5] = "Utf8";
|
|
1170
|
+
Type2[Type2["Bool"] = 6] = "Bool";
|
|
1171
|
+
Type2[Type2["Decimal"] = 7] = "Decimal";
|
|
1172
|
+
Type2[Type2["Date"] = 8] = "Date";
|
|
1173
|
+
Type2[Type2["Time"] = 9] = "Time";
|
|
1174
|
+
Type2[Type2["Timestamp"] = 10] = "Timestamp";
|
|
1175
|
+
Type2[Type2["Interval"] = 11] = "Interval";
|
|
1176
|
+
Type2[Type2["List"] = 12] = "List";
|
|
1177
|
+
Type2[Type2["Struct"] = 13] = "Struct";
|
|
1178
|
+
Type2[Type2["Union"] = 14] = "Union";
|
|
1179
|
+
Type2[Type2["FixedSizeBinary"] = 15] = "FixedSizeBinary";
|
|
1180
|
+
Type2[Type2["FixedSizeList"] = 16] = "FixedSizeList";
|
|
1181
|
+
Type2[Type2["Map"] = 17] = "Map";
|
|
1182
|
+
Type2[Type2["Dictionary"] = -1] = "Dictionary";
|
|
1183
|
+
Type2[Type2["Int8"] = -2] = "Int8";
|
|
1184
|
+
Type2[Type2["Int16"] = -3] = "Int16";
|
|
1185
|
+
Type2[Type2["Int32"] = -4] = "Int32";
|
|
1186
|
+
Type2[Type2["Int64"] = -5] = "Int64";
|
|
1187
|
+
Type2[Type2["Uint8"] = -6] = "Uint8";
|
|
1188
|
+
Type2[Type2["Uint16"] = -7] = "Uint16";
|
|
1189
|
+
Type2[Type2["Uint32"] = -8] = "Uint32";
|
|
1190
|
+
Type2[Type2["Uint64"] = -9] = "Uint64";
|
|
1191
|
+
Type2[Type2["Float16"] = -10] = "Float16";
|
|
1192
|
+
Type2[Type2["Float32"] = -11] = "Float32";
|
|
1193
|
+
Type2[Type2["Float64"] = -12] = "Float64";
|
|
1194
|
+
Type2[Type2["DateDay"] = -13] = "DateDay";
|
|
1195
|
+
Type2[Type2["DateMillisecond"] = -14] = "DateMillisecond";
|
|
1196
|
+
Type2[Type2["TimestampSecond"] = -15] = "TimestampSecond";
|
|
1197
|
+
Type2[Type2["TimestampMillisecond"] = -16] = "TimestampMillisecond";
|
|
1198
|
+
Type2[Type2["TimestampMicrosecond"] = -17] = "TimestampMicrosecond";
|
|
1199
|
+
Type2[Type2["TimestampNanosecond"] = -18] = "TimestampNanosecond";
|
|
1200
|
+
Type2[Type2["TimeSecond"] = -19] = "TimeSecond";
|
|
1201
|
+
Type2[Type2["TimeMillisecond"] = -20] = "TimeMillisecond";
|
|
1202
|
+
Type2[Type2["TimeMicrosecond"] = -21] = "TimeMicrosecond";
|
|
1203
|
+
Type2[Type2["TimeNanosecond"] = -22] = "TimeNanosecond";
|
|
1204
|
+
Type2[Type2["DenseUnion"] = -23] = "DenseUnion";
|
|
1205
|
+
Type2[Type2["SparseUnion"] = -24] = "SparseUnion";
|
|
1206
|
+
Type2[Type2["IntervalDayTime"] = -25] = "IntervalDayTime";
|
|
1207
|
+
Type2[Type2["IntervalYearMonth"] = -26] = "IntervalYearMonth";
|
|
1208
|
+
return Type2;
|
|
1209
|
+
}({});
|
|
1210
|
+
|
|
1211
|
+
// src/lib/table/arrow-api/arrow-like-type.ts
|
|
1212
|
+
var DataType = class {
|
|
1213
|
+
static isNull(x) {
|
|
1214
|
+
return x && x.typeId === Type.Null;
|
|
1215
|
+
}
|
|
1216
|
+
static isInt(x) {
|
|
1217
|
+
return x && x.typeId === Type.Int;
|
|
1218
|
+
}
|
|
1219
|
+
static isFloat(x) {
|
|
1220
|
+
return x && x.typeId === Type.Float;
|
|
1221
|
+
}
|
|
1222
|
+
static isBinary(x) {
|
|
1223
|
+
return x && x.typeId === Type.Binary;
|
|
1224
|
+
}
|
|
1225
|
+
static isUtf8(x) {
|
|
1226
|
+
return x && x.typeId === Type.Utf8;
|
|
1227
|
+
}
|
|
1228
|
+
static isBool(x) {
|
|
1229
|
+
return x && x.typeId === Type.Bool;
|
|
1230
|
+
}
|
|
1231
|
+
static isDecimal(x) {
|
|
1232
|
+
return x && x.typeId === Type.Decimal;
|
|
1233
|
+
}
|
|
1234
|
+
static isDate(x) {
|
|
1235
|
+
return x && x.typeId === Type.Date;
|
|
1236
|
+
}
|
|
1237
|
+
static isTime(x) {
|
|
1238
|
+
return x && x.typeId === Type.Time;
|
|
1239
|
+
}
|
|
1240
|
+
static isTimestamp(x) {
|
|
1241
|
+
return x && x.typeId === Type.Timestamp;
|
|
1242
|
+
}
|
|
1243
|
+
static isInterval(x) {
|
|
1244
|
+
return x && x.typeId === Type.Interval;
|
|
1245
|
+
}
|
|
1246
|
+
static isList(x) {
|
|
1247
|
+
return x && x.typeId === Type.List;
|
|
1248
|
+
}
|
|
1249
|
+
static isStruct(x) {
|
|
1250
|
+
return x && x.typeId === Type.Struct;
|
|
1251
|
+
}
|
|
1252
|
+
static isUnion(x) {
|
|
1253
|
+
return x && x.typeId === Type.Union;
|
|
1254
|
+
}
|
|
1255
|
+
static isFixedSizeBinary(x) {
|
|
1256
|
+
return x && x.typeId === Type.FixedSizeBinary;
|
|
1257
|
+
}
|
|
1258
|
+
static isFixedSizeList(x) {
|
|
1259
|
+
return x && x.typeId === Type.FixedSizeList;
|
|
1260
|
+
}
|
|
1261
|
+
static isMap(x) {
|
|
1262
|
+
return x && x.typeId === Type.Map;
|
|
1263
|
+
}
|
|
1264
|
+
static isDictionary(x) {
|
|
1265
|
+
return x && x.typeId === Type.Dictionary;
|
|
1266
|
+
}
|
|
1267
|
+
get typeId() {
|
|
1268
|
+
return Type.NONE;
|
|
1269
|
+
}
|
|
1270
|
+
compareTo(other) {
|
|
1271
|
+
return this === other;
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
var Null = class extends DataType {
|
|
1275
|
+
get typeId() {
|
|
1276
|
+
return Type.Null;
|
|
1277
|
+
}
|
|
1278
|
+
get [Symbol.toStringTag]() {
|
|
1279
|
+
return "Null";
|
|
1280
|
+
}
|
|
1281
|
+
toString() {
|
|
1282
|
+
return "Null";
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
var Bool = class extends DataType {
|
|
1286
|
+
get typeId() {
|
|
1287
|
+
return Type.Bool;
|
|
1288
|
+
}
|
|
1289
|
+
get [Symbol.toStringTag]() {
|
|
1290
|
+
return "Bool";
|
|
1291
|
+
}
|
|
1292
|
+
toString() {
|
|
1293
|
+
return "Bool";
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
var Int = class extends DataType {
|
|
1297
|
+
constructor(isSigned, bitWidth) {
|
|
1298
|
+
super();
|
|
1299
|
+
this.isSigned = isSigned;
|
|
1300
|
+
this.bitWidth = bitWidth;
|
|
1301
|
+
}
|
|
1302
|
+
get typeId() {
|
|
1303
|
+
return Type.Int;
|
|
1304
|
+
}
|
|
1305
|
+
get [Symbol.toStringTag]() {
|
|
1306
|
+
return "Int";
|
|
1307
|
+
}
|
|
1308
|
+
toString() {
|
|
1309
|
+
return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
var Int8 = class extends Int {
|
|
1313
|
+
constructor() {
|
|
1314
|
+
super(true, 8);
|
|
1315
|
+
}
|
|
1316
|
+
};
|
|
1317
|
+
var Int16 = class extends Int {
|
|
1318
|
+
constructor() {
|
|
1319
|
+
super(true, 16);
|
|
1320
|
+
}
|
|
1321
|
+
};
|
|
1322
|
+
var Int32 = class extends Int {
|
|
1323
|
+
constructor() {
|
|
1324
|
+
super(true, 32);
|
|
1325
|
+
}
|
|
1326
|
+
};
|
|
1327
|
+
var Int64 = class extends Int {
|
|
1328
|
+
constructor() {
|
|
1329
|
+
super(true, 64);
|
|
1330
|
+
}
|
|
1331
|
+
};
|
|
1332
|
+
var Uint8 = class extends Int {
|
|
1333
|
+
constructor() {
|
|
1334
|
+
super(false, 8);
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
var Uint16 = class extends Int {
|
|
1338
|
+
constructor() {
|
|
1339
|
+
super(false, 16);
|
|
1340
|
+
}
|
|
1341
|
+
};
|
|
1342
|
+
var Uint32 = class extends Int {
|
|
1343
|
+
constructor() {
|
|
1344
|
+
super(false, 32);
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
var Uint64 = class extends Int {
|
|
1348
|
+
constructor() {
|
|
1349
|
+
super(false, 64);
|
|
1350
|
+
}
|
|
1351
|
+
};
|
|
1352
|
+
var Precision = {
|
|
1353
|
+
HALF: 16,
|
|
1354
|
+
SINGLE: 32,
|
|
1355
|
+
DOUBLE: 64
|
|
1356
|
+
};
|
|
1357
|
+
var Float = class extends DataType {
|
|
1358
|
+
constructor(precision) {
|
|
1359
|
+
super();
|
|
1360
|
+
this.precision = precision;
|
|
1361
|
+
}
|
|
1362
|
+
get typeId() {
|
|
1363
|
+
return Type.Float;
|
|
1364
|
+
}
|
|
1365
|
+
get [Symbol.toStringTag]() {
|
|
1366
|
+
return "Float";
|
|
1367
|
+
}
|
|
1368
|
+
toString() {
|
|
1369
|
+
return `Float${this.precision}`;
|
|
1370
|
+
}
|
|
1371
|
+
};
|
|
1372
|
+
var Float16 = class extends Float {
|
|
1373
|
+
constructor() {
|
|
1374
|
+
super(Precision.HALF);
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
var Float32 = class extends Float {
|
|
1378
|
+
constructor() {
|
|
1379
|
+
super(Precision.SINGLE);
|
|
1380
|
+
}
|
|
1381
|
+
};
|
|
1382
|
+
var Float64 = class extends Float {
|
|
1383
|
+
constructor() {
|
|
1384
|
+
super(Precision.DOUBLE);
|
|
1385
|
+
}
|
|
1386
|
+
};
|
|
1387
|
+
var Binary = class extends DataType {
|
|
1388
|
+
constructor() {
|
|
1389
|
+
super();
|
|
1390
|
+
}
|
|
1391
|
+
get typeId() {
|
|
1392
|
+
return Type.Binary;
|
|
1393
|
+
}
|
|
1394
|
+
toString() {
|
|
1395
|
+
return "Binary";
|
|
1396
|
+
}
|
|
1397
|
+
get [Symbol.toStringTag]() {
|
|
1398
|
+
return "Binary";
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
var Utf8 = class extends DataType {
|
|
1402
|
+
get typeId() {
|
|
1403
|
+
return Type.Utf8;
|
|
1404
|
+
}
|
|
1405
|
+
get [Symbol.toStringTag]() {
|
|
1406
|
+
return "Utf8";
|
|
1407
|
+
}
|
|
1408
|
+
toString() {
|
|
1409
|
+
return "Utf8";
|
|
1410
|
+
}
|
|
1411
|
+
};
|
|
1412
|
+
var DateUnit = {
|
|
1413
|
+
DAY: 0,
|
|
1414
|
+
MILLISECOND: 1
|
|
1415
|
+
};
|
|
1416
|
+
var Date2 = class extends DataType {
|
|
1417
|
+
constructor(unit) {
|
|
1418
|
+
super();
|
|
1419
|
+
this.unit = unit;
|
|
1420
|
+
}
|
|
1421
|
+
get typeId() {
|
|
1422
|
+
return Type.Date;
|
|
1423
|
+
}
|
|
1424
|
+
get [Symbol.toStringTag]() {
|
|
1425
|
+
return "Date";
|
|
1426
|
+
}
|
|
1427
|
+
toString() {
|
|
1428
|
+
return `Date${(this.unit + 1) * 32}<${DateUnit[this.unit]}>`;
|
|
1429
|
+
}
|
|
1430
|
+
};
|
|
1431
|
+
var DateDay = class extends Date2 {
|
|
1432
|
+
constructor() {
|
|
1433
|
+
super(DateUnit.DAY);
|
|
1434
|
+
}
|
|
1435
|
+
};
|
|
1436
|
+
var DateMillisecond = class extends Date2 {
|
|
1437
|
+
constructor() {
|
|
1438
|
+
super(DateUnit.MILLISECOND);
|
|
1439
|
+
}
|
|
1440
|
+
};
|
|
1441
|
+
var TimeUnit = {
|
|
1442
|
+
SECOND: 1,
|
|
1443
|
+
MILLISECOND: 1e3,
|
|
1444
|
+
MICROSECOND: 1e6,
|
|
1445
|
+
NANOSECOND: 1e9
|
|
1446
|
+
};
|
|
1447
|
+
var Time = class extends DataType {
|
|
1448
|
+
constructor(unit, bitWidth) {
|
|
1449
|
+
super();
|
|
1450
|
+
this.unit = unit;
|
|
1451
|
+
this.bitWidth = bitWidth;
|
|
1452
|
+
}
|
|
1453
|
+
get typeId() {
|
|
1454
|
+
return Type.Time;
|
|
1455
|
+
}
|
|
1456
|
+
toString() {
|
|
1457
|
+
return `Time${this.bitWidth}<${TimeUnit[this.unit]}>`;
|
|
1458
|
+
}
|
|
1459
|
+
get [Symbol.toStringTag]() {
|
|
1460
|
+
return "Time";
|
|
1461
|
+
}
|
|
1462
|
+
};
|
|
1463
|
+
var TimeSecond = class extends Time {
|
|
1464
|
+
constructor() {
|
|
1465
|
+
super(TimeUnit.SECOND, 32);
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
var TimeMillisecond = class extends Time {
|
|
1469
|
+
constructor() {
|
|
1470
|
+
super(TimeUnit.MILLISECOND, 32);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1473
|
+
var Timestamp = class extends DataType {
|
|
1474
|
+
constructor(unit, timezone = null) {
|
|
1475
|
+
super();
|
|
1476
|
+
this.unit = unit;
|
|
1477
|
+
this.timezone = timezone;
|
|
1478
|
+
}
|
|
1479
|
+
get typeId() {
|
|
1480
|
+
return Type.Timestamp;
|
|
1481
|
+
}
|
|
1482
|
+
get [Symbol.toStringTag]() {
|
|
1483
|
+
return "Timestamp";
|
|
1484
|
+
}
|
|
1485
|
+
toString() {
|
|
1486
|
+
return `Timestamp<${TimeUnit[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
var TimestampSecond = class extends Timestamp {
|
|
1490
|
+
constructor(timezone = null) {
|
|
1491
|
+
super(TimeUnit.SECOND, timezone);
|
|
1492
|
+
}
|
|
1493
|
+
};
|
|
1494
|
+
var TimestampMillisecond = class extends Timestamp {
|
|
1495
|
+
constructor(timezone = null) {
|
|
1496
|
+
super(TimeUnit.MILLISECOND, timezone);
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
var TimestampMicrosecond = class extends Timestamp {
|
|
1500
|
+
constructor(timezone = null) {
|
|
1501
|
+
super(TimeUnit.MICROSECOND, timezone);
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
var TimestampNanosecond = class extends Timestamp {
|
|
1505
|
+
constructor(timezone = null) {
|
|
1506
|
+
super(TimeUnit.NANOSECOND, timezone);
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
var IntervalUnit = {
|
|
1510
|
+
DAY_TIME: 0,
|
|
1511
|
+
YEAR_MONTH: 1
|
|
1512
|
+
};
|
|
1513
|
+
var Interval = class extends DataType {
|
|
1514
|
+
constructor(unit) {
|
|
1515
|
+
super();
|
|
1516
|
+
this.unit = unit;
|
|
1517
|
+
}
|
|
1518
|
+
get typeId() {
|
|
1519
|
+
return Type.Interval;
|
|
1520
|
+
}
|
|
1521
|
+
get [Symbol.toStringTag]() {
|
|
1522
|
+
return "Interval";
|
|
1523
|
+
}
|
|
1524
|
+
toString() {
|
|
1525
|
+
return `Interval<${IntervalUnit[this.unit]}>`;
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
var IntervalDayTime = class extends Interval {
|
|
1529
|
+
constructor() {
|
|
1530
|
+
super(IntervalUnit.DAY_TIME);
|
|
1531
|
+
}
|
|
1532
|
+
};
|
|
1533
|
+
var IntervalYearMonth = class extends Interval {
|
|
1534
|
+
constructor() {
|
|
1535
|
+
super(IntervalUnit.YEAR_MONTH);
|
|
1536
|
+
}
|
|
1537
|
+
};
|
|
1538
|
+
var FixedSizeList = class extends DataType {
|
|
1539
|
+
constructor(listSize, child) {
|
|
1540
|
+
super();
|
|
1541
|
+
this.listSize = listSize;
|
|
1542
|
+
this.children = [child];
|
|
1543
|
+
}
|
|
1544
|
+
get typeId() {
|
|
1545
|
+
return Type.FixedSizeList;
|
|
1546
|
+
}
|
|
1547
|
+
get valueType() {
|
|
1548
|
+
return this.children[0].type;
|
|
1549
|
+
}
|
|
1550
|
+
get valueField() {
|
|
1551
|
+
return this.children[0];
|
|
1552
|
+
}
|
|
1553
|
+
get [Symbol.toStringTag]() {
|
|
1554
|
+
return "FixedSizeList";
|
|
1555
|
+
}
|
|
1556
|
+
toString() {
|
|
1557
|
+
return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
|
|
1558
|
+
}
|
|
1559
|
+
};
|
|
1560
|
+
var Struct = class extends DataType {
|
|
1561
|
+
constructor(children) {
|
|
1562
|
+
super();
|
|
1563
|
+
this.children = children;
|
|
1564
|
+
}
|
|
1565
|
+
get typeId() {
|
|
1566
|
+
return Type.Struct;
|
|
1567
|
+
}
|
|
1568
|
+
toString() {
|
|
1569
|
+
return `Struct<{${this.children.map((f) => `${f.name}:${f.type}`).join(", ")}}>`;
|
|
1570
|
+
}
|
|
1571
|
+
get [Symbol.toStringTag]() {
|
|
1572
|
+
return "Struct";
|
|
1573
|
+
}
|
|
1574
|
+
};
|
|
1575
|
+
|
|
1576
|
+
// src/lib/table/arrow-api/get-type-info.ts
|
|
1577
|
+
function getTypeInfo(arrowTypeLike) {
|
|
1578
|
+
return {
|
|
1579
|
+
typeId: arrowTypeLike.typeId,
|
|
1580
|
+
ArrayType: arrowTypeLike.ArrayType,
|
|
1581
|
+
typeName: arrowTypeLike.toString(),
|
|
1582
|
+
typeEnumName: getTypeKey(arrowTypeLike.typeId),
|
|
1583
|
+
precision: arrowTypeLike.precision
|
|
1584
|
+
};
|
|
1585
|
+
}
|
|
1586
|
+
var ReverseType = null;
|
|
1587
|
+
function getTypeKey(typeKey) {
|
|
1588
|
+
if (!ReverseType) {
|
|
1589
|
+
ReverseType = {};
|
|
1590
|
+
for (const key in Type) {
|
|
1591
|
+
ReverseType[Type[key]] = key;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
return ReverseType[typeKey];
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
// src/lib/utils/async-queue.ts
|
|
1598
|
+
var ArrayQueue = class extends Array {
|
|
1599
|
+
enqueue(value) {
|
|
1600
|
+
return this.push(value);
|
|
1601
|
+
}
|
|
1602
|
+
dequeue() {
|
|
1603
|
+
return this.shift();
|
|
1604
|
+
}
|
|
1605
|
+
};
|
|
1606
|
+
var AsyncQueue = class {
|
|
1607
|
+
constructor() {
|
|
1608
|
+
this._values = new ArrayQueue();
|
|
1609
|
+
this._settlers = new ArrayQueue();
|
|
1610
|
+
this._closed = false;
|
|
1611
|
+
}
|
|
1612
|
+
close() {
|
|
1613
|
+
while (this._settlers.length > 0) {
|
|
1614
|
+
this._settlers.dequeue().resolve({
|
|
1615
|
+
done: true
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
this._closed = true;
|
|
1619
|
+
}
|
|
1620
|
+
[Symbol.asyncIterator]() {
|
|
1621
|
+
return this;
|
|
1622
|
+
}
|
|
1623
|
+
enqueue(value) {
|
|
1624
|
+
if (this._closed) {
|
|
1625
|
+
throw new Error("Closed");
|
|
1626
|
+
}
|
|
1627
|
+
if (this._settlers.length > 0) {
|
|
1628
|
+
if (this._values.length > 0) {
|
|
1629
|
+
throw new Error("Illegal internal state");
|
|
1630
|
+
}
|
|
1631
|
+
const settler = this._settlers.dequeue();
|
|
1632
|
+
if (value instanceof Error) {
|
|
1633
|
+
settler.reject(value);
|
|
1634
|
+
} else {
|
|
1635
|
+
settler.resolve({
|
|
1636
|
+
value
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
} else {
|
|
1640
|
+
this._values.enqueue(value);
|
|
1641
|
+
}
|
|
1642
|
+
}
|
|
1643
|
+
next() {
|
|
1644
|
+
if (this._values.length > 0) {
|
|
1645
|
+
const value = this._values.dequeue();
|
|
1646
|
+
if (value instanceof Error) {
|
|
1647
|
+
return Promise.reject(value);
|
|
1648
|
+
}
|
|
1649
|
+
return Promise.resolve({
|
|
1650
|
+
value
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
if (this._closed) {
|
|
1654
|
+
if (this._settlers.length > 0) {
|
|
1655
|
+
throw new Error("Illegal internal state");
|
|
1656
|
+
}
|
|
1657
|
+
return Promise.resolve({
|
|
1658
|
+
done: true
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
return new Promise((resolve, reject) => {
|
|
1662
|
+
this._settlers.enqueue({
|
|
1663
|
+
resolve,
|
|
1664
|
+
reject
|
|
1665
|
+
});
|
|
1666
|
+
});
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
return __toCommonJS(src_exports);
|
|
1670
|
+
})();
|
|
1671
|
+
return __exports__;
|
|
1672
|
+
});
|