@loaders.gl/arrow 4.0.1 → 4.0.3
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 +2 -2
- 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 +60 -29
- 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 +18 -19
- 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 +177 -137
- 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 +113 -86
- 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 +8 -5
- package/src/geoarrow/convert-geoarrow-to-binary-geometry.ts +26 -26
- 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 +126 -145
- package/src/tables/convert-arrow-to-table.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export const ArrowLoader = {
|
|
|
15
15
|
parseSync,
|
|
16
16
|
parseInBatches: parseArrowInBatches
|
|
17
17
|
};
|
|
18
|
-
export { getBinaryGeometriesFromArrow } from "./geoarrow/convert-geoarrow-to-binary-geometry.js";
|
|
18
|
+
export { BINARY_GEOMETRY_TEMPLATE, getBinaryGeometriesFromArrow } from "./geoarrow/convert-geoarrow-to-binary-geometry.js";
|
|
19
19
|
export { parseGeometryFromArrow } from "./geoarrow/convert-geoarrow-to-geojson.js";
|
|
20
|
+
export { updateBoundsFromGeoArrowSamples } from "./geoarrow/get-arrow-bounds.js";
|
|
20
21
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TableBatchBuilder","ArrowLoader","ArrowWorkerLoader","parseSync","parseArrowInBatches","ArrowTableBatchAggregator","ArrowBatch","getArrowType","serializeArrowSchema","deserializeArrowSchema","serializeArrowMetadata","deserializeArrowMetadata","serializeArrowField","deserializeArrowField","serializeArrowType","deserializeArrowType","VECTOR_TYPES","ArrowWriter","parse","arraybuffer","options","parseInBatches","getBinaryGeometriesFromArrow","parseGeometryFromArrow"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ArrowLoaderOptions} from './arrow-loader';\nimport type {ArrowTableBatch, ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';\nimport type {ArrowTable} from './lib/arrow-table';\n\nimport {TableBatchBuilder} from '@loaders.gl/schema';\nimport {ArrowLoader as ArrowWorkerLoader} from './arrow-loader';\nimport parseSync from './lib/parse-arrow-sync';\nimport {parseArrowInBatches} from './lib/parse-arrow-in-batches';\n\nimport {ArrowTableBatchAggregator} from './lib/arrow-table-batch';\n\n// Make the ArrowBatch type available\nTableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;\n\n// TYPES\n\nexport {getArrowType} from './schema/arrow-type-utils';\n\n// SCHEMA\n\nexport {\n serializeArrowSchema,\n deserializeArrowSchema,\n serializeArrowMetadata,\n deserializeArrowMetadata,\n serializeArrowField,\n deserializeArrowField,\n serializeArrowType,\n deserializeArrowType\n} from './schema/convert-arrow-schema';\n\n// Types\nexport type {ArrowTable, ArrowTableBatch} from './lib/arrow-table';\nexport {VECTOR_TYPES} from './types';\n\n// Arrow writer\n\nexport {ArrowWriter} from './arrow-writer';\n\n// Arrow loader\n\nexport type {ArrowLoaderOptions};\nexport {ArrowWorkerLoader};\n\n/** ArrowJS table loader */\nexport const ArrowLoader: LoaderWithParser<\n ArrowTable | ColumnarTable | ObjectRowTable,\n ArrowTableBatch,\n ArrowLoaderOptions\n> = {\n ...ArrowWorkerLoader,\n parse: async (arraybuffer: ArrayBuffer, options?: ArrowLoaderOptions) =>\n parseSync(arraybuffer, options),\n parseSync,\n parseInBatches: parseArrowInBatches\n};\n\n// Arrow Utils\nexport type {GeoArrowEncoding} from '@loaders.gl/gis';\n// getGeometryColumnsFromArrowTable,\n// getGeoArrowEncoding\n\nexport type {BinaryDataFromGeoArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';\nexport {getBinaryGeometriesFromArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';\n\nexport {parseGeometryFromArrow} from './geoarrow/convert-geoarrow-to-geojson';\n"],"mappings":"AAQA,SAAQA,iBAAiB,QAAO,oBAAoB;AAAC,SAC7CC,WAAW,IAAIC,iBAAiB;AAAA,OACjCC,SAAS;AAAA,SACRC,mBAAmB;AAAA,SAEnBC,yBAAyB;AAGjCL,iBAAiB,CAACM,UAAU,GAAGD,yBAAyB;AAAC,SAIjDE,YAAY;AAAA,SAKlBC,oBAAoB,EACpBC,sBAAsB,EACtBC,sBAAsB,EACtBC,wBAAwB,EACxBC,mBAAmB,EACnBC,qBAAqB,EACrBC,kBAAkB,EAClBC,oBAAoB;AAAA,SAKdC,YAAY;AAAA,SAIZC,WAAW;AAKnB,SAAQf,iBAAiB;AAGzB,OAAO,MAAMD,WAIZ,GAAG;EACF,GAAGC,iBAAiB;EACpBgB,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEC,OAA4B,KAClEjB,SAAS,CAACgB,WAAW,EAAEC,OAAO,CAAC;EACjCjB,SAAS;EACTkB,cAAc,EAAEjB;AAClB,CAAC;AAAC,
|
|
1
|
+
{"version":3,"file":"index.js","names":["TableBatchBuilder","ArrowLoader","ArrowWorkerLoader","parseSync","parseArrowInBatches","ArrowTableBatchAggregator","ArrowBatch","getArrowType","serializeArrowSchema","deserializeArrowSchema","serializeArrowMetadata","deserializeArrowMetadata","serializeArrowField","deserializeArrowField","serializeArrowType","deserializeArrowType","VECTOR_TYPES","ArrowWriter","parse","arraybuffer","options","parseInBatches","BINARY_GEOMETRY_TEMPLATE","getBinaryGeometriesFromArrow","parseGeometryFromArrow","updateBoundsFromGeoArrowSamples"],"sources":["../src/index.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {ArrowLoaderOptions} from './arrow-loader';\nimport type {ArrowTableBatch, ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';\nimport type {ArrowTable} from './lib/arrow-table';\n\nimport {TableBatchBuilder} from '@loaders.gl/schema';\nimport {ArrowLoader as ArrowWorkerLoader} from './arrow-loader';\nimport parseSync from './lib/parse-arrow-sync';\nimport {parseArrowInBatches} from './lib/parse-arrow-in-batches';\n\nimport {ArrowTableBatchAggregator} from './lib/arrow-table-batch';\n\n// Make the ArrowBatch type available\nTableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;\n\n// TYPES\n\nexport {getArrowType} from './schema/arrow-type-utils';\n\n// SCHEMA\n\nexport {\n serializeArrowSchema,\n deserializeArrowSchema,\n serializeArrowMetadata,\n deserializeArrowMetadata,\n serializeArrowField,\n deserializeArrowField,\n serializeArrowType,\n deserializeArrowType\n} from './schema/convert-arrow-schema';\n\n// Types\nexport type {ArrowTable, ArrowTableBatch} from './lib/arrow-table';\nexport {VECTOR_TYPES} from './types';\n\n// Arrow writer\n\nexport {ArrowWriter} from './arrow-writer';\n\n// Arrow loader\n\nexport type {ArrowLoaderOptions};\nexport {ArrowWorkerLoader};\n\n/** ArrowJS table loader */\nexport const ArrowLoader: LoaderWithParser<\n ArrowTable | ColumnarTable | ObjectRowTable,\n ArrowTableBatch,\n ArrowLoaderOptions\n> = {\n ...ArrowWorkerLoader,\n parse: async (arraybuffer: ArrayBuffer, options?: ArrowLoaderOptions) =>\n parseSync(arraybuffer, options),\n parseSync,\n parseInBatches: parseArrowInBatches\n};\n\n// Arrow Utils\nexport type {GeoArrowEncoding} from '@loaders.gl/gis';\n// getGeometryColumnsFromArrowTable,\n// getGeoArrowEncoding\n\nexport type {BinaryDataFromGeoArrow} from './geoarrow/convert-geoarrow-to-binary-geometry';\nexport {\n BINARY_GEOMETRY_TEMPLATE,\n getBinaryGeometriesFromArrow\n} from './geoarrow/convert-geoarrow-to-binary-geometry';\n\nexport {parseGeometryFromArrow} from './geoarrow/convert-geoarrow-to-geojson';\n\nexport {updateBoundsFromGeoArrowSamples} from './geoarrow/get-arrow-bounds';\n"],"mappings":"AAQA,SAAQA,iBAAiB,QAAO,oBAAoB;AAAC,SAC7CC,WAAW,IAAIC,iBAAiB;AAAA,OACjCC,SAAS;AAAA,SACRC,mBAAmB;AAAA,SAEnBC,yBAAyB;AAGjCL,iBAAiB,CAACM,UAAU,GAAGD,yBAAyB;AAAC,SAIjDE,YAAY;AAAA,SAKlBC,oBAAoB,EACpBC,sBAAsB,EACtBC,sBAAsB,EACtBC,wBAAwB,EACxBC,mBAAmB,EACnBC,qBAAqB,EACrBC,kBAAkB,EAClBC,oBAAoB;AAAA,SAKdC,YAAY;AAAA,SAIZC,WAAW;AAKnB,SAAQf,iBAAiB;AAGzB,OAAO,MAAMD,WAIZ,GAAG;EACF,GAAGC,iBAAiB;EACpBgB,KAAK,EAAE,MAAAA,CAAOC,WAAwB,EAAEC,OAA4B,KAClEjB,SAAS,CAACgB,WAAW,EAAEC,OAAO,CAAC;EACjCjB,SAAS;EACTkB,cAAc,EAAEjB;AAClB,CAAC;AAAC,SASAkB,wBAAwB,EACxBC,4BAA4B;AAAA,SAGtBC,sBAAsB;AAAA,SAEtBC,+BAA+B"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ColumnarTableBatchAggregator } from '@loaders.gl/schema';
|
|
2
2
|
import type { ArrowTableBatch } from './arrow-table';
|
|
3
|
-
import
|
|
3
|
+
import * as arrow from 'apache-arrow';
|
|
4
4
|
export declare class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
5
|
-
arrowSchema: Schema | null;
|
|
5
|
+
arrowSchema: arrow.Schema | null;
|
|
6
6
|
constructor(schema: any, options: any);
|
|
7
7
|
getBatch(): ArrowTableBatch | null;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-table-batch.d.ts","sourceRoot":"","sources":["../../src/lib/arrow-table-batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"arrow-table-batch.d.ts","sourceRoot":"","sources":["../../src/lib/arrow-table-batch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,qBAAa,yBAA0B,SAAQ,4BAA4B;IACzE,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;gBAErB,MAAM,KAAA,EAAE,OAAO,KAAA;IAK3B,QAAQ,IAAI,eAAe,GAAG,IAAI;CA4BnC"}
|
|
@@ -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,CAuJtE;AAED,+EAA+E;AAE/E,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAgFvE"}
|