@loaders.gl/arrow 4.0.2 → 4.0.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/arrow-loader.d.ts +6 -3
- package/dist/arrow-loader.d.ts.map +1 -1
- package/dist/arrow-loader.js +9 -1
- package/dist/arrow-loader.js.map +1 -1
- package/dist/arrow-worker.js +37 -537
- package/dist/arrow-writer.d.ts +2 -2
- package/dist/arrow-writer.d.ts.map +1 -1
- package/dist/arrow-writer.js.map +1 -1
- package/dist/dist.dev.js +1615 -246
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +31 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js +133 -23
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts +2 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson.d.ts.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson.js +4 -0
- package/dist/geoarrow/convert-geoarrow-to-geojson.js.map +1 -1
- package/dist/geoarrow-loader.d.ts +19 -0
- package/dist/geoarrow-loader.d.ts.map +1 -0
- package/dist/geoarrow-loader.js +24 -0
- package/dist/geoarrow-loader.js.map +1 -0
- package/dist/geoarrow-writer.d.ts +9 -0
- package/dist/geoarrow-writer.d.ts.map +1 -0
- package/dist/geoarrow-writer.js +19 -0
- package/dist/geoarrow-writer.js.map +1 -0
- package/dist/index.cjs +508 -284
- package/dist/index.d.ts +9 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -13
- package/dist/index.js.map +1 -1
- package/dist/lib/arrow-table-batch.d.ts.map +1 -1
- package/dist/lib/arrow-table-batch.js.map +1 -1
- package/dist/lib/encode-arrow.d.ts.map +1 -1
- package/dist/lib/encode-arrow.js.map +1 -1
- package/dist/lib/encode-geoarrow.d.ts +15 -0
- package/dist/lib/encode-geoarrow.d.ts.map +1 -0
- package/dist/lib/encode-geoarrow.js +22 -0
- package/dist/lib/encode-geoarrow.js.map +1 -0
- package/dist/{lib → parsers}/parse-arrow-in-batches.d.ts +1 -1
- package/dist/parsers/parse-arrow-in-batches.d.ts.map +1 -0
- package/dist/parsers/parse-arrow-in-batches.js.map +1 -0
- package/dist/parsers/parse-arrow-sync.d.ts +6 -0
- package/dist/parsers/parse-arrow-sync.d.ts.map +1 -0
- package/dist/parsers/parse-arrow-sync.js +26 -0
- package/dist/parsers/parse-arrow-sync.js.map +1 -0
- package/dist/parsers/parse-geoarrow-in-batches.d.ts +6 -0
- package/dist/parsers/parse-geoarrow-in-batches.d.ts.map +1 -0
- package/dist/parsers/parse-geoarrow-in-batches.js +5 -0
- package/dist/parsers/parse-geoarrow-in-batches.js.map +1 -0
- package/dist/parsers/parse-geoarrow-sync.d.ts +6 -0
- package/dist/parsers/parse-geoarrow-sync.d.ts.map +1 -0
- package/dist/parsers/parse-geoarrow-sync.js +14 -0
- package/dist/parsers/parse-geoarrow-sync.js.map +1 -0
- package/dist/schema/convert-arrow-schema.d.ts.map +1 -1
- package/dist/schema/convert-arrow-schema.js +32 -5
- package/dist/schema/convert-arrow-schema.js.map +1 -1
- package/dist/tables/convert-arrow-to-columnar-table.d.ts +8 -0
- package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +1 -0
- package/dist/tables/convert-arrow-to-columnar-table.js +14 -0
- package/dist/tables/convert-arrow-to-columnar-table.js.map +1 -0
- package/dist/tables/convert-arrow-to-geojson-table.d.ts +16 -0
- package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +1 -0
- package/dist/tables/convert-arrow-to-geojson-table.js +33 -0
- package/dist/tables/convert-arrow-to-geojson-table.js.map +1 -0
- package/dist/tables/convert-columnar-to-row-table.d.ts +7 -0
- package/dist/tables/convert-columnar-to-row-table.d.ts.map +1 -0
- package/dist/tables/convert-columnar-to-row-table.js +18 -0
- package/dist/tables/convert-columnar-to-row-table.js.map +1 -0
- package/dist/triangulate-on-worker.d.ts +36 -0
- package/dist/triangulate-on-worker.d.ts.map +1 -0
- package/dist/triangulate-on-worker.js +14 -0
- package/dist/triangulate-on-worker.js.map +1 -0
- package/dist/triangulation-worker.js +880 -0
- package/dist/workers/arrow-worker.js +1 -1
- package/dist/workers/arrow-worker.js.map +1 -1
- package/dist/workers/triangulation-worker-node.d.ts +2 -0
- package/dist/workers/triangulation-worker-node.d.ts.map +1 -0
- package/dist/workers/triangulation-worker-node.js +2 -0
- package/dist/workers/triangulation-worker-node.js.map +1 -0
- package/dist/workers/triangulation-worker.d.ts +2 -0
- package/dist/workers/triangulation-worker.d.ts.map +1 -0
- package/dist/workers/triangulation-worker.js +24 -0
- package/dist/workers/triangulation-worker.js.map +1 -0
- package/package.json +9 -7
- package/src/arrow-loader.ts +25 -3
- package/src/arrow-writer.ts +2 -2
- package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +221 -30
- package/src/geoarrow/convert-geoarrow-to-geojson.ts +6 -2
- package/src/geoarrow-loader.ts +55 -0
- package/src/geoarrow-writer.ts +41 -0
- package/src/index.ts +30 -36
- package/src/lib/arrow-table-batch.ts +3 -0
- package/src/lib/encode-arrow.ts +3 -0
- package/src/lib/encode-geoarrow.ts +45 -0
- package/src/{lib → parsers}/parse-arrow-in-batches.ts +4 -2
- package/src/parsers/parse-arrow-sync.ts +38 -0
- package/src/parsers/parse-geoarrow-in-batches.ts +15 -0
- package/src/parsers/parse-geoarrow-sync.ts +22 -0
- package/src/schema/convert-arrow-schema.ts +32 -7
- package/src/tables/convert-arrow-to-columnar-table.ts +29 -0
- package/src/tables/convert-arrow-to-geojson-table.ts +54 -0
- package/src/tables/convert-columnar-to-row-table.ts +29 -0
- package/src/triangulate-on-worker.ts +47 -0
- package/src/workers/arrow-worker.ts +1 -1
- package/src/workers/triangulation-worker-node.ts +4 -0
- package/src/workers/triangulation-worker.ts +39 -0
- package/dist/lib/parse-arrow-in-batches.d.ts.map +0 -1
- package/dist/lib/parse-arrow-in-batches.js.map +0 -1
- package/dist/lib/parse-arrow-sync.d.ts +0 -5
- package/dist/lib/parse-arrow-sync.d.ts.map +0 -1
- package/dist/lib/parse-arrow-sync.js +0 -21
- package/dist/lib/parse-arrow-sync.js.map +0 -1
- package/dist/tables/convert-arrow-to-table.d.ts +0 -21
- package/dist/tables/convert-arrow-to-table.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-table.js +0 -37
- package/dist/tables/convert-arrow-to-table.js.map +0 -1
- package/src/lib/parse-arrow-sync.ts +0 -35
- package/src/tables/convert-arrow-to-table.ts +0 -68
- /package/dist/{lib → parsers}/parse-arrow-in-batches.js +0 -0
package/dist/arrow-worker.js
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
+
// ../worker-utils/src/lib/node/worker_threads-browser.ts
|
|
10
|
+
var parentPort = null;
|
|
11
|
+
|
|
9
12
|
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
10
13
|
function getTransferList(object, recursive = true, transfers) {
|
|
11
14
|
const transfersSet = transfers || /* @__PURE__ */ new Set();
|
|
@@ -43,19 +46,6 @@
|
|
|
43
46
|
|
|
44
47
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
45
48
|
async function getParentPort() {
|
|
46
|
-
let parentPort;
|
|
47
|
-
try {
|
|
48
|
-
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
49
|
-
parentPort = globalThis.parentPort;
|
|
50
|
-
} catch {
|
|
51
|
-
try {
|
|
52
|
-
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
53
|
-
const workerThreads = await globalThis.workerThreadsPromise;
|
|
54
|
-
parentPort = workerThreads.parentPort;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
console.error(error.message);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
49
|
return parentPort;
|
|
60
50
|
}
|
|
61
51
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
@@ -213,375 +203,6 @@
|
|
|
213
203
|
return await parser(data, { ...options }, context, loader);
|
|
214
204
|
}
|
|
215
205
|
|
|
216
|
-
// ../schema/src/lib/table/batches/base-table-batch-aggregator.ts
|
|
217
|
-
var DEFAULT_ROW_COUNT = 100;
|
|
218
|
-
var BaseTableBatchAggregator = class {
|
|
219
|
-
constructor(schema, options) {
|
|
220
|
-
this.length = 0;
|
|
221
|
-
this.rows = null;
|
|
222
|
-
this.cursor = 0;
|
|
223
|
-
this._headers = [];
|
|
224
|
-
this.options = options;
|
|
225
|
-
this.schema = schema;
|
|
226
|
-
if (!Array.isArray(schema)) {
|
|
227
|
-
this._headers = [];
|
|
228
|
-
for (const key in schema) {
|
|
229
|
-
this._headers[schema[key].index] = schema[key].name;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
rowCount() {
|
|
234
|
-
return this.length;
|
|
235
|
-
}
|
|
236
|
-
addArrayRow(row, cursor) {
|
|
237
|
-
if (Number.isFinite(cursor)) {
|
|
238
|
-
this.cursor = cursor;
|
|
239
|
-
}
|
|
240
|
-
this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
|
|
241
|
-
this.rows[this.length] = row;
|
|
242
|
-
this.length++;
|
|
243
|
-
}
|
|
244
|
-
addObjectRow(row, cursor) {
|
|
245
|
-
if (Number.isFinite(cursor)) {
|
|
246
|
-
this.cursor = cursor;
|
|
247
|
-
}
|
|
248
|
-
this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);
|
|
249
|
-
this.rows[this.length] = row;
|
|
250
|
-
this.length++;
|
|
251
|
-
}
|
|
252
|
-
getBatch() {
|
|
253
|
-
let rows = this.rows;
|
|
254
|
-
if (!rows) {
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
rows = rows.slice(0, this.length);
|
|
258
|
-
this.rows = null;
|
|
259
|
-
const batch = {
|
|
260
|
-
shape: this.options.shape,
|
|
261
|
-
batchType: "data",
|
|
262
|
-
data: rows,
|
|
263
|
-
length: this.length,
|
|
264
|
-
schema: this.schema,
|
|
265
|
-
cursor: this.cursor
|
|
266
|
-
};
|
|
267
|
-
return batch;
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
// ../schema/src/lib/table/simple-table/row-utils.ts
|
|
272
|
-
function convertToObjectRow(arrayRow, headers) {
|
|
273
|
-
if (!arrayRow) {
|
|
274
|
-
throw new Error("null row");
|
|
275
|
-
}
|
|
276
|
-
if (!headers) {
|
|
277
|
-
throw new Error("no headers");
|
|
278
|
-
}
|
|
279
|
-
const objectRow = {};
|
|
280
|
-
for (let i = 0; i < headers.length; i++) {
|
|
281
|
-
objectRow[headers[i]] = arrayRow[i];
|
|
282
|
-
}
|
|
283
|
-
return objectRow;
|
|
284
|
-
}
|
|
285
|
-
function convertToArrayRow(objectRow, headers) {
|
|
286
|
-
if (!objectRow) {
|
|
287
|
-
throw new Error("null row");
|
|
288
|
-
}
|
|
289
|
-
if (!headers) {
|
|
290
|
-
throw new Error("no headers");
|
|
291
|
-
}
|
|
292
|
-
const arrayRow = new Array(headers.length);
|
|
293
|
-
for (let i = 0; i < headers.length; i++) {
|
|
294
|
-
arrayRow[i] = objectRow[headers[i]];
|
|
295
|
-
}
|
|
296
|
-
return arrayRow;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
// ../schema/src/lib/table/batches/row-table-batch-aggregator.ts
|
|
300
|
-
var DEFAULT_ROW_COUNT2 = 100;
|
|
301
|
-
var RowTableBatchAggregator = class {
|
|
302
|
-
constructor(schema, options) {
|
|
303
|
-
this.length = 0;
|
|
304
|
-
this.objectRows = null;
|
|
305
|
-
this.arrayRows = null;
|
|
306
|
-
this.cursor = 0;
|
|
307
|
-
this._headers = [];
|
|
308
|
-
this.options = options;
|
|
309
|
-
this.schema = schema;
|
|
310
|
-
if (!Array.isArray(schema)) {
|
|
311
|
-
this._headers = [];
|
|
312
|
-
for (const key in schema) {
|
|
313
|
-
this._headers[schema[key].index] = schema[key].name;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
rowCount() {
|
|
318
|
-
return this.length;
|
|
319
|
-
}
|
|
320
|
-
addArrayRow(row, cursor) {
|
|
321
|
-
if (Number.isFinite(cursor)) {
|
|
322
|
-
this.cursor = cursor;
|
|
323
|
-
}
|
|
324
|
-
switch (this.options.shape) {
|
|
325
|
-
case "object-row-table":
|
|
326
|
-
const rowObject = convertToObjectRow(row, this._headers);
|
|
327
|
-
this.addObjectRow(rowObject, cursor);
|
|
328
|
-
break;
|
|
329
|
-
case "array-row-table":
|
|
330
|
-
this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT2);
|
|
331
|
-
this.arrayRows[this.length] = row;
|
|
332
|
-
this.length++;
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
addObjectRow(row, cursor) {
|
|
337
|
-
if (Number.isFinite(cursor)) {
|
|
338
|
-
this.cursor = cursor;
|
|
339
|
-
}
|
|
340
|
-
switch (this.options.shape) {
|
|
341
|
-
case "array-row-table":
|
|
342
|
-
const rowArray = convertToArrayRow(row, this._headers);
|
|
343
|
-
this.addArrayRow(rowArray, cursor);
|
|
344
|
-
break;
|
|
345
|
-
case "object-row-table":
|
|
346
|
-
this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT2);
|
|
347
|
-
this.objectRows[this.length] = row;
|
|
348
|
-
this.length++;
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
getBatch() {
|
|
353
|
-
let rows = this.arrayRows || this.objectRows;
|
|
354
|
-
if (!rows) {
|
|
355
|
-
return null;
|
|
356
|
-
}
|
|
357
|
-
rows = rows.slice(0, this.length);
|
|
358
|
-
this.arrayRows = null;
|
|
359
|
-
this.objectRows = null;
|
|
360
|
-
return {
|
|
361
|
-
shape: this.options.shape,
|
|
362
|
-
batchType: "data",
|
|
363
|
-
data: rows,
|
|
364
|
-
length: this.length,
|
|
365
|
-
schema: this.schema,
|
|
366
|
-
cursor: this.cursor
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
// ../schema/src/lib/table/batches/columnar-table-batch-aggregator.ts
|
|
372
|
-
var DEFAULT_ROW_COUNT3 = 100;
|
|
373
|
-
var ColumnarTableBatchAggregator = class {
|
|
374
|
-
constructor(schema, options) {
|
|
375
|
-
this.length = 0;
|
|
376
|
-
this.allocated = 0;
|
|
377
|
-
this.columns = {};
|
|
378
|
-
this.schema = schema;
|
|
379
|
-
this._reallocateColumns();
|
|
380
|
-
}
|
|
381
|
-
rowCount() {
|
|
382
|
-
return this.length;
|
|
383
|
-
}
|
|
384
|
-
addArrayRow(row) {
|
|
385
|
-
this._reallocateColumns();
|
|
386
|
-
let i = 0;
|
|
387
|
-
for (const fieldName in this.columns) {
|
|
388
|
-
this.columns[fieldName][this.length] = row[i++];
|
|
389
|
-
}
|
|
390
|
-
this.length++;
|
|
391
|
-
}
|
|
392
|
-
addObjectRow(row) {
|
|
393
|
-
this._reallocateColumns();
|
|
394
|
-
for (const fieldName in row) {
|
|
395
|
-
this.columns[fieldName][this.length] = row[fieldName];
|
|
396
|
-
}
|
|
397
|
-
this.length++;
|
|
398
|
-
}
|
|
399
|
-
getBatch() {
|
|
400
|
-
this._pruneColumns();
|
|
401
|
-
const columns = Array.isArray(this.schema) ? this.columns : {};
|
|
402
|
-
if (!Array.isArray(this.schema)) {
|
|
403
|
-
for (const fieldName in this.schema) {
|
|
404
|
-
const field = this.schema[fieldName];
|
|
405
|
-
columns[field.name] = this.columns[field.index];
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
this.columns = {};
|
|
409
|
-
const batch = {
|
|
410
|
-
shape: "columnar-table",
|
|
411
|
-
batchType: "data",
|
|
412
|
-
data: columns,
|
|
413
|
-
schema: this.schema,
|
|
414
|
-
length: this.length
|
|
415
|
-
};
|
|
416
|
-
return batch;
|
|
417
|
-
}
|
|
418
|
-
// HELPERS
|
|
419
|
-
_reallocateColumns() {
|
|
420
|
-
if (this.length < this.allocated) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
this.allocated = this.allocated > 0 ? this.allocated *= 2 : DEFAULT_ROW_COUNT3;
|
|
424
|
-
this.columns = {};
|
|
425
|
-
for (const fieldName in this.schema) {
|
|
426
|
-
const field = this.schema[fieldName];
|
|
427
|
-
const ArrayType = field.type || Float32Array;
|
|
428
|
-
const oldColumn = this.columns[field.index];
|
|
429
|
-
if (oldColumn && ArrayBuffer.isView(oldColumn)) {
|
|
430
|
-
const typedArray = new ArrayType(this.allocated);
|
|
431
|
-
typedArray.set(oldColumn);
|
|
432
|
-
this.columns[field.index] = typedArray;
|
|
433
|
-
} else if (oldColumn) {
|
|
434
|
-
oldColumn.length = this.allocated;
|
|
435
|
-
this.columns[field.index] = oldColumn;
|
|
436
|
-
} else {
|
|
437
|
-
this.columns[field.index] = new ArrayType(this.allocated);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
_pruneColumns() {
|
|
442
|
-
for (const [columnName, column] of Object.entries(this.columns)) {
|
|
443
|
-
this.columns[columnName] = column.slice(0, this.length);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
// ../schema/src/lib/table/batches/table-batch-builder.ts
|
|
449
|
-
var DEFAULT_OPTIONS = {
|
|
450
|
-
shape: "array-row-table",
|
|
451
|
-
batchSize: "auto",
|
|
452
|
-
batchDebounceMs: 0,
|
|
453
|
-
limit: 0,
|
|
454
|
-
_limitMB: 0
|
|
455
|
-
};
|
|
456
|
-
var ERR_MESSAGE = "TableBatchBuilder";
|
|
457
|
-
var TableBatchBuilder = class {
|
|
458
|
-
constructor(schema, options) {
|
|
459
|
-
this.aggregator = null;
|
|
460
|
-
this.batchCount = 0;
|
|
461
|
-
this.bytesUsed = 0;
|
|
462
|
-
this.isChunkComplete = false;
|
|
463
|
-
this.lastBatchEmittedMs = Date.now();
|
|
464
|
-
this.totalLength = 0;
|
|
465
|
-
this.totalBytes = 0;
|
|
466
|
-
this.rowBytes = 0;
|
|
467
|
-
this.schema = schema;
|
|
468
|
-
this.options = { ...DEFAULT_OPTIONS, ...options };
|
|
469
|
-
}
|
|
470
|
-
limitReached() {
|
|
471
|
-
if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {
|
|
472
|
-
return true;
|
|
473
|
-
}
|
|
474
|
-
if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {
|
|
475
|
-
return true;
|
|
476
|
-
}
|
|
477
|
-
return false;
|
|
478
|
-
}
|
|
479
|
-
/** @deprecated Use addArrayRow or addObjectRow */
|
|
480
|
-
addRow(row) {
|
|
481
|
-
if (this.limitReached()) {
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
this.totalLength++;
|
|
485
|
-
this.rowBytes = this.rowBytes || this._estimateRowMB(row);
|
|
486
|
-
this.totalBytes += this.rowBytes;
|
|
487
|
-
if (Array.isArray(row)) {
|
|
488
|
-
this.addArrayRow(row);
|
|
489
|
-
} else {
|
|
490
|
-
this.addObjectRow(row);
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
/** Add one row to the batch */
|
|
494
|
-
addArrayRow(row) {
|
|
495
|
-
if (!this.aggregator) {
|
|
496
|
-
const TableBatchType = this._getTableBatchType();
|
|
497
|
-
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
498
|
-
}
|
|
499
|
-
this.aggregator.addArrayRow(row);
|
|
500
|
-
}
|
|
501
|
-
/** Add one row to the batch */
|
|
502
|
-
addObjectRow(row) {
|
|
503
|
-
if (!this.aggregator) {
|
|
504
|
-
const TableBatchType = this._getTableBatchType();
|
|
505
|
-
this.aggregator = new TableBatchType(this.schema, this.options);
|
|
506
|
-
}
|
|
507
|
-
this.aggregator.addObjectRow(row);
|
|
508
|
-
}
|
|
509
|
-
/** Mark an incoming raw memory chunk has completed */
|
|
510
|
-
chunkComplete(chunk) {
|
|
511
|
-
if (chunk instanceof ArrayBuffer) {
|
|
512
|
-
this.bytesUsed += chunk.byteLength;
|
|
513
|
-
}
|
|
514
|
-
if (typeof chunk === "string") {
|
|
515
|
-
this.bytesUsed += chunk.length;
|
|
516
|
-
}
|
|
517
|
-
this.isChunkComplete = true;
|
|
518
|
-
}
|
|
519
|
-
getFullBatch(options) {
|
|
520
|
-
return this._isFull() ? this._getBatch(options) : null;
|
|
521
|
-
}
|
|
522
|
-
getFinalBatch(options) {
|
|
523
|
-
return this._getBatch(options);
|
|
524
|
-
}
|
|
525
|
-
// INTERNAL
|
|
526
|
-
_estimateRowMB(row) {
|
|
527
|
-
return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
|
|
528
|
-
}
|
|
529
|
-
_isFull() {
|
|
530
|
-
if (!this.aggregator || this.aggregator.rowCount() === 0) {
|
|
531
|
-
return false;
|
|
532
|
-
}
|
|
533
|
-
if (this.options.batchSize === "auto") {
|
|
534
|
-
if (!this.isChunkComplete) {
|
|
535
|
-
return false;
|
|
536
|
-
}
|
|
537
|
-
} else if (this.options.batchSize > this.aggregator.rowCount()) {
|
|
538
|
-
return false;
|
|
539
|
-
}
|
|
540
|
-
if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {
|
|
541
|
-
return false;
|
|
542
|
-
}
|
|
543
|
-
this.isChunkComplete = false;
|
|
544
|
-
this.lastBatchEmittedMs = Date.now();
|
|
545
|
-
return true;
|
|
546
|
-
}
|
|
547
|
-
/**
|
|
548
|
-
* bytesUsed can be set via chunkComplete or via getBatch*
|
|
549
|
-
*/
|
|
550
|
-
_getBatch(options) {
|
|
551
|
-
if (!this.aggregator) {
|
|
552
|
-
return null;
|
|
553
|
-
}
|
|
554
|
-
if (options?.bytesUsed) {
|
|
555
|
-
this.bytesUsed = options.bytesUsed;
|
|
556
|
-
}
|
|
557
|
-
const normalizedBatch = this.aggregator.getBatch();
|
|
558
|
-
normalizedBatch.count = this.batchCount;
|
|
559
|
-
normalizedBatch.bytesUsed = this.bytesUsed;
|
|
560
|
-
Object.assign(normalizedBatch, options);
|
|
561
|
-
this.batchCount++;
|
|
562
|
-
this.aggregator = null;
|
|
563
|
-
return normalizedBatch;
|
|
564
|
-
}
|
|
565
|
-
_getTableBatchType() {
|
|
566
|
-
switch (this.options.shape) {
|
|
567
|
-
case "row-table":
|
|
568
|
-
return BaseTableBatchAggregator;
|
|
569
|
-
case "array-row-table":
|
|
570
|
-
case "object-row-table":
|
|
571
|
-
return RowTableBatchAggregator;
|
|
572
|
-
case "columnar-table":
|
|
573
|
-
return ColumnarTableBatchAggregator;
|
|
574
|
-
case "arrow-table":
|
|
575
|
-
if (!TableBatchBuilder.ArrowBatch) {
|
|
576
|
-
throw new Error(ERR_MESSAGE);
|
|
577
|
-
}
|
|
578
|
-
return TableBatchBuilder.ArrowBatch;
|
|
579
|
-
default:
|
|
580
|
-
throw new Error(ERR_MESSAGE);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
};
|
|
584
|
-
|
|
585
206
|
// ../schema/src/lib/table/simple-table/table-accessors.ts
|
|
586
207
|
function getTableLength(table) {
|
|
587
208
|
switch (table.shape) {
|
|
@@ -952,30 +573,6 @@
|
|
|
952
573
|
};
|
|
953
574
|
}
|
|
954
575
|
|
|
955
|
-
// src/arrow-loader.ts
|
|
956
|
-
var VERSION = true ? "4.0.2" : "latest";
|
|
957
|
-
var ArrowLoader = {
|
|
958
|
-
name: "Apache Arrow",
|
|
959
|
-
id: "arrow",
|
|
960
|
-
module: "arrow",
|
|
961
|
-
version: VERSION,
|
|
962
|
-
// worker: true,
|
|
963
|
-
category: "table",
|
|
964
|
-
extensions: ["arrow", "feather"],
|
|
965
|
-
mimeTypes: [
|
|
966
|
-
"application/vnd.apache.arrow.file",
|
|
967
|
-
"application/vnd.apache.arrow.stream",
|
|
968
|
-
"application/octet-stream"
|
|
969
|
-
],
|
|
970
|
-
binary: true,
|
|
971
|
-
tests: ["ARROW"],
|
|
972
|
-
options: {
|
|
973
|
-
arrow: {
|
|
974
|
-
shape: "columnar-table"
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
|
|
979
576
|
// ../../node_modules/tslib/tslib.es6.mjs
|
|
980
577
|
function __rest(s, e) {
|
|
981
578
|
var t = {};
|
|
@@ -4771,63 +4368,6 @@
|
|
|
4771
4368
|
});
|
|
4772
4369
|
}
|
|
4773
4370
|
};
|
|
4774
|
-
function makeVector(init) {
|
|
4775
|
-
if (init) {
|
|
4776
|
-
if (init instanceof Data) {
|
|
4777
|
-
return new Vector([init]);
|
|
4778
|
-
}
|
|
4779
|
-
if (init instanceof Vector) {
|
|
4780
|
-
return new Vector(init.data);
|
|
4781
|
-
}
|
|
4782
|
-
if (init.type instanceof DataType) {
|
|
4783
|
-
return new Vector([makeData(init)]);
|
|
4784
|
-
}
|
|
4785
|
-
if (Array.isArray(init)) {
|
|
4786
|
-
return new Vector(init.flatMap((v) => unwrapInputs(v)));
|
|
4787
|
-
}
|
|
4788
|
-
if (ArrayBuffer.isView(init)) {
|
|
4789
|
-
if (init instanceof DataView) {
|
|
4790
|
-
init = new Uint8Array(init.buffer);
|
|
4791
|
-
}
|
|
4792
|
-
const props = { offset: 0, length: init.length, nullCount: 0, data: init };
|
|
4793
|
-
if (init instanceof Int8Array) {
|
|
4794
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Int8() }))]);
|
|
4795
|
-
}
|
|
4796
|
-
if (init instanceof Int16Array) {
|
|
4797
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Int16() }))]);
|
|
4798
|
-
}
|
|
4799
|
-
if (init instanceof Int32Array) {
|
|
4800
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Int32() }))]);
|
|
4801
|
-
}
|
|
4802
|
-
if (init instanceof BigInt64Array) {
|
|
4803
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Int64() }))]);
|
|
4804
|
-
}
|
|
4805
|
-
if (init instanceof Uint8Array || init instanceof Uint8ClampedArray) {
|
|
4806
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Uint8() }))]);
|
|
4807
|
-
}
|
|
4808
|
-
if (init instanceof Uint16Array) {
|
|
4809
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Uint16() }))]);
|
|
4810
|
-
}
|
|
4811
|
-
if (init instanceof Uint32Array) {
|
|
4812
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Uint32() }))]);
|
|
4813
|
-
}
|
|
4814
|
-
if (init instanceof BigUint64Array) {
|
|
4815
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Uint64() }))]);
|
|
4816
|
-
}
|
|
4817
|
-
if (init instanceof Float32Array) {
|
|
4818
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Float32() }))]);
|
|
4819
|
-
}
|
|
4820
|
-
if (init instanceof Float64Array) {
|
|
4821
|
-
return new Vector([makeData(Object.assign(Object.assign({}, props), { type: new Float64() }))]);
|
|
4822
|
-
}
|
|
4823
|
-
throw new Error("Unrecognized input");
|
|
4824
|
-
}
|
|
4825
|
-
}
|
|
4826
|
-
throw new Error("Unrecognized input");
|
|
4827
|
-
}
|
|
4828
|
-
function unwrapInputs(x) {
|
|
4829
|
-
return x instanceof Data ? [x] : x instanceof Vector ? x.data : makeVector(x).data;
|
|
4830
|
-
}
|
|
4831
4371
|
|
|
4832
4372
|
// ../../node_modules/apache-arrow/builder/valid.mjs
|
|
4833
4373
|
function createIsValidFunction(nullValues) {
|
|
@@ -12342,13 +11882,7 @@ return true;`);
|
|
|
12342
11882
|
RecordBatchFileWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12343
11883
|
RecordBatchStreamWriter["throughDOM"] = recordBatchWriterThroughDOMStream;
|
|
12344
11884
|
|
|
12345
|
-
// src/tables/convert-arrow-to-table.ts
|
|
12346
|
-
function convertApacheArrowToArrowTable(arrowTable) {
|
|
12347
|
-
return {
|
|
12348
|
-
shape: "arrow-table",
|
|
12349
|
-
data: arrowTable
|
|
12350
|
-
};
|
|
12351
|
-
}
|
|
11885
|
+
// src/tables/convert-arrow-to-columnar-table.ts
|
|
12352
11886
|
function convertArrowToColumnarTable(table) {
|
|
12353
11887
|
const arrowTable = table.data;
|
|
12354
11888
|
const columnarTable = {};
|
|
@@ -12363,25 +11897,28 @@ return true;`);
|
|
|
12363
11897
|
};
|
|
12364
11898
|
}
|
|
12365
11899
|
|
|
12366
|
-
// src/
|
|
11900
|
+
// src/parsers/parse-arrow-sync.ts
|
|
12367
11901
|
function parseArrowSync(arrayBuffer, options) {
|
|
12368
11902
|
const apacheArrowTable = tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
12369
|
-
const arrowTable =
|
|
12370
|
-
const shape = options?.
|
|
11903
|
+
const arrowTable = { shape: "arrow-table", data: apacheArrowTable };
|
|
11904
|
+
const shape = options?.shape || "arrow-table";
|
|
12371
11905
|
switch (shape) {
|
|
12372
11906
|
case "arrow-table":
|
|
12373
11907
|
return arrowTable;
|
|
12374
11908
|
case "columnar-table":
|
|
12375
11909
|
return convertArrowToColumnarTable(arrowTable);
|
|
12376
11910
|
case "object-row-table":
|
|
12377
|
-
|
|
11911
|
+
let columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
12378
11912
|
return convertTable(columnarTable, "object-row-table");
|
|
11913
|
+
case "array-row-table":
|
|
11914
|
+
columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
11915
|
+
return convertTable(columnarTable, "array-row-table");
|
|
12379
11916
|
default:
|
|
12380
11917
|
throw new Error(shape);
|
|
12381
11918
|
}
|
|
12382
11919
|
}
|
|
12383
11920
|
|
|
12384
|
-
// src/
|
|
11921
|
+
// src/parsers/parse-arrow-in-batches.ts
|
|
12385
11922
|
function parseArrowInBatches(asyncIterator) {
|
|
12386
11923
|
async function* makeArrowAsyncIterator() {
|
|
12387
11924
|
const readers = RecordBatchReader.readAll(asyncIterator);
|
|
@@ -12401,73 +11938,36 @@ return true;`);
|
|
|
12401
11938
|
return makeArrowAsyncIterator();
|
|
12402
11939
|
}
|
|
12403
11940
|
|
|
12404
|
-
// src/
|
|
12405
|
-
var
|
|
12406
|
-
|
|
12407
|
-
|
|
12408
|
-
|
|
12409
|
-
|
|
12410
|
-
|
|
12411
|
-
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
|
|
12416
|
-
|
|
12417
|
-
|
|
12418
|
-
|
|
12419
|
-
|
|
12420
|
-
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
|
|
12424
|
-
batchType: "data",
|
|
12425
|
-
data: new Table([recordBatch]),
|
|
12426
|
-
length: batch.length
|
|
12427
|
-
};
|
|
11941
|
+
// src/arrow-loader.ts
|
|
11942
|
+
var VERSION = true ? "4.0.4" : "latest";
|
|
11943
|
+
var ArrowWorkerLoader = {
|
|
11944
|
+
name: "Apache Arrow",
|
|
11945
|
+
id: "arrow",
|
|
11946
|
+
module: "arrow",
|
|
11947
|
+
version: VERSION,
|
|
11948
|
+
// worker: true,
|
|
11949
|
+
category: "table",
|
|
11950
|
+
extensions: ["arrow", "feather"],
|
|
11951
|
+
mimeTypes: [
|
|
11952
|
+
"application/vnd.apache.arrow.file",
|
|
11953
|
+
"application/vnd.apache.arrow.stream",
|
|
11954
|
+
"application/octet-stream"
|
|
11955
|
+
],
|
|
11956
|
+
binary: true,
|
|
11957
|
+
tests: ["ARROW"],
|
|
11958
|
+
options: {
|
|
11959
|
+
arrow: {
|
|
11960
|
+
shape: "columnar-table"
|
|
12428
11961
|
}
|
|
12429
|
-
return null;
|
|
12430
11962
|
}
|
|
12431
11963
|
};
|
|
12432
|
-
|
|
12433
|
-
|
|
12434
|
-
|
|
12435
|
-
|
|
12436
|
-
if (field.type === Float32Array) {
|
|
12437
|
-
const metadata = /* @__PURE__ */ new Map();
|
|
12438
|
-
const arrowField = new Field2(field.name, new Float32(), field.nullable, metadata);
|
|
12439
|
-
arrowFields.push(arrowField);
|
|
12440
|
-
}
|
|
12441
|
-
}
|
|
12442
|
-
if (arrowFields.length === 0) {
|
|
12443
|
-
throw new Error("No arrow convertible fields");
|
|
12444
|
-
}
|
|
12445
|
-
return new Schema2(arrowFields);
|
|
12446
|
-
}
|
|
12447
|
-
function getArrowVectors(arrowSchema, data) {
|
|
12448
|
-
const arrowVectors = [];
|
|
12449
|
-
for (const field of arrowSchema.fields) {
|
|
12450
|
-
const vector = data[field.name];
|
|
12451
|
-
if (vector instanceof Float32Array) {
|
|
12452
|
-
const arrowVector = makeVector(vector);
|
|
12453
|
-
arrowVectors.push(arrowVector);
|
|
12454
|
-
}
|
|
12455
|
-
}
|
|
12456
|
-
if (arrowSchema.fields.length !== arrowVectors.length) {
|
|
12457
|
-
throw new Error("Some columns not arrow convertible");
|
|
12458
|
-
}
|
|
12459
|
-
return arrowVectors;
|
|
12460
|
-
}
|
|
12461
|
-
|
|
12462
|
-
// src/index.ts
|
|
12463
|
-
TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
|
|
12464
|
-
var ArrowLoader2 = {
|
|
12465
|
-
...ArrowLoader,
|
|
12466
|
-
parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options),
|
|
12467
|
-
parseSync: parseArrowSync,
|
|
11964
|
+
var ArrowLoader = {
|
|
11965
|
+
...ArrowWorkerLoader,
|
|
11966
|
+
parse: async (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),
|
|
11967
|
+
parseSync: (arraybuffer, options) => parseArrowSync(arraybuffer, options?.arrow),
|
|
12468
11968
|
parseInBatches: parseArrowInBatches
|
|
12469
11969
|
};
|
|
12470
11970
|
|
|
12471
11971
|
// src/workers/arrow-worker.ts
|
|
12472
|
-
createLoaderWorker(
|
|
11972
|
+
createLoaderWorker(ArrowLoader);
|
|
12473
11973
|
})();
|
package/dist/arrow-writer.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WriterWithEncoder, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import { ColumnarTable } from './lib/encode-arrow';
|
|
3
3
|
type ArrowWriterOptions = WriterOptions & {
|
|
4
4
|
arrow?: {};
|
|
5
5
|
};
|
|
6
6
|
/** Apache Arrow writer */
|
|
7
|
-
export declare const ArrowWriter:
|
|
7
|
+
export declare const ArrowWriter: WriterWithEncoder<ColumnarTable, never, ArrowWriterOptions>;
|
|
8
8
|
export {};
|
|
9
9
|
//# sourceMappingURL=arrow-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-writer.d.ts","sourceRoot":"","sources":["../src/arrow-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"arrow-writer.d.ts","sourceRoot":"","sources":["../src/arrow-writer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAOjD,KAAK,kBAAkB,GAAG,aAAa,GAAG;IACxC,KAAK,CAAC,EAAE,EAAE,CAAC;CACZ,CAAC;AAEF,0BAA0B;AAC1B,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,aAAa,EAAE,KAAK,EAAE,kBAAkB,CAmBnF,CAAC"}
|
package/dist/arrow-writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-writer.js","names":["encodeArrowSync","VERSION","__VERSION__","ArrowWriter","name","id","module","version","extensions","mimeTypes","binary","options","encode","encodeArrow","data","encodeSync"],"sources":["../src/arrow-writer.ts"],"sourcesContent":["// import type {} from '@loaders.gl/loader-utils';\n\nimport type {
|
|
1
|
+
{"version":3,"file":"arrow-writer.js","names":["encodeArrowSync","VERSION","__VERSION__","ArrowWriter","name","id","module","version","extensions","mimeTypes","binary","options","encode","encodeArrow","data","encodeSync"],"sources":["../src/arrow-writer.ts"],"sourcesContent":["// import type {} from '@loaders.gl/loader-utils';\n\nimport type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';\nimport {ColumnarTable} from './lib/encode-arrow';\nimport {encodeArrowSync} from './lib/encode-arrow';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\ntype ArrowWriterOptions = WriterOptions & {\n arrow?: {};\n};\n\n/** Apache Arrow writer */\nexport const ArrowWriter: WriterWithEncoder<ColumnarTable, never, ArrowWriterOptions> = {\n name: 'Apache Arrow',\n id: 'arrow',\n module: 'arrow',\n version: VERSION,\n extensions: ['arrow', 'feather'],\n mimeTypes: [\n 'application/vnd.apache.arrow.file',\n 'application/vnd.apache.arrow.stream',\n 'application/octet-stream'\n ],\n binary: true,\n options: {},\n encode: async function encodeArrow(data, options?): Promise<ArrayBuffer> {\n return encodeArrowSync(data);\n },\n encodeSync(data, options?) {\n return encodeArrowSync(data);\n }\n};\n"],"mappings":"SAIQA,eAAe;AAIvB,MAAMC,OAAO,GAAG,OAAOC,WAAW,KAAK,WAAW,GAAGA,WAAW,GAAG,QAAQ;AAO3E,OAAO,MAAMC,WAAwE,GAAG;EACtFC,IAAI,EAAE,cAAc;EACpBC,EAAE,EAAE,OAAO;EACXC,MAAM,EAAE,OAAO;EACfC,OAAO,EAAEN,OAAO;EAChBO,UAAU,EAAE,CAAC,OAAO,EAAE,SAAS,CAAC;EAChCC,SAAS,EAAE,CACT,mCAAmC,EACnC,qCAAqC,EACrC,0BAA0B,CAC3B;EACDC,MAAM,EAAE,IAAI;EACZC,OAAO,EAAE,CAAC,CAAC;EACXC,MAAM,EAAE,eAAeC,WAAWA,CAACC,IAAI,EAAEH,OAAQ,EAAwB;IACvE,OAAOX,eAAe,CAACc,IAAI,CAAC;EAC9B,CAAC;EACDC,UAAUA,CAACD,IAAI,EAAEH,OAAQ,EAAE;IACzB,OAAOX,eAAe,CAACc,IAAI,CAAC;EAC9B;AACF,CAAC"}
|