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