@loaders.gl/arrow 4.0.1 → 4.0.2
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-worker.js +33 -25
- package/dist/arrow-writer.d.ts.map +1 -1
- package/dist/arrow-writer.js +6 -3
- package/dist/arrow-writer.js.map +1 -1
- package/dist/dist.dev.js +18 -14
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts +18 -2
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js +8 -9
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.js.map +1 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson.js.map +1 -1
- package/dist/geoarrow/get-arrow-bounds.d.ts.map +1 -1
- package/dist/geoarrow/get-arrow-bounds.js +1 -1
- package/dist/geoarrow/get-arrow-bounds.js.map +1 -1
- package/dist/index.cjs +135 -122
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/arrow-table-batch.d.ts +2 -2
- package/dist/lib/arrow-table-batch.d.ts.map +1 -1
- package/dist/lib/arrow-table-batch.js +7 -7
- package/dist/lib/arrow-table-batch.js.map +1 -1
- package/dist/lib/arrow-table.d.ts +3 -3
- package/dist/lib/arrow-table.d.ts.map +1 -1
- package/dist/lib/arrow-table.js.map +1 -1
- package/dist/lib/encode-arrow.js +5 -5
- package/dist/lib/encode-arrow.js.map +1 -1
- package/dist/lib/parse-arrow-in-batches.js +3 -3
- package/dist/lib/parse-arrow-in-batches.js.map +1 -1
- package/dist/lib/parse-arrow-sync.js +2 -2
- package/dist/lib/parse-arrow-sync.js.map +1 -1
- package/dist/schema/arrow-type-utils.d.ts +2 -2
- package/dist/schema/arrow-type-utils.d.ts.map +1 -1
- package/dist/schema/arrow-type-utils.js +9 -9
- package/dist/schema/arrow-type-utils.js.map +1 -1
- package/dist/schema/convert-arrow-schema.d.ts +7 -7
- package/dist/schema/convert-arrow-schema.d.ts.map +1 -1
- package/dist/schema/convert-arrow-schema.js +81 -81
- package/dist/schema/convert-arrow-schema.js.map +1 -1
- package/dist/tables/convert-arrow-to-table.d.ts +2 -2
- package/dist/tables/convert-arrow-to-table.d.ts.map +1 -1
- package/dist/tables/convert-arrow-to-table.js.map +1 -1
- package/package.json +5 -5
- package/src/arrow-writer.ts +6 -3
- package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +14 -16
- package/src/geoarrow/convert-geoarrow-to-geojson.ts +7 -7
- package/src/geoarrow/get-arrow-bounds.ts +1 -2
- package/src/index.ts +6 -1
- package/src/lib/arrow-table-batch.ts +13 -23
- package/src/lib/arrow-table.ts +3 -3
- package/src/lib/encode-arrow.ts +8 -8
- package/src/lib/parse-arrow-in-batches.ts +4 -4
- package/src/lib/parse-arrow-sync.ts +2 -2
- package/src/schema/arrow-type-utils.ts +10 -29
- package/src/schema/convert-arrow-schema.ts +98 -142
- package/src/tables/convert-arrow-to-table.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColumnarTableBatchAggregator } from '@loaders.gl/schema';
|
|
2
|
-
import
|
|
2
|
+
import * as arrow from 'apache-arrow';
|
|
3
3
|
export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
4
4
|
constructor(schema, options) {
|
|
5
5
|
super(schema, options);
|
|
@@ -11,8 +11,8 @@ export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
|
11
11
|
if (batch) {
|
|
12
12
|
this.arrowSchema = this.arrowSchema || getArrowSchema(batch.schema);
|
|
13
13
|
const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);
|
|
14
|
-
const recordBatch = new RecordBatch(this.arrowSchema, makeData({
|
|
15
|
-
type: new Struct(this.arrowSchema.fields),
|
|
14
|
+
const recordBatch = new arrow.RecordBatch(this.arrowSchema, arrow.makeData({
|
|
15
|
+
type: new arrow.Struct(this.arrowSchema.fields),
|
|
16
16
|
children: arrowVectors.map(_ref => {
|
|
17
17
|
let {
|
|
18
18
|
data
|
|
@@ -23,7 +23,7 @@ export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
|
23
23
|
return {
|
|
24
24
|
shape: 'arrow-table',
|
|
25
25
|
batchType: 'data',
|
|
26
|
-
data: new
|
|
26
|
+
data: new arrow.Table([recordBatch]),
|
|
27
27
|
length: batch.length
|
|
28
28
|
};
|
|
29
29
|
}
|
|
@@ -36,21 +36,21 @@ function getArrowSchema(schema) {
|
|
|
36
36
|
const field = schema[key];
|
|
37
37
|
if (field.type === Float32Array) {
|
|
38
38
|
const metadata = new Map();
|
|
39
|
-
const arrowField = new Field(field.name, new Float32(), field.nullable, metadata);
|
|
39
|
+
const arrowField = new arrow.Field(field.name, new arrow.Float32(), field.nullable, metadata);
|
|
40
40
|
arrowFields.push(arrowField);
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
if (arrowFields.length === 0) {
|
|
44
44
|
throw new Error('No arrow convertible fields');
|
|
45
45
|
}
|
|
46
|
-
return new Schema(arrowFields);
|
|
46
|
+
return new arrow.Schema(arrowFields);
|
|
47
47
|
}
|
|
48
48
|
function getArrowVectors(arrowSchema, data) {
|
|
49
49
|
const arrowVectors = [];
|
|
50
50
|
for (const field of arrowSchema.fields) {
|
|
51
51
|
const vector = data[field.name];
|
|
52
52
|
if (vector instanceof Float32Array) {
|
|
53
|
-
const arrowVector = makeVector(vector);
|
|
53
|
+
const arrowVector = arrow.makeVector(vector);
|
|
54
54
|
arrowVectors.push(arrowVector);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-table-batch.js","names":["ColumnarTableBatchAggregator","
|
|
1
|
+
{"version":3,"file":"arrow-table-batch.js","names":["ColumnarTableBatchAggregator","arrow","ArrowTableBatchAggregator","constructor","schema","options","arrowSchema","getBatch","batch","getArrowSchema","arrowVectors","getArrowVectors","data","recordBatch","RecordBatch","makeData","type","Struct","fields","children","map","_ref","shape","batchType","Table","length","arrowFields","key","field","Float32Array","metadata","Map","arrowField","Field","name","Float32","nullable","push","Error","Schema","vector","arrowVector","makeVector"],"sources":["../../src/lib/arrow-table-batch.ts"],"sourcesContent":["import {ColumnarTableBatchAggregator} from '@loaders.gl/schema';\nimport type {ArrowTableBatch} from './arrow-table';\nimport * as arrow from 'apache-arrow';\n\nexport class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {\n arrowSchema: arrow.Schema | null;\n\n constructor(schema, options) {\n super(schema, options);\n this.arrowSchema = null;\n }\n\n getBatch(): ArrowTableBatch | null {\n const batch = super.getBatch();\n if (batch) {\n // Get the arrow schema\n this.arrowSchema = this.arrowSchema || getArrowSchema(batch.schema);\n\n // Get arrow format vectors\n const arrowVectors = getArrowVectors(this.arrowSchema, batch.data);\n\n // Create the record batch\n const recordBatch = new arrow.RecordBatch(\n this.arrowSchema,\n arrow.makeData({\n type: new arrow.Struct(this.arrowSchema.fields),\n children: arrowVectors.map(({data}) => data[0])\n })\n );\n\n return {\n shape: 'arrow-table',\n batchType: 'data',\n data: new arrow.Table([recordBatch]),\n length: batch.length\n };\n }\n\n return null;\n }\n}\n\n// Convert from a simple loaders.gl schema to an Arrow schema\nfunction getArrowSchema(schema): arrow.Schema {\n const arrowFields: arrow.Field[] = [];\n for (const key in schema) {\n const field = schema[key];\n if (field.type === Float32Array) {\n // TODO - just store the original field as metadata?\n const metadata = new Map(); // field;\n // arrow: new arrow.Field(name, nullable, metadata)\n const arrowField = new arrow.Field(field.name, new arrow.Float32(), field.nullable, metadata);\n arrowFields.push(arrowField);\n }\n }\n if (arrowFields.length === 0) {\n throw new Error('No arrow convertible fields');\n }\n\n return new arrow.Schema(arrowFields);\n}\n\n// Convert from simple loaders.gl arrays to arrow vectors\nfunction getArrowVectors(arrowSchema, data): arrow.Vector[] {\n const arrowVectors: any[] = [];\n for (const field of arrowSchema.fields) {\n const vector = data[field.name];\n if (vector instanceof Float32Array) {\n const arrowVector = arrow.makeVector(vector);\n arrowVectors.push(arrowVector);\n }\n }\n if (arrowSchema.fields.length !== arrowVectors.length) {\n throw new Error('Some columns not arrow convertible');\n }\n return arrowVectors;\n}\n"],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Batch, Schema } from '@loaders.gl/schema';
|
|
2
|
-
import type
|
|
2
|
+
import type * as arrow from 'apache-arrow';
|
|
3
3
|
/**
|
|
4
4
|
* A table organized as an Apache Arrow table
|
|
5
5
|
* @note This is a variant of the type from loaders.gl/schema
|
|
@@ -7,7 +7,7 @@ import type { Table as ApacheArrowTable } from 'apache-arrow';
|
|
|
7
7
|
export type ArrowTable = {
|
|
8
8
|
shape: 'arrow-table';
|
|
9
9
|
schema?: Schema;
|
|
10
|
-
data:
|
|
10
|
+
data: arrow.Table;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Batch for a table organized as an Apache Arrow table
|
|
@@ -17,7 +17,7 @@ export type ArrowTableBatch = Batch & {
|
|
|
17
17
|
shape: 'arrow-table';
|
|
18
18
|
schemaType?: 'explicit' | 'deduced';
|
|
19
19
|
schema?: Schema;
|
|
20
|
-
data:
|
|
20
|
+
data: arrow.Table;
|
|
21
21
|
length: number;
|
|
22
22
|
};
|
|
23
23
|
//# sourceMappingURL=arrow-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-table.d.ts","sourceRoot":"","sources":["../../src/lib/arrow-table.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,KAAK,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"arrow-table.d.ts","sourceRoot":"","sources":["../../src/lib/arrow-table.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,KAAK,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG;IACpC,KAAK,EAAE,aAAa,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-table.js","names":[],"sources":["../../src/lib/arrow-table.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Batch, Schema} from '@loaders.gl/schema';\nimport type
|
|
1
|
+
{"version":3,"file":"arrow-table.js","names":[],"sources":["../../src/lib/arrow-table.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {Batch, Schema} from '@loaders.gl/schema';\nimport type * as arrow from 'apache-arrow';\n\n/**\n * A table organized as an Apache Arrow table\n * @note This is a variant of the type from loaders.gl/schema\n */\nexport type ArrowTable = {\n shape: 'arrow-table';\n schema?: Schema;\n data: arrow.Table;\n};\n\n/**\n * Batch for a table organized as an Apache Arrow table\n * @note This is a variant of the type from loaders.gl/schema\n */\nexport type ArrowTableBatch = Batch & {\n shape: 'arrow-table';\n schemaType?: 'explicit' | 'deduced';\n schema?: Schema;\n data: arrow.Table; // ApacheRecordBatch;\n length: number;\n};\n"],"mappings":""}
|
package/dist/lib/encode-arrow.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
2
|
import { VECTOR_TYPES } from "../types.js";
|
|
3
3
|
export function encodeArrowSync(data) {
|
|
4
4
|
const vectors = {};
|
|
@@ -6,17 +6,17 @@ export function encodeArrowSync(data) {
|
|
|
6
6
|
const arrayVector = createVector(arrayData.array, arrayData.type);
|
|
7
7
|
vectors[arrayData.name] = arrayVector;
|
|
8
8
|
}
|
|
9
|
-
const table = new Table(vectors);
|
|
10
|
-
const arrowBuffer = tableToIPC(table);
|
|
9
|
+
const table = new arrow.Table(vectors);
|
|
10
|
+
const arrowBuffer = arrow.tableToIPC(table);
|
|
11
11
|
return arrowBuffer;
|
|
12
12
|
}
|
|
13
13
|
function createVector(array, type) {
|
|
14
14
|
switch (type) {
|
|
15
15
|
case VECTOR_TYPES.DATE:
|
|
16
|
-
return vectorFromArray(array);
|
|
16
|
+
return arrow.vectorFromArray(array);
|
|
17
17
|
case VECTOR_TYPES.FLOAT:
|
|
18
18
|
default:
|
|
19
|
-
return vectorFromArray(array);
|
|
19
|
+
return arrow.vectorFromArray(array);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
//# sourceMappingURL=encode-arrow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encode-arrow.js","names":["
|
|
1
|
+
{"version":3,"file":"encode-arrow.js","names":["arrow","VECTOR_TYPES","encodeArrowSync","data","vectors","arrayData","arrayVector","createVector","array","type","name","table","Table","arrowBuffer","tableToIPC","DATE","vectorFromArray","FLOAT"],"sources":["../../src/lib/encode-arrow.ts"],"sourcesContent":["import * as arrow from 'apache-arrow';\nimport {AnyArrayType, VECTOR_TYPES} from '../types';\n\nexport type ColumnarTable = {\n name: string;\n array: AnyArrayType;\n type: number;\n}[];\n\n/**\n * Encodes set of arrays into the Apache Arrow columnar format\n * https://arrow.apache.org/docs/format/Columnar.html#ipc-file-format\n * @param data - columns data\n * @param options - the writer options\n * @returns - encoded ArrayBuffer\n */\nexport function encodeArrowSync(data: ColumnarTable): ArrayBuffer {\n const vectors: Record<string, arrow.Vector> = {};\n for (const arrayData of data) {\n const arrayVector = createVector(arrayData.array, arrayData.type);\n vectors[arrayData.name] = arrayVector;\n }\n const table = new arrow.Table(vectors);\n const arrowBuffer = arrow.tableToIPC(table);\n return arrowBuffer;\n}\n\n/**\n * Create Arrow arrow.Vector from given data and vector type\n * @param array {import('../types').AnyArrayType} - columns data\n * @param type {number} - the writer options\n * @return a vector of one of vector's types defined in the Apache Arrow library\n */\nfunction createVector(array, type): arrow.Vector {\n switch (type) {\n case VECTOR_TYPES.DATE:\n return arrow.vectorFromArray(array);\n case VECTOR_TYPES.FLOAT:\n default:\n return arrow.vectorFromArray(array);\n }\n}\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,cAAc;AAAC,SAChBC,YAAY;AAelC,OAAO,SAASC,eAAeA,CAACC,IAAmB,EAAe;EAChE,MAAMC,OAAqC,GAAG,CAAC,CAAC;EAChD,KAAK,MAAMC,SAAS,IAAIF,IAAI,EAAE;IAC5B,MAAMG,WAAW,GAAGC,YAAY,CAACF,SAAS,CAACG,KAAK,EAAEH,SAAS,CAACI,IAAI,CAAC;IACjEL,OAAO,CAACC,SAAS,CAACK,IAAI,CAAC,GAAGJ,WAAW;EACvC;EACA,MAAMK,KAAK,GAAG,IAAIX,KAAK,CAACY,KAAK,CAACR,OAAO,CAAC;EACtC,MAAMS,WAAW,GAAGb,KAAK,CAACc,UAAU,CAACH,KAAK,CAAC;EAC3C,OAAOE,WAAW;AACpB;AAQA,SAASN,YAAYA,CAACC,KAAK,EAAEC,IAAI,EAAgB;EAC/C,QAAQA,IAAI;IACV,KAAKR,YAAY,CAACc,IAAI;MACpB,OAAOf,KAAK,CAACgB,eAAe,CAACR,KAAK,CAAC;IACrC,KAAKP,YAAY,CAACgB,KAAK;IACvB;MACE,OAAOjB,KAAK,CAACgB,eAAe,CAACR,KAAK,CAAC;EACvC;AACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
2
|
export function parseArrowInBatches(asyncIterator) {
|
|
3
3
|
async function* makeArrowAsyncIterator() {
|
|
4
|
-
const readers = RecordBatchReader.readAll(asyncIterator);
|
|
4
|
+
const readers = arrow.RecordBatchReader.readAll(asyncIterator);
|
|
5
5
|
for await (const reader of readers) {
|
|
6
6
|
for await (const recordBatch of reader) {
|
|
7
7
|
const arrowTabledBatch = {
|
|
8
8
|
shape: 'arrow-table',
|
|
9
9
|
batchType: 'data',
|
|
10
|
-
data: new
|
|
10
|
+
data: new arrow.Table([recordBatch]),
|
|
11
11
|
length: recordBatch.data.length
|
|
12
12
|
};
|
|
13
13
|
yield arrowTabledBatch;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-arrow-in-batches.js","names":["
|
|
1
|
+
{"version":3,"file":"parse-arrow-in-batches.js","names":["arrow","parseArrowInBatches","asyncIterator","makeArrowAsyncIterator","readers","RecordBatchReader","readAll","reader","recordBatch","arrowTabledBatch","shape","batchType","data","Table","length"],"sources":["../../src/lib/parse-arrow-in-batches.ts"],"sourcesContent":["// TODO - this import defeats the sophisticated typescript checking in ArrowJS\nimport type {ArrowTableBatch} from './arrow-table';\nimport * as arrow from 'apache-arrow';\n// import {isIterable} from '@loaders.gl/core';\n\n/**\n */\nexport function parseArrowInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>\n): AsyncIterable<ArrowTableBatch> {\n // Creates the appropriate arrow.RecordBatchReader subclasses from the input\n // This will also close the underlying source in case of early termination or errors\n\n // As an optimization, return a non-async iterator\n /*\n if (isIterable(readers)) {\n function* makeArrowIterator() {\n for (const reader of readers) {\n for (const batch of reader) {\n yield processBatch(batch, reader);\n }\n break; // only processing one stream of batches\n }\n }\n const arrowIterator = makeArrowIterator();\n }\n */\n\n async function* makeArrowAsyncIterator(): AsyncIterator<ArrowTableBatch> {\n // @ts-ignore\n const readers = arrow.RecordBatchReader.readAll(asyncIterator);\n for await (const reader of readers) {\n for await (const recordBatch of reader) {\n const arrowTabledBatch: ArrowTableBatch = {\n shape: 'arrow-table',\n batchType: 'data',\n data: new arrow.Table([recordBatch]),\n length: recordBatch.data.length\n };\n // processBatch(recordBatch);\n yield arrowTabledBatch;\n }\n break; // only processing one stream of batches\n }\n }\n\n return makeArrowAsyncIterator() as any; // as AsyncIterator<ArrowTableBatch>;\n}\n\n// function processBatch(batch: RecordBatch): ArrowTableBatch {\n// const values = {};\n// batch.schema.fields.forEach(({name}, index) => {\n// values[name] = batch.getChildAt(index)?.toArray();\n// });\n// return {\n// };\n// }\n"],"mappings":"AAEA,OAAO,KAAKA,KAAK,MAAM,cAAc;AAKrC,OAAO,SAASC,mBAAmBA,CACjCC,aAAiE,EACjC;EAmBhC,gBAAgBC,sBAAsBA,CAAA,EAAmC;IAEvE,MAAMC,OAAO,GAAGJ,KAAK,CAACK,iBAAiB,CAACC,OAAO,CAACJ,aAAa,CAAC;IAC9D,WAAW,MAAMK,MAAM,IAAIH,OAAO,EAAE;MAClC,WAAW,MAAMI,WAAW,IAAID,MAAM,EAAE;QACtC,MAAME,gBAAiC,GAAG;UACxCC,KAAK,EAAE,aAAa;UACpBC,SAAS,EAAE,MAAM;UACjBC,IAAI,EAAE,IAAIZ,KAAK,CAACa,KAAK,CAAC,CAACL,WAAW,CAAC,CAAC;UACpCM,MAAM,EAAEN,WAAW,CAACI,IAAI,CAACE;QAC3B,CAAC;QAED,MAAML,gBAAgB;MACxB;MACA;IACF;EACF;EAEA,OAAON,sBAAsB,CAAC,CAAC;AACjC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { convertTable } from '@loaders.gl/schema';
|
|
2
|
-
import
|
|
2
|
+
import * as arrow from 'apache-arrow';
|
|
3
3
|
import { convertApacheArrowToArrowTable, convertArrowToColumnarTable } from "../tables/convert-arrow-to-table.js";
|
|
4
4
|
export default function parseArrowSync(arrayBuffer, options) {
|
|
5
5
|
var _options$arrow;
|
|
6
|
-
const apacheArrowTable = tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
6
|
+
const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
7
7
|
const arrowTable = convertApacheArrowToArrowTable(apacheArrowTable);
|
|
8
8
|
const shape = (options === null || options === void 0 ? void 0 : (_options$arrow = options.arrow) === null || _options$arrow === void 0 ? void 0 : _options$arrow.shape) || 'arrow-table';
|
|
9
9
|
switch (shape) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-arrow-sync.js","names":["convertTable","
|
|
1
|
+
{"version":3,"file":"parse-arrow-sync.js","names":["convertTable","arrow","convertApacheArrowToArrowTable","convertArrowToColumnarTable","parseArrowSync","arrayBuffer","options","_options$arrow","apacheArrowTable","tableFromIPC","Uint8Array","arrowTable","shape","columnarTable","Error"],"sources":["../../src/lib/parse-arrow-sync.ts"],"sourcesContent":["import type {ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';\nimport type {ArrowTable} from './arrow-table';\nimport {convertTable} from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\nimport type {ArrowLoaderOptions} from '../arrow-loader';\nimport {\n convertApacheArrowToArrowTable,\n convertArrowToColumnarTable\n} from '../tables/convert-arrow-to-table';\n\n// Parses arrow to a columnar table\nexport default function parseArrowSync(\n arrayBuffer,\n options?: ArrowLoaderOptions\n): ArrowTable | ColumnarTable | ObjectRowTable {\n const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);\n const arrowTable = convertApacheArrowToArrowTable(apacheArrowTable);\n\n const shape = options?.arrow?.shape || 'arrow-table';\n switch (shape) {\n case 'arrow-table':\n return arrowTable;\n\n case 'columnar-table':\n return convertArrowToColumnarTable(arrowTable);\n\n case 'object-row-table':\n const columnarTable = convertArrowToColumnarTable(arrowTable);\n return convertTable(columnarTable, 'object-row-table');\n\n default:\n // TODO\n throw new Error(shape);\n }\n}\n"],"mappings":"AAEA,SAAQA,YAAY,QAAO,oBAAoB;AAC/C,OAAO,KAAKC,KAAK,MAAM,cAAc;AAAC,SAGpCC,8BAA8B,EAC9BC,2BAA2B;AAI7B,eAAe,SAASC,cAAcA,CACpCC,WAAW,EACXC,OAA4B,EACiB;EAAA,IAAAC,cAAA;EAC7C,MAAMC,gBAAgB,GAAGP,KAAK,CAACQ,YAAY,CAAC,CAAC,IAAIC,UAAU,CAACL,WAAW,CAAC,CAAC,CAAC;EAC1E,MAAMM,UAAU,GAAGT,8BAA8B,CAACM,gBAAgB,CAAC;EAEnE,MAAMI,KAAK,GAAG,CAAAN,OAAO,aAAPA,OAAO,wBAAAC,cAAA,GAAPD,OAAO,CAAEL,KAAK,cAAAM,cAAA,uBAAdA,cAAA,CAAgBK,KAAK,KAAI,aAAa;EACpD,QAAQA,KAAK;IACX,KAAK,aAAa;MAChB,OAAOD,UAAU;IAEnB,KAAK,gBAAgB;MACnB,OAAOR,2BAA2B,CAACQ,UAAU,CAAC;IAEhD,KAAK,kBAAkB;MACrB,MAAME,aAAa,GAAGV,2BAA2B,CAACQ,UAAU,CAAC;MAC7D,OAAOX,YAAY,CAACa,aAAa,EAAE,kBAAkB,CAAC;IAExD;MAEE,MAAM,IAAIC,KAAK,CAACF,KAAK,CAAC;EAC1B;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TypedArray } from '@loaders.gl/schema';
|
|
2
|
-
import
|
|
2
|
+
import * as arrow from 'apache-arrow';
|
|
3
3
|
/** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */
|
|
4
|
-
export declare function getArrowType(array: TypedArray): DataType;
|
|
4
|
+
export declare function getArrowType(array: TypedArray): arrow.DataType;
|
|
5
5
|
//# sourceMappingURL=arrow-type-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-type-utils.d.ts","sourceRoot":"","sources":["../../src/schema/arrow-type-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"arrow-type-utils.d.ts","sourceRoot":"","sources":["../../src/schema/arrow-type-utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,oHAAoH;AACpH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC,QAAQ,CAqB9D"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
2
|
export function getArrowType(array) {
|
|
3
3
|
switch (array.constructor) {
|
|
4
4
|
case Int8Array:
|
|
5
|
-
return new Int8();
|
|
5
|
+
return new arrow.Int8();
|
|
6
6
|
case Uint8Array:
|
|
7
|
-
return new Uint8();
|
|
7
|
+
return new arrow.Uint8();
|
|
8
8
|
case Int16Array:
|
|
9
|
-
return new Int16();
|
|
9
|
+
return new arrow.Int16();
|
|
10
10
|
case Uint16Array:
|
|
11
|
-
return new Uint16();
|
|
11
|
+
return new arrow.Uint16();
|
|
12
12
|
case Int32Array:
|
|
13
|
-
return new Int32();
|
|
13
|
+
return new arrow.Int32();
|
|
14
14
|
case Uint32Array:
|
|
15
|
-
return new Uint32();
|
|
15
|
+
return new arrow.Uint32();
|
|
16
16
|
case Float32Array:
|
|
17
|
-
return new Float32();
|
|
17
|
+
return new arrow.Float32();
|
|
18
18
|
case Float64Array:
|
|
19
|
-
return new Float64();
|
|
19
|
+
return new arrow.Float64();
|
|
20
20
|
default:
|
|
21
21
|
throw new Error('array type not supported');
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-type-utils.js","names":["
|
|
1
|
+
{"version":3,"file":"arrow-type-utils.js","names":["arrow","getArrowType","array","constructor","Int8Array","Int8","Uint8Array","Uint8","Int16Array","Int16","Uint16Array","Uint16","Int32Array","Int32","Uint32Array","Uint32","Float32Array","Float32","Float64Array","Float64","Error"],"sources":["../../src/schema/arrow-type-utils.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {TypedArray} from '@loaders.gl/schema';\nimport * as arrow from 'apache-arrow';\n\n/** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */\nexport function getArrowType(array: TypedArray): arrow.DataType {\n switch (array.constructor) {\n case Int8Array:\n return new arrow.Int8();\n case Uint8Array:\n return new arrow.Uint8();\n case Int16Array:\n return new arrow.Int16();\n case Uint16Array:\n return new arrow.Uint16();\n case Int32Array:\n return new arrow.Int32();\n case Uint32Array:\n return new arrow.Uint32();\n case Float32Array:\n return new arrow.Float32();\n case Float64Array:\n return new arrow.Float64();\n default:\n throw new Error('array type not supported');\n }\n}\n\n/*\nexport function getArrowVector(array: TypedArray): AbstractVector {\n switch (array.constructor) {\n case Int8Array:\n return Int8Vector.from(array);\n case Uint8Array:\n return Uint8Vector.from(array);\n case Int16Array:\n return Int16Vector.from(array);\n case Uint16Array:\n return Uint16Vector.from(array);\n case Int32Array:\n return Int32Vector.from(array);\n case Uint32Array:\n return Uint32Vector.from(array);\n case Float32Array:\n return Float32Vector.from(array);\n case Float64Array:\n return Float64Vector.from(array);\n default:\n throw new Error('array type not supported');\n }\n}\n*/\n"],"mappings":"AAIA,OAAO,KAAKA,KAAK,MAAM,cAAc;AAGrC,OAAO,SAASC,YAAYA,CAACC,KAAiB,EAAkB;EAC9D,QAAQA,KAAK,CAACC,WAAW;IACvB,KAAKC,SAAS;MACZ,OAAO,IAAIJ,KAAK,CAACK,IAAI,CAAC,CAAC;IACzB,KAAKC,UAAU;MACb,OAAO,IAAIN,KAAK,CAACO,KAAK,CAAC,CAAC;IAC1B,KAAKC,UAAU;MACb,OAAO,IAAIR,KAAK,CAACS,KAAK,CAAC,CAAC;IAC1B,KAAKC,WAAW;MACd,OAAO,IAAIV,KAAK,CAACW,MAAM,CAAC,CAAC;IAC3B,KAAKC,UAAU;MACb,OAAO,IAAIZ,KAAK,CAACa,KAAK,CAAC,CAAC;IAC1B,KAAKC,WAAW;MACd,OAAO,IAAId,KAAK,CAACe,MAAM,CAAC,CAAC;IAC3B,KAAKC,YAAY;MACf,OAAO,IAAIhB,KAAK,CAACiB,OAAO,CAAC,CAAC;IAC5B,KAAKC,YAAY;MACf,OAAO,IAAIlB,KAAK,CAACmB,OAAO,CAAC,CAAC;IAC5B;MACE,MAAM,IAAIC,KAAK,CAAC,0BAA0B,CAAC;EAC/C;AACF"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { DataType, Field, Schema, SchemaMetadata } from '@loaders.gl/schema';
|
|
2
|
-
import
|
|
2
|
+
import * as arrow from 'apache-arrow';
|
|
3
3
|
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
4
|
-
export declare function serializeArrowSchema(arrowSchema:
|
|
4
|
+
export declare function serializeArrowSchema(arrowSchema: arrow.Schema): Schema;
|
|
5
5
|
/** Convert a serialized Schema (plain data) to an Apache Arrow Schema (class instance) */
|
|
6
|
-
export declare function deserializeArrowSchema(schema: Schema):
|
|
6
|
+
export declare function deserializeArrowSchema(schema: Schema): arrow.Schema;
|
|
7
7
|
/** Convert Apache Arrow Schema metadata (Map<string, string>) to serialized metadata (Record<string, string> */
|
|
8
8
|
export declare function serializeArrowMetadata(arrowMetadata: Map<string, string>): SchemaMetadata;
|
|
9
9
|
/** Convert serialized metadata (Record<string, string> to Apache Arrow Schema metadata (Map<string, string>) to */
|
|
10
10
|
export declare function deserializeArrowMetadata(metadata?: SchemaMetadata): Map<string, string>;
|
|
11
11
|
/** Convert Apache Arrow Field (class instance) to serialized Field (plain data) */
|
|
12
|
-
export declare function serializeArrowField(field:
|
|
12
|
+
export declare function serializeArrowField(field: arrow.Field): Field;
|
|
13
13
|
/** Convert a serialized Field (plain data) to an Apache Arrow Field (class instance)*/
|
|
14
|
-
export declare function deserializeArrowField(field: Field):
|
|
14
|
+
export declare function deserializeArrowField(field: Field): arrow.Field;
|
|
15
15
|
/** Converts a serializable loaders.gl data type to hydrated arrow data type */
|
|
16
|
-
export declare function serializeArrowType(arrowType:
|
|
16
|
+
export declare function serializeArrowType(arrowType: arrow.DataType): DataType;
|
|
17
17
|
/** Converts a serializable loaders.gl data type to hydrated arrow data type */
|
|
18
|
-
export declare function deserializeArrowType(dataType: DataType):
|
|
18
|
+
export declare function deserializeArrowType(dataType: DataType): arrow.DataType;
|
|
19
19
|
//# sourceMappingURL=convert-arrow-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-arrow-schema.d.ts","sourceRoot":"","sources":["../../src/schema/convert-arrow-schema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAChF,OAAO,
|
|
1
|
+
{"version":3,"file":"convert-arrow-schema.d.ts","sourceRoot":"","sources":["../../src/schema/convert-arrow-schema.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAChF,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAKtE;AAED,0FAA0F;AAC1F,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAKnE;AAED,gHAAgH;AAChH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,cAAc,CAEzF;AAED,mHAAmH;AACnH,wBAAgB,wBAAwB,CAAC,QAAQ,CAAC,EAAE,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAEvF;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAO7D;AAED,uFAAuF;AACvF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAO/D;AAED,+EAA+E;AAE/E,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAmItE;AAED,+EAA+E;AAE/E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC,QAAQ,CA2EvE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as arrow from 'apache-arrow';
|
|
2
2
|
export function serializeArrowSchema(arrowSchema) {
|
|
3
3
|
return {
|
|
4
4
|
fields: arrowSchema.fields.map(arrowField => serializeArrowField(arrowField)),
|
|
@@ -6,7 +6,7 @@ export function serializeArrowSchema(arrowSchema) {
|
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
8
|
export function deserializeArrowSchema(schema) {
|
|
9
|
-
return new
|
|
9
|
+
return new arrow.Schema(schema.fields.map(field => deserializeArrowField(field)), deserializeArrowMetadata(schema.metadata));
|
|
10
10
|
}
|
|
11
11
|
export function serializeArrowMetadata(arrowMetadata) {
|
|
12
12
|
return Object.fromEntries(arrowMetadata);
|
|
@@ -23,128 +23,128 @@ export function serializeArrowField(field) {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
export function deserializeArrowField(field) {
|
|
26
|
-
return new
|
|
26
|
+
return new arrow.Field(field.name, deserializeArrowType(field.type), field.nullable, deserializeArrowMetadata(field.metadata));
|
|
27
27
|
}
|
|
28
28
|
export function serializeArrowType(arrowType) {
|
|
29
29
|
switch (arrowType.constructor) {
|
|
30
|
-
case Null:
|
|
30
|
+
case arrow.Null:
|
|
31
31
|
return 'null';
|
|
32
|
-
case Binary:
|
|
32
|
+
case arrow.Binary:
|
|
33
33
|
return 'binary';
|
|
34
|
-
case Bool:
|
|
34
|
+
case arrow.Bool:
|
|
35
35
|
return 'bool';
|
|
36
|
-
case Int:
|
|
36
|
+
case arrow.Int:
|
|
37
37
|
const intType = arrowType;
|
|
38
38
|
return `${intType.isSigned ? 'u' : ''}int${intType.bitWidth}`;
|
|
39
|
-
case Int8:
|
|
39
|
+
case arrow.Int8:
|
|
40
40
|
return 'int8';
|
|
41
|
-
case Int16:
|
|
41
|
+
case arrow.Int16:
|
|
42
42
|
return 'int16';
|
|
43
|
-
case Int32:
|
|
43
|
+
case arrow.Int32:
|
|
44
44
|
return 'int32';
|
|
45
|
-
case Int64:
|
|
45
|
+
case arrow.Int64:
|
|
46
46
|
return 'int64';
|
|
47
|
-
case Uint8:
|
|
47
|
+
case arrow.Uint8:
|
|
48
48
|
return 'uint8';
|
|
49
|
-
case Uint16:
|
|
49
|
+
case arrow.Uint16:
|
|
50
50
|
return 'uint16';
|
|
51
|
-
case Uint32:
|
|
51
|
+
case arrow.Uint32:
|
|
52
52
|
return 'uint32';
|
|
53
|
-
case Uint64:
|
|
53
|
+
case arrow.Uint64:
|
|
54
54
|
return 'uint64';
|
|
55
|
-
case Float:
|
|
55
|
+
case arrow.Float:
|
|
56
56
|
const precision = arrowType.precision;
|
|
57
57
|
switch (precision) {
|
|
58
|
-
case Precision.HALF:
|
|
58
|
+
case arrow.Precision.HALF:
|
|
59
59
|
return 'float16';
|
|
60
|
-
case Precision.SINGLE:
|
|
60
|
+
case arrow.Precision.SINGLE:
|
|
61
61
|
return 'float32';
|
|
62
|
-
case Precision.DOUBLE:
|
|
62
|
+
case arrow.Precision.DOUBLE:
|
|
63
63
|
return 'float64';
|
|
64
64
|
default:
|
|
65
65
|
return 'float16';
|
|
66
66
|
}
|
|
67
|
-
case Float16:
|
|
67
|
+
case arrow.Float16:
|
|
68
68
|
return 'float16';
|
|
69
|
-
case Float32:
|
|
69
|
+
case arrow.Float32:
|
|
70
70
|
return 'float32';
|
|
71
|
-
case Float64:
|
|
71
|
+
case arrow.Float64:
|
|
72
72
|
return 'float64';
|
|
73
|
-
case Utf8:
|
|
73
|
+
case arrow.Utf8:
|
|
74
74
|
return 'utf8';
|
|
75
75
|
case Date:
|
|
76
76
|
const dateUnit = arrowType.unit;
|
|
77
|
-
return dateUnit === DateUnit.DAY ? 'date-day' : 'date-millisecond';
|
|
78
|
-
case DateDay:
|
|
77
|
+
return dateUnit === arrow.DateUnit.DAY ? 'date-day' : 'date-millisecond';
|
|
78
|
+
case arrow.DateDay:
|
|
79
79
|
return 'date-day';
|
|
80
|
-
case DateMillisecond:
|
|
80
|
+
case arrow.DateMillisecond:
|
|
81
81
|
return 'date-millisecond';
|
|
82
|
-
case Time:
|
|
82
|
+
case arrow.Time:
|
|
83
83
|
const timeUnit = arrowType.unit;
|
|
84
84
|
switch (timeUnit) {
|
|
85
|
-
case TimeUnit.SECOND:
|
|
85
|
+
case arrow.TimeUnit.SECOND:
|
|
86
86
|
return 'time-second';
|
|
87
|
-
case TimeUnit.MILLISECOND:
|
|
87
|
+
case arrow.TimeUnit.MILLISECOND:
|
|
88
88
|
return 'time-millisecond';
|
|
89
|
-
case TimeUnit.MICROSECOND:
|
|
89
|
+
case arrow.TimeUnit.MICROSECOND:
|
|
90
90
|
return 'time-microsecond';
|
|
91
|
-
case TimeUnit.NANOSECOND:
|
|
91
|
+
case arrow.TimeUnit.NANOSECOND:
|
|
92
92
|
return 'time-nanosecond';
|
|
93
93
|
default:
|
|
94
94
|
return 'time-second';
|
|
95
95
|
}
|
|
96
|
-
case TimeMillisecond:
|
|
96
|
+
case arrow.TimeMillisecond:
|
|
97
97
|
return 'time-millisecond';
|
|
98
|
-
case TimeSecond:
|
|
98
|
+
case arrow.TimeSecond:
|
|
99
99
|
return 'time-second';
|
|
100
|
-
case TimeMicrosecond:
|
|
100
|
+
case arrow.TimeMicrosecond:
|
|
101
101
|
return 'time-microsecond';
|
|
102
|
-
case TimeNanosecond:
|
|
102
|
+
case arrow.TimeNanosecond:
|
|
103
103
|
return 'time-nanosecond';
|
|
104
|
-
case Timestamp:
|
|
104
|
+
case arrow.Timestamp:
|
|
105
105
|
const timeStampUnit = arrowType.unit;
|
|
106
106
|
switch (timeStampUnit) {
|
|
107
|
-
case TimeUnit.SECOND:
|
|
107
|
+
case arrow.TimeUnit.SECOND:
|
|
108
108
|
return 'timestamp-second';
|
|
109
|
-
case TimeUnit.MILLISECOND:
|
|
109
|
+
case arrow.TimeUnit.MILLISECOND:
|
|
110
110
|
return 'timestamp-millisecond';
|
|
111
|
-
case TimeUnit.MICROSECOND:
|
|
111
|
+
case arrow.TimeUnit.MICROSECOND:
|
|
112
112
|
return 'timestamp-microsecond';
|
|
113
|
-
case TimeUnit.NANOSECOND:
|
|
113
|
+
case arrow.TimeUnit.NANOSECOND:
|
|
114
114
|
return 'timestamp-nanosecond';
|
|
115
115
|
default:
|
|
116
116
|
return 'timestamp-second';
|
|
117
117
|
}
|
|
118
|
-
case TimestampSecond:
|
|
118
|
+
case arrow.TimestampSecond:
|
|
119
119
|
return 'timestamp-second';
|
|
120
|
-
case TimestampMillisecond:
|
|
120
|
+
case arrow.TimestampMillisecond:
|
|
121
121
|
return 'timestamp-millisecond';
|
|
122
|
-
case TimestampMicrosecond:
|
|
122
|
+
case arrow.TimestampMicrosecond:
|
|
123
123
|
return 'timestamp-microsecond';
|
|
124
|
-
case TimestampNanosecond:
|
|
124
|
+
case arrow.TimestampNanosecond:
|
|
125
125
|
return 'timestamp-nanosecond';
|
|
126
|
-
case Interval:
|
|
126
|
+
case arrow.Interval:
|
|
127
127
|
const intervalUnit = arrowType.unit;
|
|
128
128
|
switch (intervalUnit) {
|
|
129
|
-
case IntervalUnit.DAY_TIME:
|
|
129
|
+
case arrow.IntervalUnit.DAY_TIME:
|
|
130
130
|
return 'interval-daytime';
|
|
131
|
-
case IntervalUnit.YEAR_MONTH:
|
|
131
|
+
case arrow.IntervalUnit.YEAR_MONTH:
|
|
132
132
|
return 'interval-yearmonth';
|
|
133
133
|
default:
|
|
134
134
|
return 'interval-daytime';
|
|
135
135
|
}
|
|
136
|
-
case IntervalDayTime:
|
|
136
|
+
case arrow.IntervalDayTime:
|
|
137
137
|
return 'interval-daytime';
|
|
138
|
-
case IntervalYearMonth:
|
|
138
|
+
case arrow.IntervalYearMonth:
|
|
139
139
|
return 'interval-yearmonth';
|
|
140
|
-
case List:
|
|
140
|
+
case arrow.List:
|
|
141
141
|
const listType = arrowType;
|
|
142
142
|
const listField = listType.valueField;
|
|
143
143
|
return {
|
|
144
144
|
type: 'list',
|
|
145
145
|
children: [serializeArrowField(listField)]
|
|
146
146
|
};
|
|
147
|
-
case FixedSizeList:
|
|
147
|
+
case arrow.FixedSizeList:
|
|
148
148
|
return {
|
|
149
149
|
type: 'fixed-size-list',
|
|
150
150
|
listSize: arrowType.listSize,
|
|
@@ -159,72 +159,72 @@ export function deserializeArrowType(dataType) {
|
|
|
159
159
|
switch (dataType.type) {
|
|
160
160
|
case 'list':
|
|
161
161
|
const field = deserializeArrowField(dataType.children[0]);
|
|
162
|
-
return new List(field);
|
|
162
|
+
return new arrow.List(field);
|
|
163
163
|
case 'fixed-size-list':
|
|
164
164
|
const child = deserializeArrowField(dataType.children[0]);
|
|
165
|
-
return new FixedSizeList(dataType.listSize, child);
|
|
165
|
+
return new arrow.FixedSizeList(dataType.listSize, child);
|
|
166
166
|
case 'struct':
|
|
167
167
|
const children = dataType.children.map(arrowField => deserializeArrowField(arrowField));
|
|
168
|
-
return new Struct(children);
|
|
168
|
+
return new arrow.Struct(children);
|
|
169
169
|
default:
|
|
170
170
|
throw new Error('array type not supported');
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
switch (dataType) {
|
|
174
174
|
case 'null':
|
|
175
|
-
return new Null();
|
|
175
|
+
return new arrow.Null();
|
|
176
176
|
case 'binary':
|
|
177
|
-
return new Binary();
|
|
177
|
+
return new arrow.Binary();
|
|
178
178
|
case 'bool':
|
|
179
|
-
return new Bool();
|
|
179
|
+
return new arrow.Bool();
|
|
180
180
|
case 'int8':
|
|
181
|
-
return new Int8();
|
|
181
|
+
return new arrow.Int8();
|
|
182
182
|
case 'int16':
|
|
183
|
-
return new Int16();
|
|
183
|
+
return new arrow.Int16();
|
|
184
184
|
case 'int32':
|
|
185
|
-
return new Int32();
|
|
185
|
+
return new arrow.Int32();
|
|
186
186
|
case 'int64':
|
|
187
|
-
return new Int64();
|
|
187
|
+
return new arrow.Int64();
|
|
188
188
|
case 'uint8':
|
|
189
|
-
return new Uint8();
|
|
189
|
+
return new arrow.Uint8();
|
|
190
190
|
case 'uint16':
|
|
191
|
-
return new Uint16();
|
|
191
|
+
return new arrow.Uint16();
|
|
192
192
|
case 'uint32':
|
|
193
|
-
return new Uint32();
|
|
193
|
+
return new arrow.Uint32();
|
|
194
194
|
case 'uint64':
|
|
195
|
-
return new Uint64();
|
|
195
|
+
return new arrow.Uint64();
|
|
196
196
|
case 'float16':
|
|
197
|
-
return new Float16();
|
|
197
|
+
return new arrow.Float16();
|
|
198
198
|
case 'float32':
|
|
199
|
-
return new Float32();
|
|
199
|
+
return new arrow.Float32();
|
|
200
200
|
case 'float64':
|
|
201
|
-
return new Float64();
|
|
201
|
+
return new arrow.Float64();
|
|
202
202
|
case 'utf8':
|
|
203
|
-
return new Utf8();
|
|
203
|
+
return new arrow.Utf8();
|
|
204
204
|
case 'date-day':
|
|
205
|
-
return new DateDay();
|
|
205
|
+
return new arrow.DateDay();
|
|
206
206
|
case 'date-millisecond':
|
|
207
|
-
return new DateMillisecond();
|
|
207
|
+
return new arrow.DateMillisecond();
|
|
208
208
|
case 'time-second':
|
|
209
|
-
return new TimeSecond();
|
|
209
|
+
return new arrow.TimeSecond();
|
|
210
210
|
case 'time-millisecond':
|
|
211
|
-
return new TimeMillisecond();
|
|
211
|
+
return new arrow.TimeMillisecond();
|
|
212
212
|
case 'time-microsecond':
|
|
213
|
-
return new TimeMicrosecond();
|
|
213
|
+
return new arrow.TimeMicrosecond();
|
|
214
214
|
case 'time-nanosecond':
|
|
215
|
-
return new TimeNanosecond();
|
|
215
|
+
return new arrow.TimeNanosecond();
|
|
216
216
|
case 'timestamp-second':
|
|
217
|
-
return new TimestampSecond();
|
|
217
|
+
return new arrow.TimestampSecond();
|
|
218
218
|
case 'timestamp-millisecond':
|
|
219
|
-
return new TimestampMillisecond();
|
|
219
|
+
return new arrow.TimestampMillisecond();
|
|
220
220
|
case 'timestamp-microsecond':
|
|
221
|
-
return new TimestampMicrosecond();
|
|
221
|
+
return new arrow.TimestampMicrosecond();
|
|
222
222
|
case 'timestamp-nanosecond':
|
|
223
|
-
return new TimestampNanosecond();
|
|
223
|
+
return new arrow.TimestampNanosecond();
|
|
224
224
|
case 'interval-daytime':
|
|
225
|
-
return new IntervalDayTime();
|
|
225
|
+
return new arrow.IntervalDayTime();
|
|
226
226
|
case 'interval-yearmonth':
|
|
227
|
-
return new IntervalYearMonth();
|
|
227
|
+
return new arrow.IntervalYearMonth();
|
|
228
228
|
default:
|
|
229
229
|
throw new Error('array type not supported');
|
|
230
230
|
}
|