@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
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { GeoJSONTable } from '@loaders.gl/schema';
|
|
2
|
-
import * as arrow from 'apache-arrow';
|
|
3
|
-
import type { ArrowTable } from "../lib/arrow-table.js";
|
|
4
|
-
/**
|
|
5
|
-
* Wrap an apache arrow table in a loaders.gl table wrapper.
|
|
6
|
-
* From this additional conversions are available.
|
|
7
|
-
* @param arrowTable
|
|
8
|
-
* @returns
|
|
9
|
-
*/
|
|
10
|
-
export declare function convertApacheArrowToArrowTable(arrowTable: arrow.Table): ArrowTable;
|
|
11
|
-
/**
|
|
12
|
-
* Convert an Apache Arrow table to a GeoJSONTable
|
|
13
|
-
* @note Currently does not convert schema
|
|
14
|
-
*/
|
|
15
|
-
export declare function convertArrowToGeoJSONTable(table: ArrowTable): GeoJSONTable;
|
|
16
|
-
//# sourceMappingURL=convert-arrow-to-geojson-table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-arrow-to-geojson-table.d.ts","sourceRoot":"","sources":["../../src/tables/convert-arrow-to-geojson-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAU,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAC,UAAU,EAAC,8BAA2B;AAInD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,KAAK,CAAC,KAAK,GAAG,UAAU,CAMlF;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,UAAU,GAAG,YAAY,CAqC1E"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { serializeArrowSchema, parseGeometryFromArrow } from '@loaders.gl/arrow';
|
|
5
|
-
import { getGeometryColumnsFromSchema } from '@loaders.gl/gis';
|
|
6
|
-
/**
|
|
7
|
-
* Wrap an apache arrow table in a loaders.gl table wrapper.
|
|
8
|
-
* From this additional conversions are available.
|
|
9
|
-
* @param arrowTable
|
|
10
|
-
* @returns
|
|
11
|
-
*/
|
|
12
|
-
export function convertApacheArrowToArrowTable(arrowTable) {
|
|
13
|
-
return {
|
|
14
|
-
shape: 'arrow-table',
|
|
15
|
-
schema: serializeArrowSchema(arrowTable.schema),
|
|
16
|
-
data: arrowTable
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Convert an Apache Arrow table to a GeoJSONTable
|
|
21
|
-
* @note Currently does not convert schema
|
|
22
|
-
*/
|
|
23
|
-
export function convertArrowToGeoJSONTable(table) {
|
|
24
|
-
const arrowTable = table.data;
|
|
25
|
-
const schema = serializeArrowSchema(arrowTable.schema);
|
|
26
|
-
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
27
|
-
// get encoding from geometryColumns['geometry']
|
|
28
|
-
const encoding = geometryColumns.geometry.encoding;
|
|
29
|
-
const features = [];
|
|
30
|
-
// Remove geometry columns
|
|
31
|
-
const propertyColumnNames = arrowTable.schema.fields
|
|
32
|
-
.map((field) => field.name)
|
|
33
|
-
// TODO - this deletes all geometry columns
|
|
34
|
-
.filter((name) => !(name in geometryColumns));
|
|
35
|
-
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
36
|
-
const arrowGeometryColumn = arrowTable.getChild('geometry');
|
|
37
|
-
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
38
|
-
// get the geometry value from arrow geometry column
|
|
39
|
-
// Note that type can vary
|
|
40
|
-
const arrowGeometry = arrowGeometryColumn?.get(row);
|
|
41
|
-
// parse arrow geometry to geojson feature
|
|
42
|
-
const feature = parseGeometryFromArrow(arrowGeometry, encoding);
|
|
43
|
-
if (feature) {
|
|
44
|
-
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
45
|
-
features.push({ type: 'Feature', geometry: feature, properties });
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
shape: 'geojson-table',
|
|
50
|
-
type: 'FeatureCollection',
|
|
51
|
-
schema: table.schema,
|
|
52
|
-
features
|
|
53
|
-
};
|
|
54
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ColumnarTable, ObjectRowTable } from '@loaders.gl/schema';
|
|
2
|
-
/**
|
|
3
|
-
*
|
|
4
|
-
* @note - should be part of schema module
|
|
5
|
-
*/
|
|
6
|
-
export declare function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable;
|
|
7
|
-
//# sourceMappingURL=convert-columnar-to-row-table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-columnar-to-row-table.d.ts","sourceRoot":"","sources":["../../src/tables/convert-columnar-to-row-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAE,cAAc,EAAC,MAAM,oBAAoB,CAAC;AAEtE;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,aAAa,GAAG,cAAc,CAoB5F"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @note - should be part of schema module
|
|
7
|
-
*/
|
|
8
|
-
export function convertColumnarToRowFormatTable(columnarTable) {
|
|
9
|
-
const tableKeys = Object.keys(columnarTable);
|
|
10
|
-
const tableRowsCount = columnarTable[tableKeys[0]].length;
|
|
11
|
-
const rowFormatTable = [];
|
|
12
|
-
for (let index = 0; index < tableRowsCount; index++) {
|
|
13
|
-
const tableItem = {};
|
|
14
|
-
for (let keyIndex = 0; keyIndex < tableKeys.length; keyIndex++) {
|
|
15
|
-
const fieldName = tableKeys[keyIndex];
|
|
16
|
-
tableItem[fieldName] = columnarTable[fieldName][index];
|
|
17
|
-
}
|
|
18
|
-
rowFormatTable.push(tableItem);
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
shape: 'object-row-table',
|
|
22
|
-
schema: columnarTable.schema,
|
|
23
|
-
data: rowFormatTable
|
|
24
|
-
};
|
|
25
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
3
|
-
* @param mesh
|
|
4
|
-
* @param metadata
|
|
5
|
-
* @param batchSize
|
|
6
|
-
* @returns
|
|
7
|
-
*
|
|
8
|
-
export function convertTableToArrow(table: Table, options?: {batchSize?: number}): ArrowTable {
|
|
9
|
-
const vectors: AbstractVector[] = [];
|
|
10
|
-
const fields: Field[] = [];
|
|
11
|
-
|
|
12
|
-
const length = getTableLength(table);
|
|
13
|
-
const batchSize = options?.batchSize || length;
|
|
14
|
-
|
|
15
|
-
const recordBatches: RecordBatch[] = [];
|
|
16
|
-
for (let i = 0; i < length; i += batchSize) {
|
|
17
|
-
for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {
|
|
18
|
-
const field_ = table.schema.fields[columnIndex];
|
|
19
|
-
const column = getTableColumnAt(table, columnIndex, i, batchSize);
|
|
20
|
-
const type = getArrowType(column);
|
|
21
|
-
const vector = getArrowVector(column);
|
|
22
|
-
const listType = new FixedSizeList(size, new Field('value', type));
|
|
23
|
-
const field = new Field(field_.name, listType, false, makeMeshAttributeMetadata(attribute));
|
|
24
|
-
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
25
|
-
const listVector = new FixedSizeListVector(data);
|
|
26
|
-
vectors.push(listVector);
|
|
27
|
-
fields.push(field);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
for (const attributeKey in table.columns) {
|
|
31
|
-
const attribute = mesh.attributes[attributeKey];
|
|
32
|
-
const {value, size = 1} = attribute;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const schema = new ApacheArrowSchema(fields, table?.schema?.metadata || new Map<string, string>());
|
|
36
|
-
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
37
|
-
const apacheArrowTable = new ApacheArrowTable(schema, recordBatch);
|
|
38
|
-
|
|
39
|
-
return apacheArrowTable;
|
|
40
|
-
}
|
|
41
|
-
*/
|
|
42
|
-
//# sourceMappingURL=convert-table-to-arrow.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert-table-to-arrow.d.ts","sourceRoot":"","sources":["../../src/tables/convert-table-to-arrow.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCE"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// loaders.gl
|
|
3
|
-
// SPDX-License-Identifier: MIT
|
|
4
|
-
// Copyright (c) vis.gl contributors
|
|
5
|
-
// import {
|
|
6
|
-
// Table as ApacheArrowTable,
|
|
7
|
-
// Schema as ApacheArrowSchema,
|
|
8
|
-
// RecordBatch,
|
|
9
|
-
// FixedSizeList,
|
|
10
|
-
// Field,
|
|
11
|
-
// Data,
|
|
12
|
-
// FixedSizeListVector
|
|
13
|
-
// } from 'apache-arrow/Arrow.dom';
|
|
14
|
-
// import {AbstractVector} from 'apache-arrow/vector';
|
|
15
|
-
// import {Table} from '../../types/category-table';
|
|
16
|
-
// import {getArrowType, getArrowVector} from './arrow-type-utils';
|
|
17
|
-
// import {makeMeshAttributeMetadata} from './deduce-mesh-schema';
|
|
18
|
-
// import {getTableLength, getTableNumCols} from './table-accessors';
|
|
19
|
-
/**
|
|
20
|
-
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
21
|
-
* @param mesh
|
|
22
|
-
* @param metadata
|
|
23
|
-
* @param batchSize
|
|
24
|
-
* @returns
|
|
25
|
-
*
|
|
26
|
-
export function convertTableToArrow(table: Table, options?: {batchSize?: number}): ArrowTable {
|
|
27
|
-
const vectors: AbstractVector[] = [];
|
|
28
|
-
const fields: Field[] = [];
|
|
29
|
-
|
|
30
|
-
const length = getTableLength(table);
|
|
31
|
-
const batchSize = options?.batchSize || length;
|
|
32
|
-
|
|
33
|
-
const recordBatches: RecordBatch[] = [];
|
|
34
|
-
for (let i = 0; i < length; i += batchSize) {
|
|
35
|
-
for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {
|
|
36
|
-
const field_ = table.schema.fields[columnIndex];
|
|
37
|
-
const column = getTableColumnAt(table, columnIndex, i, batchSize);
|
|
38
|
-
const type = getArrowType(column);
|
|
39
|
-
const vector = getArrowVector(column);
|
|
40
|
-
const listType = new FixedSizeList(size, new Field('value', type));
|
|
41
|
-
const field = new Field(field_.name, listType, false, makeMeshAttributeMetadata(attribute));
|
|
42
|
-
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
43
|
-
const listVector = new FixedSizeListVector(data);
|
|
44
|
-
vectors.push(listVector);
|
|
45
|
-
fields.push(field);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
for (const attributeKey in table.columns) {
|
|
49
|
-
const attribute = mesh.attributes[attributeKey];
|
|
50
|
-
const {value, size = 1} = attribute;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const schema = new ApacheArrowSchema(fields, table?.schema?.metadata || new Map<string, string>());
|
|
54
|
-
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
55
|
-
const apacheArrowTable = new ApacheArrowTable(schema, recordBatch);
|
|
56
|
-
|
|
57
|
-
return apacheArrowTable;
|
|
58
|
-
}
|
|
59
|
-
*/
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAIA,KAAK,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,CAAC;AAElG,KAAK,eAAe,GAAG,YAAY,GAAG,YAAY,CAAC;AAEnD,KAAK,UAAU,GAAG,aAAa,GAAG,eAAe,CAAC;AAElD,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC;AAEnD,oBAAY,YAAY;IACtB,KAAK,IAAA;IACL,IAAI,IAAA;CACL"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {ArrayRowTable, ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';
|
|
6
|
-
import type {ArrowTable} from '../lib/arrow-table';
|
|
7
|
-
import {convertTable} from '@loaders.gl/schema';
|
|
8
|
-
import * as arrow from 'apache-arrow';
|
|
9
|
-
import {convertArrowToColumnarTable} from '../tables/convert-arrow-to-columnar-table';
|
|
10
|
-
import {serializeArrowSchema} from '../schema/convert-arrow-schema';
|
|
11
|
-
|
|
12
|
-
// Parses arrow to a columnar table
|
|
13
|
-
export function parseArrowSync(
|
|
14
|
-
arrayBuffer,
|
|
15
|
-
options?: {shape?: 'arrow-table' | 'columnar-table' | 'object-row-table' | 'array-row-table'}
|
|
16
|
-
): ArrowTable | ColumnarTable | ObjectRowTable | ArrayRowTable {
|
|
17
|
-
const apacheArrowTable = arrow.tableFromIPC([new Uint8Array(arrayBuffer)]);
|
|
18
|
-
const arrowTable: ArrowTable = {
|
|
19
|
-
shape: 'arrow-table',
|
|
20
|
-
schema: serializeArrowSchema(apacheArrowTable.schema),
|
|
21
|
-
data: apacheArrowTable
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const shape = options?.shape || 'arrow-table';
|
|
25
|
-
switch (shape) {
|
|
26
|
-
case 'arrow-table':
|
|
27
|
-
return arrowTable;
|
|
28
|
-
|
|
29
|
-
case 'columnar-table':
|
|
30
|
-
return convertArrowToColumnarTable(arrowTable);
|
|
31
|
-
|
|
32
|
-
case 'object-row-table':
|
|
33
|
-
let columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
34
|
-
return convertTable(columnarTable, 'object-row-table');
|
|
35
|
-
|
|
36
|
-
case 'array-row-table':
|
|
37
|
-
columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
38
|
-
return convertTable(columnarTable, 'array-row-table');
|
|
39
|
-
|
|
40
|
-
default:
|
|
41
|
-
// TODO
|
|
42
|
-
throw new Error(shape);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {GeoJSONTableBatch} from '@loaders.gl/schema';
|
|
6
|
-
import type {ArrowTableBatch} from '../lib/arrow-table';
|
|
7
|
-
import {parseArrowInBatches} from './parse-arrow-in-batches';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
*/
|
|
11
|
-
export function parseGeoArrowInBatches(
|
|
12
|
-
asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>
|
|
13
|
-
): AsyncIterable<ArrowTableBatch | GeoJSONTableBatch> {
|
|
14
|
-
// | BinaryGeometry
|
|
15
|
-
return parseArrowInBatches(asyncIterator);
|
|
16
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {GeoJSONTable} from '@loaders.gl/schema';
|
|
6
|
-
import type {ArrowTable} from '../lib/arrow-table';
|
|
7
|
-
import {parseArrowSync} from './parse-arrow-sync';
|
|
8
|
-
import {convertArrowToGeoJSONTable} from '../tables/convert-arrow-to-geojson-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 convertArrowToGeoJSONTable(table);
|
|
20
|
-
default:
|
|
21
|
-
return table;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {TypedArray} from '@loaders.gl/schema';
|
|
6
|
-
import * as arrow from 'apache-arrow';
|
|
7
|
-
|
|
8
|
-
/** Return an Apache Arrow Type instance that corresponds to the type of the elements in the supplied Typed Array */
|
|
9
|
-
export function getArrowType(array: TypedArray): arrow.DataType {
|
|
10
|
-
switch (array.constructor) {
|
|
11
|
-
case Int8Array:
|
|
12
|
-
return new arrow.Int8();
|
|
13
|
-
case Uint8Array:
|
|
14
|
-
return new arrow.Uint8();
|
|
15
|
-
case Int16Array:
|
|
16
|
-
return new arrow.Int16();
|
|
17
|
-
case Uint16Array:
|
|
18
|
-
return new arrow.Uint16();
|
|
19
|
-
case Int32Array:
|
|
20
|
-
return new arrow.Int32();
|
|
21
|
-
case Uint32Array:
|
|
22
|
-
return new arrow.Uint32();
|
|
23
|
-
case Float32Array:
|
|
24
|
-
return new arrow.Float32();
|
|
25
|
-
case Float64Array:
|
|
26
|
-
return new arrow.Float64();
|
|
27
|
-
default:
|
|
28
|
-
throw new Error('array type not supported');
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
export function getArrowVector(array: TypedArray): AbstractVector {
|
|
34
|
-
switch (array.constructor) {
|
|
35
|
-
case Int8Array:
|
|
36
|
-
return Int8Vector.from(array);
|
|
37
|
-
case Uint8Array:
|
|
38
|
-
return Uint8Vector.from(array);
|
|
39
|
-
case Int16Array:
|
|
40
|
-
return Int16Vector.from(array);
|
|
41
|
-
case Uint16Array:
|
|
42
|
-
return Uint16Vector.from(array);
|
|
43
|
-
case Int32Array:
|
|
44
|
-
return Int32Vector.from(array);
|
|
45
|
-
case Uint32Array:
|
|
46
|
-
return Uint32Vector.from(array);
|
|
47
|
-
case Float32Array:
|
|
48
|
-
return Float32Vector.from(array);
|
|
49
|
-
case Float64Array:
|
|
50
|
-
return Float64Vector.from(array);
|
|
51
|
-
default:
|
|
52
|
-
throw new Error('array type not supported');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
*/
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {ColumnarTable} from '@loaders.gl/schema';
|
|
6
|
-
import type {ArrowTable} from '../lib/arrow-table';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Convert an Apache Arrow table to a ColumnarTable
|
|
10
|
-
* @note Currently does not convert schema
|
|
11
|
-
*/
|
|
12
|
-
export function convertArrowToColumnarTable(table: ArrowTable): ColumnarTable {
|
|
13
|
-
// TODO - avoid calling `getColumn` on columns we are not interested in?
|
|
14
|
-
// Add options object?
|
|
15
|
-
|
|
16
|
-
const arrowTable = table.data;
|
|
17
|
-
const columnarTable = {};
|
|
18
|
-
|
|
19
|
-
for (const field of arrowTable.schema.fields) {
|
|
20
|
-
// This (is intended to) coalesce all record batches into a single typed array
|
|
21
|
-
const arrowColumn = arrowTable.getChild(field.name);
|
|
22
|
-
const values = arrowColumn?.toArray();
|
|
23
|
-
columnarTable[field.name] = values;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
shape: 'columnar-table',
|
|
28
|
-
schema: table.schema,
|
|
29
|
-
data: columnarTable
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {Feature, GeoJSONTable} from '@loaders.gl/schema';
|
|
6
|
-
import * as arrow from 'apache-arrow';
|
|
7
|
-
import type {ArrowTable} from '../lib/arrow-table';
|
|
8
|
-
import {serializeArrowSchema, parseGeometryFromArrow} from '@loaders.gl/arrow';
|
|
9
|
-
import {getGeometryColumnsFromSchema} from '@loaders.gl/gis';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Wrap an apache arrow table in a loaders.gl table wrapper.
|
|
13
|
-
* From this additional conversions are available.
|
|
14
|
-
* @param arrowTable
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
export function convertApacheArrowToArrowTable(arrowTable: arrow.Table): ArrowTable {
|
|
18
|
-
return {
|
|
19
|
-
shape: 'arrow-table',
|
|
20
|
-
schema: serializeArrowSchema(arrowTable.schema),
|
|
21
|
-
data: arrowTable
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Convert an Apache Arrow table to a GeoJSONTable
|
|
27
|
-
* @note Currently does not convert schema
|
|
28
|
-
*/
|
|
29
|
-
export function convertArrowToGeoJSONTable(table: ArrowTable): GeoJSONTable {
|
|
30
|
-
const arrowTable = table.data;
|
|
31
|
-
const schema = serializeArrowSchema(arrowTable.schema);
|
|
32
|
-
const geometryColumns = getGeometryColumnsFromSchema(schema);
|
|
33
|
-
|
|
34
|
-
// get encoding from geometryColumns['geometry']
|
|
35
|
-
const encoding = geometryColumns.geometry.encoding;
|
|
36
|
-
|
|
37
|
-
const features: Feature[] = [];
|
|
38
|
-
|
|
39
|
-
// Remove geometry columns
|
|
40
|
-
const propertyColumnNames = arrowTable.schema.fields
|
|
41
|
-
.map((field) => field.name)
|
|
42
|
-
// TODO - this deletes all geometry columns
|
|
43
|
-
.filter((name) => !(name in geometryColumns));
|
|
44
|
-
const propertiesTable = arrowTable.select(propertyColumnNames);
|
|
45
|
-
|
|
46
|
-
const arrowGeometryColumn = arrowTable.getChild('geometry');
|
|
47
|
-
|
|
48
|
-
for (let row = 0; row < arrowTable.numRows; row++) {
|
|
49
|
-
// get the geometry value from arrow geometry column
|
|
50
|
-
// Note that type can vary
|
|
51
|
-
const arrowGeometry = arrowGeometryColumn?.get(row);
|
|
52
|
-
// parse arrow geometry to geojson feature
|
|
53
|
-
const feature = parseGeometryFromArrow(arrowGeometry, encoding);
|
|
54
|
-
if (feature) {
|
|
55
|
-
const properties = propertiesTable.get(row)?.toJSON() || {};
|
|
56
|
-
features.push({type: 'Feature', geometry: feature, properties});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
shape: 'geojson-table',
|
|
62
|
-
type: 'FeatureCollection',
|
|
63
|
-
schema: table.schema,
|
|
64
|
-
features
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {ColumnarTable, ObjectRowTable} from '@loaders.gl/schema';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @note - should be part of schema module
|
|
10
|
-
*/
|
|
11
|
-
export function convertColumnarToRowFormatTable(columnarTable: ColumnarTable): ObjectRowTable {
|
|
12
|
-
const tableKeys = Object.keys(columnarTable);
|
|
13
|
-
const tableRowsCount = columnarTable[tableKeys[0]].length;
|
|
14
|
-
|
|
15
|
-
const rowFormatTable: {}[] = [];
|
|
16
|
-
|
|
17
|
-
for (let index = 0; index < tableRowsCount; index++) {
|
|
18
|
-
const tableItem = {};
|
|
19
|
-
for (let keyIndex = 0; keyIndex < tableKeys.length; keyIndex++) {
|
|
20
|
-
const fieldName = tableKeys[keyIndex];
|
|
21
|
-
tableItem[fieldName] = columnarTable[fieldName][index];
|
|
22
|
-
}
|
|
23
|
-
rowFormatTable.push(tableItem);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
shape: 'object-row-table',
|
|
28
|
-
schema: columnarTable.schema,
|
|
29
|
-
data: rowFormatTable
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
// import {
|
|
6
|
-
// Table as ApacheArrowTable,
|
|
7
|
-
// Schema as ApacheArrowSchema,
|
|
8
|
-
// RecordBatch,
|
|
9
|
-
// FixedSizeList,
|
|
10
|
-
// Field,
|
|
11
|
-
// Data,
|
|
12
|
-
// FixedSizeListVector
|
|
13
|
-
// } from 'apache-arrow/Arrow.dom';
|
|
14
|
-
// import {AbstractVector} from 'apache-arrow/vector';
|
|
15
|
-
|
|
16
|
-
// import {Table} from '../../types/category-table';
|
|
17
|
-
// import {getArrowType, getArrowVector} from './arrow-type-utils';
|
|
18
|
-
// import {makeMeshAttributeMetadata} from './deduce-mesh-schema';
|
|
19
|
-
// import {getTableLength, getTableNumCols} from './table-accessors';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* * Convert a loaders.gl Mesh to an Apache Arrow Table
|
|
23
|
-
* @param mesh
|
|
24
|
-
* @param metadata
|
|
25
|
-
* @param batchSize
|
|
26
|
-
* @returns
|
|
27
|
-
*
|
|
28
|
-
export function convertTableToArrow(table: Table, options?: {batchSize?: number}): ArrowTable {
|
|
29
|
-
const vectors: AbstractVector[] = [];
|
|
30
|
-
const fields: Field[] = [];
|
|
31
|
-
|
|
32
|
-
const length = getTableLength(table);
|
|
33
|
-
const batchSize = options?.batchSize || length;
|
|
34
|
-
|
|
35
|
-
const recordBatches: RecordBatch[] = [];
|
|
36
|
-
for (let i = 0; i < length; i += batchSize) {
|
|
37
|
-
for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {
|
|
38
|
-
const field_ = table.schema.fields[columnIndex];
|
|
39
|
-
const column = getTableColumnAt(table, columnIndex, i, batchSize);
|
|
40
|
-
const type = getArrowType(column);
|
|
41
|
-
const vector = getArrowVector(column);
|
|
42
|
-
const listType = new FixedSizeList(size, new Field('value', type));
|
|
43
|
-
const field = new Field(field_.name, listType, false, makeMeshAttributeMetadata(attribute));
|
|
44
|
-
const data = new Data(listType, 0, value.length / size, 0, undefined, [vector]);
|
|
45
|
-
const listVector = new FixedSizeListVector(data);
|
|
46
|
-
vectors.push(listVector);
|
|
47
|
-
fields.push(field);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
for (const attributeKey in table.columns) {
|
|
51
|
-
const attribute = mesh.attributes[attributeKey];
|
|
52
|
-
const {value, size = 1} = attribute;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const schema = new ApacheArrowSchema(fields, table?.schema?.metadata || new Map<string, string>());
|
|
56
|
-
const recordBatch = new RecordBatch(schema, vectors[0].length, vectors);
|
|
57
|
-
const apacheArrowTable = new ApacheArrowTable(schema, recordBatch);
|
|
58
|
-
|
|
59
|
-
return apacheArrowTable;
|
|
60
|
-
}
|
|
61
|
-
*/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|