@loaders.gl/arrow 4.0.0-alpha.23 → 4.0.0-alpha.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/arrow-worker.js +9706 -9890
  2. package/dist/dist.min.js +6271 -6424
  3. package/dist/es5/arrow-loader.js +1 -1
  4. package/dist/es5/arrow-writer.js +1 -1
  5. package/dist/es5/index.js +3 -3
  6. package/dist/es5/index.js.map +1 -1
  7. package/dist/es5/lib/arrow-table-batch.js +2 -2
  8. package/dist/es5/lib/arrow-table-batch.js.map +1 -1
  9. package/dist/es5/lib/convert-table.js +57 -0
  10. package/dist/es5/lib/convert-table.js.map +1 -0
  11. package/dist/es5/lib/parse-arrow-in-batches.js +43 -48
  12. package/dist/es5/lib/parse-arrow-in-batches.js.map +1 -1
  13. package/dist/es5/lib/parse-arrow-sync.js +11 -37
  14. package/dist/es5/lib/parse-arrow-sync.js.map +1 -1
  15. package/dist/esm/arrow-loader.js +1 -1
  16. package/dist/esm/arrow-writer.js +1 -1
  17. package/dist/esm/index.js +2 -2
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/lib/arrow-table-batch.js +1 -1
  20. package/dist/esm/lib/arrow-table-batch.js.map +1 -1
  21. package/dist/esm/lib/convert-table.js +37 -0
  22. package/dist/esm/lib/convert-table.js.map +1 -0
  23. package/dist/esm/lib/parse-arrow-in-batches.js +8 -15
  24. package/dist/esm/lib/parse-arrow-in-batches.js.map +1 -1
  25. package/dist/esm/lib/parse-arrow-sync.js +11 -25
  26. package/dist/esm/lib/parse-arrow-sync.js.map +1 -1
  27. package/dist/index.d.ts +2 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/lib/arrow-table-batch.d.ts +1 -1
  30. package/dist/lib/arrow-table-batch.d.ts.map +1 -1
  31. package/dist/lib/convert-table.d.ts +20 -0
  32. package/dist/lib/convert-table.d.ts.map +1 -0
  33. package/dist/lib/parse-arrow-in-batches.d.ts +2 -1
  34. package/dist/lib/parse-arrow-in-batches.d.ts.map +1 -1
  35. package/dist/lib/parse-arrow-sync.d.ts +2 -1
  36. package/dist/lib/parse-arrow-sync.d.ts.map +1 -1
  37. package/package.json +5 -5
  38. package/src/index.ts +8 -3
  39. package/src/lib/arrow-table-batch.ts +1 -1
  40. package/src/lib/convert-table.ts +65 -0
  41. package/src/lib/parse-arrow-in-batches.ts +24 -15
  42. package/src/lib/parse-arrow-sync.ts +20 -35
  43. package/dist/arrow-loader.js +0 -28
  44. package/dist/arrow-writer.js +0 -25
  45. package/dist/bundle.js +0 -5
  46. package/dist/index.js +0 -27
  47. package/dist/lib/arrow-table-batch.js +0 -65
  48. package/dist/lib/encode-arrow.js +0 -38
  49. package/dist/lib/parse-arrow-in-batches.js +0 -47
  50. package/dist/lib/parse-arrow-sync.js +0 -41
  51. package/dist/types.js +0 -8
  52. package/dist/workers/arrow-worker.js +0 -5
@@ -1,38 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.encodeArrowSync = void 0;
4
- const apache_arrow_1 = require("apache-arrow");
5
- const types_1 = require("../types");
6
- /**
7
- * Encodes set of arrays into the Apache Arrow columnar format
8
- * https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format
9
- * @param data - columns data
10
- * @param options - the writer options
11
- * @returns - encoded ArrayBuffer
12
- */
13
- function encodeArrowSync(data) {
14
- const vectors = {};
15
- for (const arrayData of data) {
16
- const arrayVector = createVector(arrayData.array, arrayData.type);
17
- vectors[arrayData.name] = arrayVector;
18
- }
19
- const table = new apache_arrow_1.Table(vectors);
20
- const arrowBuffer = (0, apache_arrow_1.tableToIPC)(table);
21
- return arrowBuffer;
22
- }
23
- exports.encodeArrowSync = encodeArrowSync;
24
- /**
25
- * Create Arrow Vector from given data and vector type
26
- * @param array {import('../types').AnyArrayType} - columns data
27
- * @param type {number} - the writer options
28
- * @return a vector of one of vector's types defined in the Apache Arrow library
29
- */
30
- function createVector(array, type) {
31
- switch (type) {
32
- case types_1.VECTOR_TYPES.DATE:
33
- return (0, apache_arrow_1.vectorFromArray)(array);
34
- case types_1.VECTOR_TYPES.FLOAT:
35
- default:
36
- return (0, apache_arrow_1.vectorFromArray)(array);
37
- }
38
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseArrowInBatches = void 0;
4
- // TODO - this import defeats the sophisticated typescript checking in ArrowJS
5
- const apache_arrow_1 = require("apache-arrow");
6
- // import {isIterable} from '@loaders.gl/core';
7
- /**
8
- */
9
- function parseArrowInBatches(asyncIterator) {
10
- // Creates the appropriate RecordBatchReader subclasses from the input
11
- // This will also close the underlying source in case of early termination or errors
12
- // As an optimization, return a non-async iterator
13
- /*
14
- if (isIterable(readers)) {
15
- function* makeArrowIterator() {
16
- for (const reader of readers) {
17
- for (const batch of reader) {
18
- yield processBatch(batch, reader);
19
- }
20
- break; // only processing one stream of batches
21
- }
22
- }
23
- const arrowIterator = makeArrowIterator();
24
- }
25
- */
26
- async function* makeArrowAsyncIterator() {
27
- const readers = apache_arrow_1.RecordBatchReader.readAll(asyncIterator);
28
- for await (const reader of readers) {
29
- for await (const batch of reader) {
30
- yield processBatch(batch);
31
- }
32
- break; // only processing one stream of batches
33
- }
34
- }
35
- return makeArrowAsyncIterator();
36
- }
37
- exports.parseArrowInBatches = parseArrowInBatches;
38
- function processBatch(batch) {
39
- const values = {
40
- metadata: batch.schema.metadata,
41
- length: batch.length
42
- };
43
- batch.schema.fields.forEach(({ name }, index) => {
44
- values[name] = batch.getChildAt(index).toArray();
45
- });
46
- return values;
47
- }
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const apache_arrow_1 = require("apache-arrow");
4
- // Parses arrow to a columnar table
5
- function parseArrowSync(arrayBuffer, options) {
6
- const arrowTable = (0, apache_arrow_1.tableFromIPC)([new Uint8Array(arrayBuffer)]);
7
- // Extract columns
8
- // TODO - avoid calling `getColumn` on columns we are not interested in?
9
- // Add options object?
10
- const columnarTable = {};
11
- for (const field of arrowTable.schema.fields) {
12
- // This (is intended to) coalesce all record batches into a single typed array
13
- const arrowColumn = arrowTable.getChild(field.name);
14
- const values = arrowColumn?.toArray();
15
- columnarTable[field.name] = values;
16
- }
17
- switch (options?.arrow?.shape) {
18
- case 'arrow-table':
19
- return arrowTable;
20
- case 'object-row-table':
21
- return convertColumnarToRowFormatTable(columnarTable);
22
- case 'columnar-table':
23
- default:
24
- return columnarTable;
25
- }
26
- }
27
- exports.default = parseArrowSync;
28
- function convertColumnarToRowFormatTable(columnarTable) {
29
- const tableKeys = Object.keys(columnarTable);
30
- const tableRowsCount = columnarTable[tableKeys[0]].length;
31
- const rowFormatTable = [];
32
- for (let index = 0; index < tableRowsCount; index++) {
33
- const tableItem = {};
34
- for (let keyIndex = 0; keyIndex < tableKeys.length; keyIndex++) {
35
- const fieldName = tableKeys[keyIndex];
36
- tableItem[fieldName] = columnarTable[fieldName][index];
37
- }
38
- rowFormatTable.push(tableItem);
39
- }
40
- return rowFormatTable;
41
- }
package/dist/types.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VECTOR_TYPES = void 0;
4
- var VECTOR_TYPES;
5
- (function (VECTOR_TYPES) {
6
- VECTOR_TYPES[VECTOR_TYPES["FLOAT"] = 0] = "FLOAT";
7
- VECTOR_TYPES[VECTOR_TYPES["DATE"] = 1] = "DATE";
8
- })(VECTOR_TYPES || (exports.VECTOR_TYPES = VECTOR_TYPES = {}));
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_utils_1 = require("@loaders.gl/loader-utils");
4
- const index_1 = require("../index");
5
- (0, loader_utils_1.createLoaderWorker)(index_1.ArrowLoader);