@loaders.gl/arrow 4.3.0-alpha.8 → 4.3.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow-loader.d.ts +6 -38
- package/dist/arrow-loader.d.ts.map +1 -1
- package/dist/arrow-loader.js +2 -29
- package/dist/arrow-worker.js +2654 -1710
- package/dist/arrow-writer.d.ts +1 -1
- package/dist/arrow-writer.d.ts.map +1 -1
- package/dist/arrow-writer.js +2 -2
- package/dist/dist.dev.js +1863 -1768
- package/dist/dist.min.js +5 -5
- package/dist/exports/arrow-loader.d.ts +34 -0
- package/dist/exports/arrow-loader.d.ts.map +1 -0
- package/dist/exports/arrow-loader.js +30 -0
- package/dist/exports/geoarrow-loader.d.ts +27 -0
- package/dist/exports/geoarrow-loader.d.ts.map +1 -0
- package/dist/exports/geoarrow-loader.js +13 -0
- package/dist/geoarrow-loader.d.ts +3 -27
- package/dist/geoarrow-loader.d.ts.map +1 -1
- package/dist/geoarrow-loader.js +2 -12
- package/dist/geoarrow-writer.d.ts +2 -2
- package/dist/geoarrow-writer.d.ts.map +1 -1
- package/dist/geoarrow-writer.js +2 -2
- package/dist/index.cjs +426 -387
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +14 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -12
- package/dist/lib/encoders/encode-arrow.d.ts.map +1 -0
- package/dist/lib/encoders/encode-geoarrow.d.ts.map +1 -0
- package/dist/lib/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +1 -0
- package/dist/lib/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +1 -0
- package/dist/lib/geoarrow/get-arrow-bounds.d.ts.map +1 -0
- package/dist/lib/parsers/parse-arrow.d.ts +9 -0
- package/dist/lib/parsers/parse-arrow.d.ts.map +1 -0
- package/dist/{parsers/parse-arrow-in-batches.js → lib/parsers/parse-arrow.js} +7 -3
- package/dist/lib/parsers/parse-geoarrow.d.ts +9 -0
- package/dist/lib/parsers/parse-geoarrow.d.ts.map +1 -0
- package/dist/{parsers/parse-geoarrow-sync.js → lib/parsers/parse-geoarrow.js} +9 -3
- package/dist/{schema → lib/tables}/convert-arrow-schema.d.ts +4 -0
- package/dist/lib/tables/convert-arrow-schema.d.ts.map +1 -0
- package/dist/{schema → lib/tables}/convert-arrow-schema.js +8 -0
- package/dist/lib/tables/convert-arrow-to-table.d.ts +15 -0
- package/dist/lib/tables/convert-arrow-to-table.d.ts.map +1 -0
- package/dist/lib/tables/convert-arrow-to-table.js +104 -0
- package/dist/lib/tables/convert-table-to-arrow.d.ts +16 -0
- package/dist/lib/tables/convert-table-to-arrow.d.ts.map +1 -0
- package/dist/lib/tables/convert-table-to-arrow.js +56 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/{lib → schema}/arrow-table-batch.d.ts +2 -1
- package/dist/schema/arrow-table-batch.d.ts.map +1 -0
- package/dist/{lib → schema}/arrow-table-batch.js +1 -0
- package/dist/{lib/arrow-table.d.ts → schema/arrow-table-type.d.ts} +3 -1
- package/dist/schema/arrow-table-type.d.ts.map +1 -0
- package/dist/triangulate-on-worker.js +1 -1
- package/dist/triangulation-worker.js +13 -5
- package/dist/workers/triangulation-worker.js +1 -1
- package/package.json +11 -7
- package/src/arrow-loader.ts +6 -57
- package/src/arrow-writer.ts +1 -2
- package/src/exports/arrow-loader.ts +49 -0
- package/src/exports/geoarrow-loader.ts +24 -0
- package/src/geoarrow-loader.ts +6 -22
- package/src/geoarrow-writer.ts +1 -1
- package/src/index.ts +23 -23
- package/src/{parsers/parse-arrow-in-batches.ts → lib/parsers/parse-arrow.ts} +11 -5
- package/src/lib/parsers/parse-geoarrow.ts +32 -0
- package/src/{schema → lib/tables}/convert-arrow-schema.ts +10 -0
- package/src/lib/tables/convert-arrow-to-table.ts +144 -0
- package/src/lib/tables/convert-table-to-arrow.ts +72 -0
- package/src/{lib → schema}/arrow-table-batch.ts +2 -1
- package/src/{lib/arrow-table.ts → schema/arrow-table-type.ts} +2 -0
- package/src/workers/triangulation-worker.ts +1 -1
- package/dist/geoarrow/convert-geoarrow-to-binary-geometry.d.ts.map +0 -1
- package/dist/geoarrow/convert-geoarrow-to-geojson-geometry.d.ts.map +0 -1
- package/dist/geoarrow/get-arrow-bounds.d.ts.map +0 -1
- package/dist/lib/arrow-table-batch.d.ts.map +0 -1
- package/dist/lib/arrow-table.d.ts.map +0 -1
- package/dist/lib/encode-arrow.d.ts.map +0 -1
- package/dist/lib/encode-geoarrow.d.ts.map +0 -1
- package/dist/parsers/parse-arrow-in-batches.d.ts +0 -6
- package/dist/parsers/parse-arrow-in-batches.d.ts.map +0 -1
- package/dist/parsers/parse-arrow-sync.d.ts +0 -6
- package/dist/parsers/parse-arrow-sync.d.ts.map +0 -1
- package/dist/parsers/parse-arrow-sync.js +0 -32
- package/dist/parsers/parse-geoarrow-in-batches.d.ts +0 -6
- package/dist/parsers/parse-geoarrow-in-batches.d.ts.map +0 -1
- package/dist/parsers/parse-geoarrow-in-batches.js +0 -10
- package/dist/parsers/parse-geoarrow-sync.d.ts +0 -6
- package/dist/parsers/parse-geoarrow-sync.d.ts.map +0 -1
- package/dist/schema/arrow-type-utils.d.ts +0 -5
- package/dist/schema/arrow-type-utils.d.ts.map +0 -1
- package/dist/schema/arrow-type-utils.js +0 -51
- package/dist/schema/convert-arrow-schema.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-columnar-table.d.ts +0 -8
- package/dist/tables/convert-arrow-to-columnar-table.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-columnar-table.js +0 -24
- package/dist/tables/convert-arrow-to-geojson-table.d.ts +0 -16
- package/dist/tables/convert-arrow-to-geojson-table.d.ts.map +0 -1
- package/dist/tables/convert-arrow-to-geojson-table.js +0 -54
- package/dist/tables/convert-columnar-to-row-table.d.ts +0 -7
- package/dist/tables/convert-columnar-to-row-table.d.ts.map +0 -1
- package/dist/tables/convert-columnar-to-row-table.js +0 -25
- package/dist/tables/convert-table-to-arrow.d.ts +0 -42
- package/dist/tables/convert-table-to-arrow.d.ts.map +0 -1
- package/dist/tables/convert-table-to-arrow.js +0 -59
- package/dist/types.d.ts.map +0 -1
- package/src/parsers/parse-arrow-sync.ts +0 -44
- package/src/parsers/parse-geoarrow-in-batches.ts +0 -16
- package/src/parsers/parse-geoarrow-sync.ts +0 -23
- package/src/schema/arrow-type-utils.ts +0 -55
- package/src/tables/convert-arrow-to-columnar-table.ts +0 -31
- package/src/tables/convert-arrow-to-geojson-table.ts +0 -66
- package/src/tables/convert-columnar-to-row-table.ts +0 -31
- package/src/tables/convert-table-to-arrow.ts +0 -61
- /package/dist/lib/{encode-arrow.d.ts → encoders/encode-arrow.d.ts} +0 -0
- /package/dist/lib/{encode-arrow.js → encoders/encode-arrow.js} +0 -0
- /package/dist/lib/{encode-geoarrow.d.ts → encoders/encode-geoarrow.d.ts} +0 -0
- /package/dist/lib/{encode-geoarrow.js → encoders/encode-geoarrow.js} +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.d.ts +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.js +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.d.ts +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.js +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.d.ts +0 -0
- /package/dist/{geoarrow → lib/geoarrow}/get-arrow-bounds.js +0 -0
- /package/dist/{types.d.ts → lib/types.d.ts} +0 -0
- /package/dist/{types.js → lib/types.js} +0 -0
- /package/dist/{lib/arrow-table.js → schema/arrow-table-type.js} +0 -0
- /package/src/lib/{encode-arrow.ts → encoders/encode-arrow.ts} +0 -0
- /package/src/lib/{encode-geoarrow.ts → encoders/encode-geoarrow.ts} +0 -0
- /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-binary-geometry.ts +0 -0
- /package/src/{geoarrow → lib/geoarrow}/convert-geoarrow-to-geojson-geometry.ts +0 -0
- /package/src/{geoarrow → lib/geoarrow}/get-arrow-bounds.ts +0 -0
- /package/src/{types.ts → lib/types.ts} +0 -0
package/src/index.ts
CHANGED
|
@@ -2,35 +2,33 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// Types
|
|
6
|
+
export type {ArrowTable, ArrowTableBatch} from './schema/arrow-table-type';
|
|
7
|
+
export {VECTOR_TYPES} from './lib/types';
|
|
8
|
+
import {ArrowTableBatchAggregator} from './schema/arrow-table-batch';
|
|
8
9
|
|
|
9
10
|
// Make the ArrowBatch type available
|
|
11
|
+
import {TableBatchBuilder} from '@loaders.gl/schema';
|
|
10
12
|
TableBatchBuilder.ArrowBatch = ArrowTableBatchAggregator;
|
|
11
13
|
|
|
12
|
-
// TYPES
|
|
13
|
-
|
|
14
|
-
export {getArrowType} from './schema/arrow-type-utils';
|
|
15
|
-
|
|
16
|
-
// SCHEMA
|
|
17
|
-
|
|
18
|
-
// Types
|
|
19
|
-
export type {ArrowTable, ArrowTableBatch} from './lib/arrow-table';
|
|
20
|
-
export {VECTOR_TYPES} from './types';
|
|
21
|
-
|
|
22
14
|
// Arrow loader / Writer
|
|
23
15
|
|
|
24
|
-
export type {ArrowLoaderOptions};
|
|
25
|
-
export {
|
|
16
|
+
export type {ArrowLoaderOptions} from './exports/arrow-loader';
|
|
17
|
+
export {ArrowWorkerLoader} from './exports/arrow-loader';
|
|
18
|
+
export {ArrowLoader} from './arrow-loader';
|
|
26
19
|
|
|
27
20
|
export {ArrowWriter} from './arrow-writer';
|
|
28
21
|
|
|
29
22
|
// Geoarrow loader
|
|
30
|
-
export {
|
|
23
|
+
export {GeoArrowWorkerLoader} from './exports/geoarrow-loader';
|
|
24
|
+
export {GeoArrowLoader} from './geoarrow-loader';
|
|
31
25
|
|
|
32
26
|
// Schema utils
|
|
33
27
|
export {
|
|
28
|
+
convertArrowToSchema,
|
|
29
|
+
convertSchemaToArrow,
|
|
30
|
+
|
|
31
|
+
// DETAILED FUNCTIONS
|
|
34
32
|
serializeArrowSchema,
|
|
35
33
|
deserializeArrowSchema,
|
|
36
34
|
serializeArrowMetadata,
|
|
@@ -39,7 +37,11 @@ export {
|
|
|
39
37
|
deserializeArrowField,
|
|
40
38
|
serializeArrowType,
|
|
41
39
|
deserializeArrowType
|
|
42
|
-
} from './
|
|
40
|
+
} from './lib//tables/convert-arrow-schema';
|
|
41
|
+
|
|
42
|
+
// Table utils
|
|
43
|
+
export {convertArrowToTable} from './lib/tables/convert-arrow-to-table';
|
|
44
|
+
export {convertTableToArrow} from './lib/tables/convert-table-to-arrow';
|
|
43
45
|
|
|
44
46
|
// EXPERIMENTAL
|
|
45
47
|
|
|
@@ -51,19 +53,17 @@ export type {GeoArrowEncoding} from '@loaders.gl/gis';
|
|
|
51
53
|
export type {
|
|
52
54
|
BinaryDataFromGeoArrow,
|
|
53
55
|
BinaryGeometriesFromArrowOptions
|
|
54
|
-
} from './geoarrow/convert-geoarrow-to-binary-geometry';
|
|
56
|
+
} from './lib/geoarrow/convert-geoarrow-to-binary-geometry';
|
|
55
57
|
export {
|
|
56
58
|
getBinaryGeometryTemplate,
|
|
57
59
|
getBinaryGeometriesFromArrow,
|
|
58
60
|
getTriangleIndices,
|
|
59
61
|
getMeanCentersFromBinaryGeometries
|
|
60
|
-
} from './geoarrow/convert-geoarrow-to-binary-geometry';
|
|
61
|
-
|
|
62
|
-
export {updateBoundsFromGeoArrowSamples} from './geoarrow/get-arrow-bounds';
|
|
62
|
+
} from './lib/geoarrow/convert-geoarrow-to-binary-geometry';
|
|
63
63
|
|
|
64
|
-
export {
|
|
64
|
+
export {updateBoundsFromGeoArrowSamples} from './lib/geoarrow/get-arrow-bounds';
|
|
65
65
|
|
|
66
|
-
export {
|
|
66
|
+
export {parseGeometryFromArrow} from './lib/geoarrow/convert-geoarrow-to-geojson-geometry';
|
|
67
67
|
|
|
68
68
|
// EXPERIMENTAL WORKER
|
|
69
69
|
export {hardClone} from './workers/hard-clone';
|
|
@@ -2,13 +2,19 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {ArrowTableBatch} from '../lib/arrow-table';
|
|
6
5
|
import * as arrow from 'apache-arrow';
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import type {Table} from '@loaders.gl/schema';
|
|
7
|
+
import type {ArrowTableBatch} from '../../schema/arrow-table-type';
|
|
8
|
+
import {ArrowLoaderOptions} from '../../exports/arrow-loader';
|
|
9
|
+
import {convertArrowToTable} from '../tables/convert-arrow-to-table';
|
|
10
|
+
|
|
11
|
+
/** Parses arrow to a loaders.gl table. Defaults to `arrow-table` */
|
|
12
|
+
export function parseArrowSync(arrayBuffer, options?: {shape?: Table['shape']}): Table {
|
|
13
|
+
const shape = options?.shape || 'arrow-table';
|
|
14
|
+
const arrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
15
|
+
return convertArrowToTable(arrowTable, shape);
|
|
16
|
+
}
|
|
9
17
|
|
|
10
|
-
/**
|
|
11
|
-
*/
|
|
12
18
|
export function parseArrowInBatches(
|
|
13
19
|
asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,
|
|
14
20
|
options?: ArrowLoaderOptions
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {GeoJSONTable, GeoJSONTableBatch} from '@loaders.gl/schema';
|
|
6
|
+
import type {ArrowTable, ArrowTableBatch} from '../../schema/arrow-table-type';
|
|
7
|
+
import {parseArrowSync, parseArrowInBatches} from './parse-arrow';
|
|
8
|
+
import {convertArrowToTable} from '../tables/convert-arrow-to-table';
|
|
9
|
+
|
|
10
|
+
// Parses arrow to a columnar table
|
|
11
|
+
export function parseGeoArrowSync(
|
|
12
|
+
arrayBuffer,
|
|
13
|
+
options?: {shape?: 'arrow-table' | 'geojson-table' | 'binary-geometry'}
|
|
14
|
+
): ArrowTable | GeoJSONTable {
|
|
15
|
+
// | BinaryGeometry
|
|
16
|
+
const table = parseArrowSync(arrayBuffer, {shape: 'arrow-table'}) as ArrowTable;
|
|
17
|
+
switch (options?.shape) {
|
|
18
|
+
case 'geojson-table':
|
|
19
|
+
return convertArrowToTable(table.data, 'geojson-table');
|
|
20
|
+
default:
|
|
21
|
+
return table;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*/
|
|
27
|
+
export function parseGeoArrowInBatches(
|
|
28
|
+
asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>
|
|
29
|
+
): AsyncIterable<ArrowTableBatch | GeoJSONTableBatch> {
|
|
30
|
+
// | BinaryGeometry
|
|
31
|
+
return parseArrowInBatches(asyncIterator);
|
|
32
|
+
}
|
|
@@ -5,6 +5,16 @@
|
|
|
5
5
|
import type {DataType, Field, Schema, SchemaMetadata} from '@loaders.gl/schema';
|
|
6
6
|
import * as arrow from 'apache-arrow';
|
|
7
7
|
|
|
8
|
+
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
9
|
+
export function convertArrowToSchema(arrowSchema: arrow.Schema): Schema {
|
|
10
|
+
return serializeArrowSchema(arrowSchema);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
14
|
+
export function convertSchemaToArrow(schema: Schema): arrow.Schema {
|
|
15
|
+
return deserializeArrowSchema(schema);
|
|
16
|
+
}
|
|
17
|
+
|
|
8
18
|
/** Convert Apache Arrow Schema (class instance) to a serialized Schema (plain data) */
|
|
9
19
|
export function serializeArrowSchema(arrowSchema: arrow.Schema): Schema {
|
|
10
20
|
return {
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
import type {
|
|
7
|
+
Table,
|
|
8
|
+
ArrayRowTable,
|
|
9
|
+
ColumnarTable,
|
|
10
|
+
ObjectRowTable,
|
|
11
|
+
GeoJSONTable,
|
|
12
|
+
Feature
|
|
13
|
+
} from '@loaders.gl/schema';
|
|
14
|
+
import type {ArrowTable} from '../../schema/arrow-table-type';
|
|
15
|
+
|
|
16
|
+
import {convertTable} from '@loaders.gl/schema';
|
|
17
|
+
import {getGeometryColumnsFromSchema} from '@loaders.gl/gis';
|
|
18
|
+
import {convertArrowToSchema} from '../tables/convert-arrow-schema';
|
|
19
|
+
import {parseGeometryFromArrow} from '../geoarrow/convert-geoarrow-to-geojson-geometry';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Convert an Apache Arrow table to a loaders.gl Table
|
|
23
|
+
* @note Currently does not convert schema
|
|
24
|
+
*/
|
|
25
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: 'arrow-table'): ArrowTable;
|
|
26
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: 'columnar-table'): ColumnarTable;
|
|
27
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: 'object-row-table'): ObjectRowTable;
|
|
28
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: 'array-row-table'): ArrayRowTable;
|
|
29
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: 'geojson-table'): GeoJSONTable;
|
|
30
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: 'columnar-table'): ColumnarTable;
|
|
31
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: Table['shape']): Table;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Convert an Apache Arrow table to a loaders.gl Table
|
|
35
|
+
* @note Currently does not convert schema
|
|
36
|
+
*/
|
|
37
|
+
export function convertArrowToTable(arrowTable: arrow.Table, shape: Table['shape']): Table {
|
|
38
|
+
switch (shape) {
|
|
39
|
+
case 'arrow-table':
|
|
40
|
+
return convertArrowToArrowTable(arrowTable);
|
|
41
|
+
case 'array-row-table':
|
|
42
|
+
return convertArrowToArrayRowTable(arrowTable);
|
|
43
|
+
case 'object-row-table':
|
|
44
|
+
return convertArrowToObjectRowTable(arrowTable);
|
|
45
|
+
case 'columnar-table':
|
|
46
|
+
return convertArrowToColumnarTable(arrowTable);
|
|
47
|
+
case 'geojson-table':
|
|
48
|
+
return convertArrowToGeoJSONTable(arrowTable);
|
|
49
|
+
default:
|
|
50
|
+
throw new Error(shape);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Wrap an apache arrow table in a loaders.gl table wrapper.
|
|
56
|
+
* From this additional conversions are available.
|
|
57
|
+
* @param arrowTable
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
function convertArrowToArrowTable(arrowTable: arrow.Table): ArrowTable {
|
|
61
|
+
return {
|
|
62
|
+
shape: 'arrow-table',
|
|
63
|
+
schema: convertArrowToSchema(arrowTable.schema),
|
|
64
|
+
data: arrowTable
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function convertArrowToArrayRowTable(arrowTable: arrow.Table): Table {
|
|
69
|
+
const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
70
|
+
return convertTable(columnarTable, 'array-row-table');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function convertArrowToObjectRowTable(arrowTable: arrow.Table): Table {
|
|
74
|
+
const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
75
|
+
return convertTable(columnarTable, 'object-row-table');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Convert an Apache Arrow table to a ColumnarTable
|
|
80
|
+
* @note Currently does not convert schema
|
|
81
|
+
*/
|
|
82
|
+
function convertArrowToColumnarTable(arrowTable: arrow.Table): ColumnarTable {
|
|
83
|
+
// TODO - avoid calling `getColumn` on columns we are not interested in?
|
|
84
|
+
// Add options object?
|
|
85
|
+
|
|
86
|
+
const columns: ColumnarTable['data'] = {};
|
|
87
|
+
|
|
88
|
+
for (const field of arrowTable.schema.fields) {
|
|
89
|
+
// This (is intended to) coalesce all record batches into a single typed array
|
|
90
|
+
const arrowColumn = arrowTable.getChild(field.name);
|
|
91
|
+
const values = arrowColumn?.toArray();
|
|
92
|
+
columns[field.name] = values;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const schema = convertArrowToSchema(arrowTable.schema);
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
shape: 'columnar-table',
|
|
99
|
+
schema,
|
|
100
|
+
data: columns
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Convert an Apache Arrow table to a GeoJSONTable
|
|
106
|
+
* @note Currently does not convert schema
|
|
107
|
+
*/
|
|
108
|
+
function convertArrowToGeoJSONTable(arrowTable: arrow.Table): GeoJSONTable {
|
|
109
|
+
const schema = convertArrowToSchema(arrowTable.schema);
|
|
110
|
+
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
111
|
+
|
|
112
|
+
// get encoding from geometryColumns['geometry']
|
|
113
|
+
const encoding = geometryColumns.geometry.encoding;
|
|
114
|
+
|
|
115
|
+
const features: Feature[] = [];
|
|
116
|
+
|
|
117
|
+
// Remove geometry columns
|
|
118
|
+
const propertyColumnNames = arrowTable.schema.fields
|
|
119
|
+
.map((field) => field.name)
|
|
120
|
+
// TODO - this deletes all geometry columns
|
|
121
|
+
.filter((name) => !(name in geometryColumns));
|
|
122
|
+
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
123
|
+
|
|
124
|
+
const arrowGeometryColumn = arrowTable.getChild('geometry');
|
|
125
|
+
|
|
126
|
+
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
127
|
+
// get the geometry value from arrow geometry column
|
|
128
|
+
// Note that type can vary
|
|
129
|
+
const arrowGeometry = arrowGeometryColumn?.get(row);
|
|
130
|
+
// parse arrow geometry to geojson feature
|
|
131
|
+
const feature = parseGeometryFromArrow(arrowGeometry, encoding);
|
|
132
|
+
if (feature) {
|
|
133
|
+
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
134
|
+
features.push({type: 'Feature', geometry: feature, properties});
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
shape: 'geojson-table',
|
|
140
|
+
type: 'FeatureCollection',
|
|
141
|
+
schema,
|
|
142
|
+
features
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
import {Table, getTableLength, getTableNumCols, getTableCellAt} from '@loaders.gl/schema';
|
|
7
|
+
import {deserializeArrowSchema} from '../tables/convert-arrow-schema';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* * Convert a loaders.gl Table to an Apache Arrow Table
|
|
11
|
+
* @param mesh
|
|
12
|
+
* @param metadata
|
|
13
|
+
* @param batchSize
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
export function convertTableToArrow(table: Table, options?: {batchSize?: number}): arrow.Table {
|
|
17
|
+
switch (table.shape) {
|
|
18
|
+
case 'arrow-table':
|
|
19
|
+
return table.data as arrow.Table;
|
|
20
|
+
|
|
21
|
+
case 'columnar-table':
|
|
22
|
+
// TODO - optimized implementation is possible
|
|
23
|
+
// return convertColumnarTableToArrow(table, options);
|
|
24
|
+
|
|
25
|
+
// fall through
|
|
26
|
+
|
|
27
|
+
default:
|
|
28
|
+
const arrowBatchIterator = makeTableToArrowBatchesIterator(table, options);
|
|
29
|
+
return new arrow.Table(arrowBatchIterator);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function* makeTableToArrowBatchesIterator(
|
|
34
|
+
table: Table,
|
|
35
|
+
options?: {batchSize?: number}
|
|
36
|
+
): IterableIterator<arrow.RecordBatch> {
|
|
37
|
+
const arrowSchema = deserializeArrowSchema(table.schema!);
|
|
38
|
+
|
|
39
|
+
const length = getTableLength(table);
|
|
40
|
+
const numColumns = getTableNumCols(table);
|
|
41
|
+
const batchSize = options?.batchSize || length;
|
|
42
|
+
|
|
43
|
+
const builders = arrowSchema?.fields.map((arrowField) => arrow.makeBuilder(arrowField));
|
|
44
|
+
const structField = new arrow.Struct(arrowSchema.fields);
|
|
45
|
+
|
|
46
|
+
let batchLength = 0;
|
|
47
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
48
|
+
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
49
|
+
const value = getTableCellAt(table, rowIndex, columnIndex);
|
|
50
|
+
|
|
51
|
+
const builder = builders[columnIndex];
|
|
52
|
+
builder.append(value);
|
|
53
|
+
batchLength++;
|
|
54
|
+
|
|
55
|
+
if (batchLength >= batchSize) {
|
|
56
|
+
const datas = builders.map((builder) => builder.flush());
|
|
57
|
+
const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);
|
|
58
|
+
yield new arrow.RecordBatch(arrowSchema, structData);
|
|
59
|
+
batchLength = 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (batchLength > 0) {
|
|
65
|
+
const datas = builders.map((builder) => builder.flush());
|
|
66
|
+
const structData = new arrow.Data(structField, 0, batchLength, 0, undefined, datas);
|
|
67
|
+
yield new arrow.RecordBatch(arrowSchema, structData);
|
|
68
|
+
batchLength = 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
builders.map((builder) => builder.finish());
|
|
72
|
+
}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {ColumnarTableBatchAggregator} from '@loaders.gl/schema';
|
|
6
|
-
import type {ArrowTableBatch} from './arrow-table';
|
|
6
|
+
import type {ArrowTableBatch} from './arrow-table-type';
|
|
7
7
|
import * as arrow from 'apache-arrow';
|
|
8
8
|
|
|
9
|
+
/** @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency */
|
|
9
10
|
export class ArrowTableBatchAggregator extends ColumnarTableBatchAggregator {
|
|
10
11
|
arrowSchema: arrow.Schema | null;
|
|
11
12
|
|
|
@@ -8,6 +8,7 @@ import type * as arrow from 'apache-arrow';
|
|
|
8
8
|
/**
|
|
9
9
|
* A table organized as an Apache Arrow table
|
|
10
10
|
* @note This is a variant of the type from loaders.gl/schema
|
|
11
|
+
* @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency
|
|
11
12
|
*/
|
|
12
13
|
export type ArrowTable = {
|
|
13
14
|
shape: 'arrow-table';
|
|
@@ -18,6 +19,7 @@ export type ArrowTable = {
|
|
|
18
19
|
/**
|
|
19
20
|
* Batch for a table organized as an Apache Arrow table
|
|
20
21
|
* @note This is a variant of the type from loaders.gl/schema
|
|
22
|
+
* @note Should be part of @loaders.gl/schema - kept separate to avoid hard arrow dependency
|
|
21
23
|
*/
|
|
22
24
|
export type ArrowTableBatch = Batch & {
|
|
23
25
|
shape: 'arrow-table';
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getTriangleIndices,
|
|
9
9
|
getBinaryGeometriesFromArrow,
|
|
10
10
|
BinaryDataFromGeoArrow
|
|
11
|
-
} from '../geoarrow/convert-geoarrow-to-binary-geometry';
|
|
11
|
+
} from '../lib/geoarrow/convert-geoarrow-to-binary-geometry';
|
|
12
12
|
import type {
|
|
13
13
|
TriangulationWorkerInput,
|
|
14
14
|
TriangulateInput,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-geoarrow-to-binary-geometry.d.ts","sourceRoot":"","sources":["../../src/geoarrow/convert-geoarrow-to-binary-geometry.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAC,uBAAuB,IAAI,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAajD;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,oEAAoE;IACpE,gBAAgB,EAAE,cAAc,EAAE,CAAC;IACnC,wCAAwC;IACxC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,6CAA6C;IAC7C,YAAY,EAAE;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAC,CAAC;IAChE,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC;CAC1B,CAAC;AAsBF;;GAEG;AACH,wBAAgB,yBAAyB;;;;;;;;;;;;;;;EAQxC;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC7C,6FAA6F;IAC7F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mHAAmH;IACnH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,KAAK,CAAC,MAAM,EACvB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,gCAAgC,GACzC,sBAAsB,CAiFxB;AAED;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,gBAAgB,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,EAAE,CAiCjG;AA2ED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,WAAW,EAC3B,uBAAuB,EAAE,UAAU,EACnC,mBAAmB,EAAE,YAAY,EACjC,IAAI,EAAE,MAAM,GACX,WAAW,GAAG,IAAI,CAyCpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-geoarrow-to-geojson-geometry.d.ts","sourceRoot":"","sources":["../../src/geoarrow/convert-geoarrow-to-geojson-geometry.ts"],"names":[],"mappings":"AAKA,OAAO,EAQL,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAmB,KAAK,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAGxE;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,GAAG,EACnB,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,QAAQ,GAAG,IAAI,CAwCjB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-arrow-bounds.d.ts","sourceRoot":"","sources":["../../src/geoarrow/get-arrow-bounds.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,YAAY,EACxB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EACxC,UAAU,GAAE,MAAY,GACvB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAsBlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-table-batch.d.ts","sourceRoot":"","sources":["../../src/lib/arrow-table-batch.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,4BAA4B,EAAC,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAC,eAAe,EAAC,yBAAsB;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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-table.d.ts","sourceRoot":"","sources":["../../src/lib/arrow-table.ts"],"names":[],"mappings":"AAIA,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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode-arrow.d.ts","sourceRoot":"","sources":["../../src/lib/encode-arrow.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAe,oBAAiB;AAEpD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC;AAEJ;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,WAAW,CAShE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode-geoarrow.d.ts","sourceRoot":"","sources":["../../src/lib/encode-geoarrow.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,YAAY,EAAe,oBAAiB;AAEpD,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;CACd,EAAE,CAAC;AAEJ;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,aAAa,GAAG,WAAW,CASnE"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ArrowTableBatch } from "../lib/arrow-table.js";
|
|
2
|
-
import { ArrowLoaderOptions } from "../arrow-loader.js";
|
|
3
|
-
/**
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseArrowInBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: ArrowLoaderOptions): AsyncIterable<ArrowTableBatch>;
|
|
6
|
-
//# sourceMappingURL=parse-arrow-in-batches.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-arrow-in-batches.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-arrow-in-batches.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,8BAA2B;AAExD,OAAO,EAAC,kBAAkB,EAAC,2BAAwB;AAGnD;GACG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACjE,OAAO,CAAC,EAAE,kBAAkB,GAC3B,aAAa,CAAC,eAAe,CAAC,CA0ChC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ArrayRowTable, ColumnarTable, ObjectRowTable } from '@loaders.gl/schema';
|
|
2
|
-
import type { ArrowTable } from "../lib/arrow-table.js";
|
|
3
|
-
export declare function parseArrowSync(arrayBuffer: any, options?: {
|
|
4
|
-
shape?: 'arrow-table' | 'columnar-table' | 'object-row-table' | 'array-row-table';
|
|
5
|
-
}): ArrowTable | ColumnarTable | ObjectRowTable | ArrayRowTable;
|
|
6
|
-
//# sourceMappingURL=parse-arrow-sync.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-arrow-sync.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-arrow-sync.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,aAAa,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AACrF,OAAO,KAAK,EAAC,UAAU,EAAC,8BAA2B;AAOnD,wBAAgB,cAAc,CAC5B,WAAW,KAAA,EACX,OAAO,CAAC,EAAE;IAAC,KAAK,CAAC,EAAE,aAAa,GAAG,gBAAgB,GAAG,kBAAkB,GAAG,iBAAiB,CAAA;CAAC,GAC5F,UAAU,GAAG,aAAa,GAAG,cAAc,GAAG,aAAa,CA4B7D"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { convertTable } from '@loaders.gl/schema';
|
|
5
|
-
import * as arrow from 'apache-arrow';
|
|
6
|
-
import { convertArrowToColumnarTable } from "../tables/convert-arrow-to-columnar-table.js";
|
|
7
|
-
import { serializeArrowSchema } from "../schema/convert-arrow-schema.js";
|
|
8
|
-
// Parses arrow to a columnar table
|
|
9
|
-
export function parseArrowSync(arrayBuffer, options) {
|
|
10
|
-
const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
11
|
-
const arrowTable = {
|
|
12
|
-
shape: 'arrow-table',
|
|
13
|
-
schema: serializeArrowSchema(apacheArrowTable.schema),
|
|
14
|
-
data: apacheArrowTable
|
|
15
|
-
};
|
|
16
|
-
const shape = options?.shape || 'arrow-table';
|
|
17
|
-
switch (shape) {
|
|
18
|
-
case 'arrow-table':
|
|
19
|
-
return arrowTable;
|
|
20
|
-
case 'columnar-table':
|
|
21
|
-
return convertArrowToColumnarTable(arrowTable);
|
|
22
|
-
case 'object-row-table':
|
|
23
|
-
let columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
24
|
-
return convertTable(columnarTable, 'object-row-table');
|
|
25
|
-
case 'array-row-table':
|
|
26
|
-
columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
27
|
-
return convertTable(columnarTable, 'array-row-table');
|
|
28
|
-
default:
|
|
29
|
-
// TODO
|
|
30
|
-
throw new Error(shape);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { GeoJSONTableBatch } from '@loaders.gl/schema';
|
|
2
|
-
import type { ArrowTableBatch } from "../lib/arrow-table.js";
|
|
3
|
-
/**
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseGeoArrowInBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>): AsyncIterable<ArrowTableBatch | GeoJSONTableBatch>;
|
|
6
|
-
//# sourceMappingURL=parse-geoarrow-in-batches.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-geoarrow-in-batches.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-geoarrow-in-batches.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAC,eAAe,EAAC,8BAA2B;AAGxD;GACG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,GAChE,aAAa,CAAC,eAAe,GAAG,iBAAiB,CAAC,CAGpD"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { parseArrowInBatches } from "./parse-arrow-in-batches.js";
|
|
5
|
-
/**
|
|
6
|
-
*/
|
|
7
|
-
export function parseGeoArrowInBatches(asyncIterator) {
|
|
8
|
-
// | BinaryGeometry
|
|
9
|
-
return parseArrowInBatches(asyncIterator);
|
|
10
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { GeoJSONTable } from '@loaders.gl/schema';
|
|
2
|
-
import type { ArrowTable } from "../lib/arrow-table.js";
|
|
3
|
-
export declare function parseGeoArrowSync(arrayBuffer: any, options?: {
|
|
4
|
-
shape?: 'arrow-table' | 'geojson-table' | 'binary-geometry';
|
|
5
|
-
}): ArrowTable | GeoJSONTable;
|
|
6
|
-
//# sourceMappingURL=parse-geoarrow-sync.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-geoarrow-sync.d.ts","sourceRoot":"","sources":["../../src/parsers/parse-geoarrow-sync.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAC,UAAU,EAAC,8BAA2B;AAKnD,wBAAgB,iBAAiB,CAC/B,WAAW,KAAA,EACX,OAAO,CAAC,EAAE;IAAC,KAAK,CAAC,EAAE,aAAa,GAAG,eAAe,GAAG,iBAAiB,CAAA;CAAC,GACtE,UAAU,GAAG,YAAY,CAS3B"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { TypedArray } from '@loaders.gl/schema';
|
|
2
|
-
import * as arrow from 'apache-arrow';
|
|
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): arrow.DataType;
|
|
5
|
-
//# sourceMappingURL=arrow-type-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arrow-type-utils.d.ts","sourceRoot":"","sources":["../../src/schema/arrow-type-utils.ts"],"names":[],"mappings":"AAIA,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,51 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import * as arrow from 'apache-arrow';
|
|
5
|
-
/** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */
|
|
6
|
-
export function getArrowType(array) {
|
|
7
|
-
switch (array.constructor) {
|
|
8
|
-
case Int8Array:
|
|
9
|
-
return new arrow.Int8();
|
|
10
|
-
case Uint8Array:
|
|
11
|
-
return new arrow.Uint8();
|
|
12
|
-
case Int16Array:
|
|
13
|
-
return new arrow.Int16();
|
|
14
|
-
case Uint16Array:
|
|
15
|
-
return new arrow.Uint16();
|
|
16
|
-
case Int32Array:
|
|
17
|
-
return new arrow.Int32();
|
|
18
|
-
case Uint32Array:
|
|
19
|
-
return new arrow.Uint32();
|
|
20
|
-
case Float32Array:
|
|
21
|
-
return new arrow.Float32();
|
|
22
|
-
case Float64Array:
|
|
23
|
-
return new arrow.Float64();
|
|
24
|
-
default:
|
|
25
|
-
throw new Error('array type not supported');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/*
|
|
29
|
-
export function getArrowVector(array: TypedArray): AbstractVector {
|
|
30
|
-
switch (array.constructor) {
|
|
31
|
-
case Int8Array:
|
|
32
|
-
return Int8Vector.from(array);
|
|
33
|
-
case Uint8Array:
|
|
34
|
-
return Uint8Vector.from(array);
|
|
35
|
-
case Int16Array:
|
|
36
|
-
return Int16Vector.from(array);
|
|
37
|
-
case Uint16Array:
|
|
38
|
-
return Uint16Vector.from(array);
|
|
39
|
-
case Int32Array:
|
|
40
|
-
return Int32Vector.from(array);
|
|
41
|
-
case Uint32Array:
|
|
42
|
-
return Uint32Vector.from(array);
|
|
43
|
-
case Float32Array:
|
|
44
|
-
return Float32Vector.from(array);
|
|
45
|
-
case Float64Array:
|
|
46
|
-
return Float64Vector.from(array);
|
|
47
|
-
default:
|
|
48
|
-
throw new Error('array type not supported');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
*/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-arrow-schema.d.ts","sourceRoot":"","sources":["../../src/schema/convert-arrow-schema.ts"],"names":[],"mappings":"AAIA,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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ColumnarTable } from '@loaders.gl/schema';
|
|
2
|
-
import type { ArrowTable } from "../lib/arrow-table.js";
|
|
3
|
-
/**
|
|
4
|
-
* Convert an Apache Arrow table to a ColumnarTable
|
|
5
|
-
* @note Currently does not convert schema
|
|
6
|
-
*/
|
|
7
|
-
export declare function convertArrowToColumnarTable(table: ArrowTable): ColumnarTable;
|
|
8
|
-
//# sourceMappingURL=convert-arrow-to-columnar-table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-arrow-to-columnar-table.d.ts","sourceRoot":"","sources":["../../src/tables/convert-arrow-to-columnar-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,oBAAoB,CAAC;AACtD,OAAO,KAAK,EAAC,UAAU,EAAC,8BAA2B;AAEnD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAmB5E"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
/**
|
|
5
|
-
* Convert an Apache Arrow table to a ColumnarTable
|
|
6
|
-
* @note Currently does not convert schema
|
|
7
|
-
*/
|
|
8
|
-
export function convertArrowToColumnarTable(table) {
|
|
9
|
-
// TODO - avoid calling `getColumn` on columns we are not interested in?
|
|
10
|
-
// Add options object?
|
|
11
|
-
const arrowTable = table.data;
|
|
12
|
-
const columnarTable = {};
|
|
13
|
-
for (const field of arrowTable.schema.fields) {
|
|
14
|
-
// This (is intended to) coalesce all record batches into a single typed array
|
|
15
|
-
const arrowColumn = arrowTable.getChild(field.name);
|
|
16
|
-
const values = arrowColumn?.toArray();
|
|
17
|
-
columnarTable[field.name] = values;
|
|
18
|
-
}
|
|
19
|
-
return {
|
|
20
|
-
shape: 'columnar-table',
|
|
21
|
-
schema: table.schema,
|
|
22
|
-
data: columnarTable
|
|
23
|
-
};
|
|
24
|
-
}
|