@loaders.gl/arrow 3.4.10 → 3.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14956,7 +14956,7 @@ return true;`);
14956
14956
  }
14957
14957
 
14958
14958
  // src/arrow-loader.ts
14959
- var VERSION = true ? "3.4.10" : "latest";
14959
+ var VERSION = true ? "3.4.12" : "latest";
14960
14960
  var DEFAULT_ARROW_LOADER_OPTIONS = {
14961
14961
  arrow: {
14962
14962
  shape: "columnar-table"
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports._typecheckArrowLoader = exports.ArrowLoader = void 0;
7
- var VERSION = typeof "3.4.10" !== 'undefined' ? "3.4.10" : 'latest';
7
+ var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
8
8
  var DEFAULT_ARROW_LOADER_OPTIONS = {
9
9
  arrow: {
10
10
  shape: 'columnar-table'
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.ArrowWriter = void 0;
7
7
  var _encodeArrow = require("./lib/encode-arrow");
8
- var VERSION = typeof "3.4.10" !== 'undefined' ? "3.4.10" : 'latest';
8
+ var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
9
9
  var ArrowWriter = {
10
10
  name: 'Apache Arrow',
11
11
  id: 'arrow',
@@ -1,4 +1,4 @@
1
- const VERSION = typeof "3.4.10" !== 'undefined' ? "3.4.10" : 'latest';
1
+ const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
2
2
  const DEFAULT_ARROW_LOADER_OPTIONS = {
3
3
  arrow: {
4
4
  shape: 'columnar-table'
@@ -1,5 +1,5 @@
1
1
  import { encodeArrowSync } from './lib/encode-arrow';
2
- const VERSION = typeof "3.4.10" !== 'undefined' ? "3.4.10" : 'latest';
2
+ const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
3
3
  export const ArrowWriter = {
4
4
  name: 'Apache Arrow',
5
5
  id: 'arrow',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/arrow",
3
- "version": "3.4.10",
3
+ "version": "3.4.12",
4
4
  "description": "Simple columnar table loader for the Apache Arrow format",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -36,9 +36,9 @@
36
36
  "build-worker": "esbuild src/workers/arrow-worker.ts --bundle --outfile=dist/arrow-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
37
37
  },
38
38
  "dependencies": {
39
- "@loaders.gl/loader-utils": "3.4.10",
40
- "@loaders.gl/schema": "3.4.10",
39
+ "@loaders.gl/loader-utils": "3.4.12",
40
+ "@loaders.gl/schema": "3.4.12",
41
41
  "apache-arrow": "^4.0.0"
42
42
  },
43
- "gitHead": "4568459c96eaf0480a50ab77cace355307f61f04"
43
+ "gitHead": "85254762ae3082f608a863291deef09f2b40c6cf"
44
44
  }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._typecheckArrowLoader = exports.ArrowLoader = void 0;
4
- // __VERSION__ is injected by babel-plugin-version-inline
5
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
7
- const DEFAULT_ARROW_LOADER_OPTIONS = {
8
- arrow: {
9
- shape: 'columnar-table'
10
- }
11
- };
12
- /** ArrowJS table loader */
13
- exports.ArrowLoader = {
14
- name: 'Apache Arrow',
15
- id: 'arrow',
16
- module: 'arrow',
17
- version: VERSION,
18
- worker: true,
19
- category: 'table',
20
- extensions: ['arrow', 'feather'],
21
- mimeTypes: [
22
- 'application/vnd.apache.arrow.file',
23
- 'application/vnd.apache.arrow.stream',
24
- 'application/octet-stream'
25
- ],
26
- binary: true,
27
- tests: ['ARROW'],
28
- options: DEFAULT_ARROW_LOADER_OPTIONS
29
- };
30
- exports._typecheckArrowLoader = exports.ArrowLoader;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ArrowWriter = void 0;
4
- const encode_arrow_1 = require("./lib/encode-arrow");
5
- // __VERSION__ is injected by babel-plugin-version-inline
6
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
- /** Apache Arrow writer */
9
- exports.ArrowWriter = {
10
- name: 'Apache Arrow',
11
- id: 'arrow',
12
- module: 'arrow',
13
- version: VERSION,
14
- extensions: ['arrow', 'feather'],
15
- mimeTypes: [
16
- 'application/vnd.apache.arrow.file',
17
- 'application/vnd.apache.arrow.stream',
18
- 'application/octet-stream'
19
- ],
20
- encodeSync,
21
- binary: true,
22
- options: {}
23
- };
24
- function encodeSync(data, options) {
25
- return (0, encode_arrow_1.encodeArrowSync)(data);
26
- }
package/dist/bundle.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- // @ts-nocheck
3
- const moduleExports = require('./index');
4
- globalThis.loaders = globalThis.loaders || {};
5
- module.exports = Object.assign(globalThis.loaders, moduleExports);
package/dist/index.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports._typecheckArrowLoader = exports.ArrowLoader = exports.ArrowWorkerLoader = exports.ArrowWriter = exports.VECTOR_TYPES = void 0;
7
- const arrow_loader_1 = require("./arrow-loader");
8
- Object.defineProperty(exports, "ArrowWorkerLoader", { enumerable: true, get: function () { return arrow_loader_1.ArrowLoader; } });
9
- const parse_arrow_sync_1 = __importDefault(require("./lib/parse-arrow-sync"));
10
- const parse_arrow_in_batches_1 = require("./lib/parse-arrow-in-batches");
11
- const schema_1 = require("@loaders.gl/schema");
12
- const arrow_table_batch_1 = __importDefault(require("./lib/arrow-table-batch"));
13
- // Make the ArrowBatch type available
14
- schema_1.TableBatchBuilder.ArrowBatch = arrow_table_batch_1.default;
15
- // Types
16
- var types_1 = require("./types");
17
- Object.defineProperty(exports, "VECTOR_TYPES", { enumerable: true, get: function () { return types_1.VECTOR_TYPES; } });
18
- // Arrow writer
19
- var arrow_writer_1 = require("./arrow-writer");
20
- Object.defineProperty(exports, "ArrowWriter", { enumerable: true, get: function () { return arrow_writer_1.ArrowWriter; } });
21
- /** ArrowJS table loader */
22
- exports.ArrowLoader = {
23
- ...arrow_loader_1.ArrowLoader,
24
- parse: async (arraybuffer, options) => (0, parse_arrow_sync_1.default)(arraybuffer, options),
25
- parseSync: parse_arrow_sync_1.default,
26
- parseInBatches: parse_arrow_in_batches_1.parseArrowInBatches
27
- };
28
- exports._typecheckArrowLoader = exports.ArrowLoader;
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const apache_arrow_1 = require("apache-arrow");
4
- const schema_1 = require("@loaders.gl/schema");
5
- class ArrowTableBatchAggregator extends schema_1.ColumnarTableBatchAggregator {
6
- constructor(schema, options) {
7
- super(schema, options);
8
- this.arrowSchema = null;
9
- }
10
- getBatch() {
11
- const batch = super.getBatch();
12
- if (batch) {
13
- // Get the arrow schema
14
- this.arrowSchema = this.arrowSchema || getArrowSchema(batch.schema);
15
- // Get arrow format vectors
16
- const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);
17
- // Create the record batch
18
- // new RecordBatch(schema, numRows, vectors, ...);
19
- const recordBatch = new apache_arrow_1.RecordBatch(this.arrowSchema, batch.length, arrowVectors);
20
- return {
21
- shape: 'arrow-table',
22
- batchType: 'data',
23
- data: recordBatch,
24
- length: batch.length
25
- };
26
- }
27
- return null;
28
- }
29
- }
30
- exports.default = ArrowTableBatchAggregator;
31
- // Convert from a simple loaders.gl schema to an Arrow schema
32
- function getArrowSchema(schema) {
33
- const arrowFields = [];
34
- for (const key in schema) {
35
- const field = schema[key];
36
- if (field.type === Float32Array) {
37
- const metadata = field; // just store the original field as metadata
38
- // arrow: new Field(name, nullable, metadata)
39
- const arrowField = new apache_arrow_1.Field(field.name, new apache_arrow_1.Float32(), field.nullable, metadata);
40
- arrowFields.push(arrowField);
41
- }
42
- }
43
- if (arrowFields.length === 0) {
44
- throw new Error('No arrow convertible fields');
45
- }
46
- return new apache_arrow_1.Schema(arrowFields);
47
- }
48
- // Convert from simple loaders.gl arrays to arrow vectors
49
- function getArrowVectors(arrowSchema, data) {
50
- const arrowVectors = [];
51
- for (const field of arrowSchema.fields) {
52
- const vector = data[field.name];
53
- if (vector instanceof Float32Array) {
54
- const arrowVector = apache_arrow_1.Float32Vector.from(vector);
55
- arrowVectors.push(arrowVector);
56
- }
57
- }
58
- if (arrowSchema.fields.length !== arrowVectors.length) {
59
- throw new Error('Some columns not arrow convertible');
60
- }
61
- return arrowVectors;
62
- }
@@ -1,40 +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
- const arrayNames = [];
16
- for (const arrayData of data) {
17
- arrayNames.push(arrayData.name);
18
- const arrayVector = createVector(arrayData.array, arrayData.type);
19
- vectors.push(arrayVector);
20
- }
21
- const table = apache_arrow_1.Table.new(vectors, arrayNames);
22
- const arrowBuffer = table.serialize();
23
- return arrowBuffer;
24
- }
25
- exports.encodeArrowSync = encodeArrowSync;
26
- /**
27
- * Create Arrow Vector from given data and vector type
28
- * @param array {import('../types').AnyArrayType} - columns data
29
- * @param type {number} - the writer options
30
- * @return a vector of one of vector's types defined in the Apache Arrow library
31
- */
32
- function createVector(array, type) {
33
- switch (type) {
34
- case types_1.VECTOR_TYPES.DATE:
35
- return apache_arrow_1.DateVector.from(array);
36
- case types_1.VECTOR_TYPES.FLOAT:
37
- default:
38
- return apache_arrow_1.FloatVector.from(array);
39
- }
40
- }
@@ -1,48 +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
- // @ts-expect-error Fixed in arrow 9
28
- const readers = apache_arrow_1.RecordBatchReader.readAll(asyncIterator);
29
- for await (const reader of readers) {
30
- for await (const batch of reader) {
31
- yield processBatch(batch);
32
- }
33
- break; // only processing one stream of batches
34
- }
35
- }
36
- return makeArrowAsyncIterator();
37
- }
38
- exports.parseArrowInBatches = parseArrowInBatches;
39
- function processBatch(batch) {
40
- const values = {
41
- metadata: batch.schema.metadata,
42
- length: batch.length
43
- };
44
- batch.schema.fields.forEach(({ name }, index) => {
45
- values[name] = batch.getChildAt(index).toArray();
46
- });
47
- return values;
48
- }
@@ -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 = apache_arrow_1.Table.from([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
- arrowTable.schema.fields.forEach((field) => {
12
- // This (is intended to) coalesce all record batches into a single typed array
13
- const arrowColumn = arrowTable.getColumn(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 || (exports.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);