@loaders.gl/core 5.0.0-beta.10 → 5.0.0-beta.11
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/SCAN-README.md +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs +1 -5
- package/dist/arrow-geometry/feature-collection-to-arrow.cjs.map +2 -2
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts +4 -3
- package/dist/arrow-geometry/feature-collection-to-arrow.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-collection-to-arrow.js +2 -6
- package/dist/arrow-geometry/feature-collection-to-arrow.js.map +1 -1
- package/dist/arrow-geometry/feature-table.cjs +2 -10
- package/dist/arrow-geometry/feature-table.cjs.map +2 -2
- package/dist/arrow-geometry/feature-table.d.ts +6 -5
- package/dist/arrow-geometry/feature-table.d.ts.map +1 -1
- package/dist/arrow-geometry/feature-table.js +5 -13
- package/dist/arrow-geometry/feature-table.js.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.cjs +1 -5
- package/dist/arrow-geometry/wkb-arrow-utils.cjs.map +2 -2
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts +7 -7
- package/dist/arrow-geometry/wkb-arrow-utils.d.ts.map +1 -1
- package/dist/arrow-geometry/wkb-arrow-utils.js +4 -8
- package/dist/arrow-geometry/wkb-arrow-utils.js.map +1 -1
- package/dist/arrow-worker-transport.cjs +7 -75
- package/dist/arrow-worker-transport.cjs.map +1 -1
- package/dist/arrow-worker-transport.d.ts +3 -7
- package/dist/arrow-worker-transport.d.ts.map +1 -1
- package/dist/arrow-worker-transport.js +15 -89
- package/dist/arrow-worker-transport.js.map +1 -1
- package/dist/cluster-source.cjs +12 -12
- package/dist/cluster-source.cjs.map +1 -1
- package/dist/dist.dev.js +71 -60
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +87 -125
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.cjs +12 -12
- package/dist/geoarrow/clustering/cluster-source.cjs.map +2 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts +3 -2
- package/dist/geoarrow/clustering/cluster-source.d.ts.map +1 -1
- package/dist/geoarrow/clustering/cluster-source.js +12 -14
- package/dist/geoarrow/clustering/cluster-source.js.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.cjs +4 -12
- package/dist/geoarrow/convert-table-to-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts +5 -5
- package/dist/geoarrow/convert-table-to-geoarrow.d.ts.map +1 -1
- package/dist/geoarrow/convert-table-to-geoarrow.js +6 -14
- package/dist/geoarrow/convert-table-to-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs +1 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow.js.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts +3 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js +2 -3
- package/dist/geoarrow/geoarrow-converter/geoarrow-converter.js.map +1 -1
- package/dist/geoarrow/geoarrow-stream.cjs +10 -11
- package/dist/geoarrow/geoarrow-stream.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts +2 -2
- package/dist/geoarrow/geoarrow-stream.d.ts.map +1 -1
- package/dist/geoarrow/geoarrow-stream.js +9 -12
- package/dist/geoarrow/geoarrow-stream.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.cjs.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js +3 -3
- package/dist/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.cjs.map +2 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts +5 -2
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.d.ts.map +1 -1
- package/dist/geoarrow/lib/table-converters/convert-geoarrow-table.js.map +1 -1
- package/dist/index.cjs +69 -54
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +2 -4
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/loader-options.d.ts +6 -0
- package/dist/lib/api/loader-options.d.ts.map +1 -1
- package/dist/lib/api/loader-options.js +48 -0
- package/dist/lib/api/loader-options.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +2 -5
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.js +6 -10
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +2 -5
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +2 -5
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +5 -8
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -1
- package/dist/lib/loader-utils/native-arrow.js +13 -31
- package/dist/lib/loader-utils/native-arrow.js.map +1 -1
- package/dist/loader-utils/index.cjs +27 -22
- package/dist/loader-utils/index.cjs.map +1 -1
- package/dist/loader-utils/index.d.ts +1 -1
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +6 -2
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +15 -12
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +36 -22
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +2 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts +3 -3
- package/dist/loader-utils/lib/sources/vector-tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +3 -5
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +4 -4
- package/dist/scan/arrow-execution/expressions.cjs.map +2 -2
- package/dist/scan/arrow-execution/expressions.d.ts +4 -4
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +4 -4
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-query-worker-entry.cjs +121 -0
- package/dist/scan/arrow-query-worker-entry.cjs.map +7 -0
- package/dist/scan/arrow-query-worker-entry.d.ts +2 -0
- package/dist/scan/arrow-query-worker-entry.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker-entry.js +7 -0
- package/dist/scan/arrow-query-worker-entry.js.map +1 -0
- package/dist/scan/arrow-query-worker.cjs +197 -0
- package/dist/scan/arrow-query-worker.cjs.map +7 -0
- package/dist/scan/arrow-query-worker.d.ts +47 -0
- package/dist/scan/arrow-query-worker.d.ts.map +1 -0
- package/dist/scan/arrow-query-worker.js +101 -0
- package/dist/scan/arrow-query-worker.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +12 -13
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +14 -15
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +5 -2
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +2 -2
- package/dist/scan/parse-sql-predicate.cjs.map +2 -2
- package/dist/scan/parse-sql-predicate.js +1 -1
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +6 -6
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.d.ts +1 -1
- package/dist/scan/query-pushdown.d.ts.map +1 -1
- package/dist/scan/query-pushdown.js +3 -6
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query-scales.cjs +140 -0
- package/dist/scan/query-scales.cjs.map +7 -0
- package/dist/scan/query-scales.d.ts +35 -0
- package/dist/scan/query-scales.d.ts.map +1 -0
- package/dist/scan/query-scales.js +120 -0
- package/dist/scan/query-scales.js.map +1 -0
- package/dist/scan/query.cjs +49 -45
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts +7 -4
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +35 -52
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/vector-table-scan-source.cjs +19 -13
- package/dist/scan/vector-table-scan-source.cjs.map +3 -3
- package/dist/scan/vector-table-scan-source.d.ts +3 -4
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +11 -12
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema/categories/category-mesh.d.ts +3 -10
- package/dist/schema/categories/category-mesh.d.ts.map +1 -1
- package/dist/schema/categories/category-mesh.js.map +1 -1
- package/dist/schema/categories/category-table.d.ts +2 -19
- package/dist/schema/categories/category-table.d.ts.map +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts +1 -1
- package/dist/schema/geometry/arrow-binary-features.d.ts.map +1 -1
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/types/batch.d.ts +0 -4
- package/dist/schema/types/batch.d.ts.map +1 -1
- package/dist/schema-utils/index.cjs +419 -502
- package/dist/schema-utils/index.cjs.map +3 -3
- package/dist/schema-utils/index.d.ts +4 -5
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +4 -5
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +4 -5
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +21 -18
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts +6 -11
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js +8 -21
- package/dist/schema-utils/lib/mesh/convert-mesh-to-table.js.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts +4 -4
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js +13 -15
- package/dist/schema-utils/lib/mesh/convert-table-to-mesh.js.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts +2 -2
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.d.ts.map +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js +1 -1
- package/dist/schema-utils/lib/mesh/point-cloud-tiler.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts +2 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.d.ts.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +3 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js +6 -5
- package/dist/schema-utils/lib/table/arrow-api/arrow-like-table.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/convert-batches.js +5 -8
- package/dist/schema-utils/lib/table/batches/convert-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js +2 -6
- package/dist/schema-utils/lib/table/batches/make-arrow-batch-iterator.js.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js +4 -24
- package/dist/schema-utils/lib/table/batches/make-table-from-batches.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts +3 -6
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js +6 -57
- package/dist/schema-utils/lib/table/tables/convert-arrow-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/make-table.js +2 -2
- package/dist/schema-utils/lib/table/tables/make-table.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-accessors.js +2 -16
- package/dist/schema-utils/lib/table/tables/table-accessors.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts +2 -2
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js +4 -4
- package/dist/schema-utils/lib/table/tables/table-converter/table-converter.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.d.ts +1 -3
- package/dist/schema-utils/lib/table/tables/table-types.d.ts.map +1 -1
- package/dist/schema-utils/lib/table/tables/table-types.js +0 -4
- package/dist/schema-utils/lib/table/tables/table-types.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +16 -10
- package/dist/vector-table-scan-source.cjs.map +2 -2
- package/dist/worker-utils/index.cjs +2 -2
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/package.json +23 -8
- package/src/arrow-geometry/feature-collection-to-arrow.ts +5 -8
- package/src/arrow-geometry/feature-table.ts +8 -21
- package/src/arrow-geometry/wkb-arrow-utils.ts +8 -12
- package/src/arrow-worker-transport.ts +21 -120
- package/src/geoarrow/clustering/cluster-source.ts +16 -23
- package/src/geoarrow/convert-table-to-geoarrow.ts +11 -23
- package/src/geoarrow/geoarrow-converter/convert-geoarrow.ts +2 -2
- package/src/geoarrow/geoarrow-converter/geoarrow-converter.ts +2 -4
- package/src/geoarrow/geoarrow-stream.ts +15 -15
- package/src/geoarrow/lib/feature-collection-converters/convert-arrow-binary-feature-collection.ts +3 -3
- package/src/geoarrow/lib/table-converters/convert-geoarrow-table.ts +7 -5
- package/src/index.ts +1 -1
- package/src/lib/api/load.ts +2 -12
- package/src/lib/api/loader-options.ts +69 -0
- package/src/lib/api/parse-file.ts +2 -11
- package/src/lib/api/parse-in-batches.ts +8 -12
- package/src/lib/api/parse-sync.ts +3 -7
- package/src/lib/api/parse.ts +2 -6
- package/src/lib/loader-utils/native-arrow.ts +12 -38
- package/src/loader-utils/index.ts +0 -1
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +7 -6
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +64 -41
- package/src/loader-utils/lib/sources/table-source-collection.ts +2 -1
- package/src/loader-utils/lib/sources/vector-tile-source.ts +3 -9
- package/src/loader-utils/loader-types.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +7 -7
- package/src/scan/arrow-query-worker-entry.ts +8 -0
- package/src/scan/arrow-query-worker.ts +158 -0
- package/src/scan/federated-table-scan-source.ts +15 -18
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +1 -1
- package/src/scan/query-pushdown.ts +7 -7
- package/src/scan/query-scales.ts +199 -0
- package/src/scan/query.ts +68 -71
- package/src/scan/vector-table-scan-source.ts +16 -21
- package/src/schema/categories/category-mesh.ts +3 -11
- package/src/schema/categories/category-table.ts +2 -28
- package/src/schema/geometry/arrow-binary-features.ts +1 -1
- package/src/schema/index.ts +1 -3
- package/src/schema/types/batch.ts +0 -5
- package/src/schema-utils/index.ts +4 -10
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +33 -30
- package/src/schema-utils/lib/mesh/convert-mesh-to-table.ts +12 -38
- package/src/schema-utils/lib/mesh/convert-table-to-mesh.ts +15 -18
- package/src/schema-utils/lib/mesh/point-cloud-tiler.ts +4 -13
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/arrow-api/arrow-like-table.ts +10 -9
- package/src/schema-utils/lib/table/batches/convert-batches.ts +5 -8
- package/src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts +2 -6
- package/src/schema-utils/lib/table/batches/make-table-from-batches.ts +5 -27
- package/src/schema-utils/lib/table/tables/convert-arrow-table.ts +9 -72
- package/src/schema-utils/lib/table/tables/make-table.ts +2 -2
- package/src/schema-utils/lib/table/tables/table-accessors.ts +2 -22
- package/src/schema-utils/lib/table/tables/table-converter/table-converter.ts +6 -6
- package/src/schema-utils/lib/table/tables/table-types.ts +1 -7
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +0 -27
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +0 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +0 -23
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +0 -1
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +0 -54
|
@@ -3,22 +3,11 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {getFloat16Storage, isNativeFloat16Array} from '@loaders.gl/core/schema';
|
|
6
|
-
import type {
|
|
7
|
-
BigTypedArray,
|
|
8
|
-
Mesh,
|
|
9
|
-
MeshAttribute,
|
|
10
|
-
MeshArrowTable,
|
|
11
|
-
MeshTable,
|
|
12
|
-
Schema
|
|
13
|
-
} from '@loaders.gl/core/schema';
|
|
6
|
+
import type {BigTypedArray, Mesh, MeshAttribute, MeshTable, Schema} from '@loaders.gl/core/schema';
|
|
14
7
|
import {indexedMeshArrowSchema, meshArrowSchema} from '@loaders.gl/core/schema';
|
|
15
8
|
import * as arrow from 'apache-arrow';
|
|
16
9
|
import {getFixedSizeListVector} from '../arrow-utils/arrow-fixed-size-list-utils';
|
|
17
|
-
import {
|
|
18
|
-
deserializeArrowField,
|
|
19
|
-
deserializeArrowMetadata,
|
|
20
|
-
serializeArrowSchema
|
|
21
|
-
} from '../schema/convert-arrow-schema';
|
|
10
|
+
import {deserializeArrowField, deserializeArrowMetadata} from '../schema/convert-arrow-schema';
|
|
22
11
|
|
|
23
12
|
/** Arrow column inputs, including exact 64-bit integers that are not GPU attributes. */
|
|
24
13
|
export type MeshArrowAttributes = Record<
|
|
@@ -71,7 +60,7 @@ export function convertMeshToTable(
|
|
|
71
60
|
case 'columnar-table':
|
|
72
61
|
return convertMeshToColumnarTable(mesh);
|
|
73
62
|
case 'arrow':
|
|
74
|
-
return
|
|
63
|
+
return convertMeshToArrowTable(mesh);
|
|
75
64
|
default:
|
|
76
65
|
throw new Error(shape);
|
|
77
66
|
}
|
|
@@ -99,13 +88,8 @@ export function convertMeshToColumnarTable(mesh: Mesh): MeshTable {
|
|
|
99
88
|
};
|
|
100
89
|
}
|
|
101
90
|
|
|
102
|
-
/**
|
|
103
|
-
|
|
104
|
-
* @param mesh Mesh to convert.
|
|
105
|
-
* @param batchSize Reserved for future chunked Arrow conversion.
|
|
106
|
-
* @returns Mesh data as an Apache Arrow table wrapper.
|
|
107
|
-
*/
|
|
108
|
-
export function convertMeshToArrowTableWrapper(mesh: Mesh, batchSize?: number): MeshArrowTable {
|
|
91
|
+
/** Builds a native Apache Arrow mesh table, including topology, indices, and bounds. */
|
|
92
|
+
export function convertMeshToArrowTable(mesh: Mesh): arrow.Table {
|
|
109
93
|
return makeMeshArrowTable(mesh.attributes, {
|
|
110
94
|
schema: mesh.schema,
|
|
111
95
|
topology: mesh.topology,
|
|
@@ -116,15 +100,15 @@ export function convertMeshToArrowTableWrapper(mesh: Mesh, batchSize?: number):
|
|
|
116
100
|
}
|
|
117
101
|
|
|
118
102
|
/**
|
|
119
|
-
*
|
|
103
|
+
* Creates a native Apache Arrow mesh table from typed attributes.
|
|
120
104
|
* @param attributes Mesh attributes to expose as Arrow columns.
|
|
121
105
|
* @param options Mesh table metadata and optional schema.
|
|
122
|
-
* @returns
|
|
106
|
+
* @returns The Arrow table with mesh topology, bounds, and optional indices.
|
|
123
107
|
*/
|
|
124
108
|
export function makeMeshArrowTable(
|
|
125
109
|
attributes: MeshArrowAttributes,
|
|
126
110
|
options: MeshArrowTableOptions = {}
|
|
127
|
-
):
|
|
111
|
+
): arrow.Table {
|
|
128
112
|
const fields: arrow.Field[] = [];
|
|
129
113
|
const columns: {[columnName: string]: arrow.Vector} = {};
|
|
130
114
|
const attributeNames = getOrderedAttributeNames(attributes);
|
|
@@ -139,7 +123,7 @@ export function makeMeshArrowTable(
|
|
|
139
123
|
getAttributeArrowField(options.schema, attributeName, column, attribute.componentType)
|
|
140
124
|
);
|
|
141
125
|
|
|
142
|
-
if (attributeName ===
|
|
126
|
+
if (attributeName === attributeNames[0] && options.indices?.value?.length) {
|
|
143
127
|
const indicesField = indexedMeshArrowSchema.fields.find(field => field.name === 'indices')!;
|
|
144
128
|
columns.indices = getIndicesVector(options.indices.value, column.length, indicesField.type);
|
|
145
129
|
fields.push(indicesField);
|
|
@@ -149,19 +133,9 @@ export function makeMeshArrowTable(
|
|
|
149
133
|
const arrowSchema = new arrow.Schema(fields, getMeshArrowMetadata(options));
|
|
150
134
|
// Arrow's column-object constructor synthesizes an incompatible batch schema for empty
|
|
151
135
|
// fixed-size-list vectors. A schema-only table preserves the declared mesh fields instead.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
: new arrow.Table(arrowSchema, columns);
|
|
156
|
-
const schema = serializeArrowSchema(table.schema);
|
|
157
|
-
|
|
158
|
-
return {
|
|
159
|
-
shape: 'arrow-table',
|
|
160
|
-
schema,
|
|
161
|
-
data: table,
|
|
162
|
-
topology: options.topology || 'point-list',
|
|
163
|
-
indices: options.indices
|
|
164
|
-
};
|
|
136
|
+
return columns[attributeNames[0]]?.length === 0
|
|
137
|
+
? new arrow.Table(arrowSchema)
|
|
138
|
+
: new arrow.Table(arrowSchema, columns);
|
|
165
139
|
}
|
|
166
140
|
|
|
167
141
|
/** Return an Arrow vector for a mesh attribute. */
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {createFloat16Array, getFloat16Value, setFloat16Value} from '@loaders.gl/core/schema';
|
|
6
|
-
import type {Mesh, MeshAttribute, ColumnarTable,
|
|
6
|
+
import type {Mesh, MeshAttribute, ColumnarTable, Schema} from '@loaders.gl/core/schema';
|
|
7
7
|
import * as arrow from 'apache-arrow';
|
|
8
8
|
import {getFixedSizeListSize} from '../arrow-utils/arrow-fixed-size-list-utils';
|
|
9
9
|
import {serializeArrowSchema} from '../schema/convert-arrow-schema';
|
|
10
|
-
import {
|
|
10
|
+
import {isArrowTable} from '../../../lib/loader-utils/native-arrow';
|
|
11
11
|
import {getMeshBoundingBox} from './mesh-utils';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -15,26 +15,17 @@ import {getMeshBoundingBox} from './mesh-utils';
|
|
|
15
15
|
* @param table Table to convert.
|
|
16
16
|
* @returns Mesh reconstructed from the table.
|
|
17
17
|
*/
|
|
18
|
-
export function convertTableToMesh(table: ColumnarTable |
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
// case 'columnar-table':
|
|
22
|
-
// return convertColumnarTableToMesh(table);
|
|
23
|
-
case 'arrow-table':
|
|
24
|
-
return convertArrowTableToMesh(table);
|
|
25
|
-
default:
|
|
26
|
-
throw new Error(table.shape);
|
|
27
|
-
}
|
|
18
|
+
export function convertTableToMesh(table: ColumnarTable | arrow.Table): Mesh {
|
|
19
|
+
if (isArrowTable(table)) return convertArrowTableToMesh(table);
|
|
20
|
+
throw new Error(table.shape);
|
|
28
21
|
}
|
|
29
22
|
|
|
30
23
|
/**
|
|
31
24
|
* Convert an Apache Arrow mesh table to a loaders.gl Mesh.
|
|
32
|
-
* @param table Native Arrow table
|
|
25
|
+
* @param table Native Arrow table.
|
|
33
26
|
* @returns Mesh reconstructed from the Arrow table.
|
|
34
27
|
*/
|
|
35
|
-
export function convertArrowTableToMesh(
|
|
36
|
-
const arrowTable = isNativeArrowTable(table) ? table : table.data;
|
|
37
|
-
|
|
28
|
+
export function convertArrowTableToMesh(arrowTable: arrow.Table): Mesh {
|
|
38
29
|
const schema = serializeArrowSchema(arrowTable.schema);
|
|
39
30
|
// Legacy mesh batches describe their own vertices, not the cumulative stream extent.
|
|
40
31
|
const localBounds =
|
|
@@ -185,14 +176,20 @@ function getAttributeTypedArray(attributeData: arrow.Vector, size: number): any
|
|
|
185
176
|
return attributeData.toArray();
|
|
186
177
|
}
|
|
187
178
|
|
|
188
|
-
|
|
179
|
+
if (attributeData.length === 0) {
|
|
180
|
+
const EmptyStorage = attributeData.type.valueType.ArrayType;
|
|
181
|
+
return new EmptyStorage(0);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const values = attributeData.data.find(chunk => chunk.length > 0)!.children[0].values;
|
|
189
185
|
const TypedArrayConstructor = values.constructor as any;
|
|
190
186
|
const typedArray = new TypedArrayConstructor(attributeData.length * size);
|
|
191
187
|
let targetOffset = 0;
|
|
192
188
|
|
|
193
189
|
for (const data of attributeData.data) {
|
|
194
|
-
const child = data.children[0];
|
|
195
190
|
const sourceLength = data.length * size;
|
|
191
|
+
if (sourceLength === 0) continue;
|
|
192
|
+
const child = data.children[0];
|
|
196
193
|
const sourceOffset = child.offset || data.offset * size;
|
|
197
194
|
// Arrow chunks can either slice child values eagerly or retain offsets into the source buffer.
|
|
198
195
|
const sourceStart = sourceOffset + sourceLength <= child.values.length ? sourceOffset : 0;
|
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
6
|
-
Mesh,
|
|
7
|
-
MeshArrowTable,
|
|
8
|
-
MeshArrowTableData,
|
|
9
|
-
MeshAttribute,
|
|
10
|
-
TypedArray
|
|
11
|
-
} from '@loaders.gl/core/schema';
|
|
5
|
+
import type {Mesh, MeshArrowTable, MeshAttribute, TypedArray} from '@loaders.gl/core/schema';
|
|
12
6
|
import {convertTableToMesh} from './convert-table-to-mesh';
|
|
13
7
|
|
|
14
8
|
/** A native-coordinate cube, with minimum and maximum XYZ corners. */
|
|
@@ -95,10 +89,7 @@ export class PointCloudTiler {
|
|
|
95
89
|
private pointByteLength = 0;
|
|
96
90
|
|
|
97
91
|
/** Starts indexing one decoded point dataset with explicit allocation limits. */
|
|
98
|
-
constructor(
|
|
99
|
-
input: Mesh | MeshArrowTable | MeshArrowTableData,
|
|
100
|
-
options: PointCloudTilerOptions = {}
|
|
101
|
-
) {
|
|
92
|
+
constructor(input: Mesh | MeshArrowTable, options: PointCloudTilerOptions = {}) {
|
|
102
93
|
this.options = {
|
|
103
94
|
nodePointLimit: options.nodePointLimit ?? 50_000,
|
|
104
95
|
maximumDepth: options.maximumDepth ?? 16,
|
|
@@ -250,10 +241,10 @@ export class PointCloudTiler {
|
|
|
250
241
|
}
|
|
251
242
|
|
|
252
243
|
/** Validates the decoded profile and creates a root cube from finite native coordinates. */
|
|
253
|
-
private async initialize(input: Mesh | MeshArrowTable
|
|
244
|
+
private async initialize(input: Mesh | MeshArrowTable): Promise<void> {
|
|
254
245
|
this.signal.throwIfAborted();
|
|
255
246
|
if (!('attributes' in input)) {
|
|
256
|
-
const table =
|
|
247
|
+
const table = input;
|
|
257
248
|
const buffers = new Set<ArrayBufferLike>();
|
|
258
249
|
let arrowBytes = 0;
|
|
259
250
|
/** Counts retained Arrow buffers and rejects null child values before conversion. */
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
// Type deduction
|
|
6
6
|
import type {Schema, Field, ArrayType, Table} from '@loaders.gl/core/schema';
|
|
7
|
+
import type {Table as ArrowTable} from 'apache-arrow';
|
|
8
|
+
import {convertArrowToSchema} from './convert-arrow-schema';
|
|
7
9
|
import {getDataTypeFromArray, getDataTypeFromValue} from './data-type';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -12,7 +14,8 @@ import {getDataTypeFromArray, getDataTypeFromValue} from './data-type';
|
|
|
12
14
|
* @param {*} schema
|
|
13
15
|
* @returns
|
|
14
16
|
*/
|
|
15
|
-
export function deduceTableSchema(table: Table): Schema {
|
|
17
|
+
export function deduceTableSchema(table: Table | ArrowTable): Schema {
|
|
18
|
+
if (!('shape' in table)) return convertArrowToSchema(table.schema);
|
|
16
19
|
switch (table.shape) {
|
|
17
20
|
case 'array-row-table':
|
|
18
21
|
case 'object-row-table':
|
|
@@ -24,7 +27,6 @@ export function deduceTableSchema(table: Table): Schema {
|
|
|
24
27
|
case 'columnar-table':
|
|
25
28
|
return deduceSchemaFromColumns(table.data);
|
|
26
29
|
|
|
27
|
-
case 'arrow-table':
|
|
28
30
|
default:
|
|
29
31
|
throw new Error('Deduce schema');
|
|
30
32
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type * as arrow from 'apache-arrow';
|
|
5
6
|
import type {Table} from '@loaders.gl/core/schema';
|
|
6
7
|
|
|
7
8
|
import {ArrowLikeSchema} from './arrow-like-schema';
|
|
@@ -20,10 +21,10 @@ import {
|
|
|
20
21
|
} from '../tables/table-accessors';
|
|
21
22
|
|
|
22
23
|
class ArrowLikeVector {
|
|
23
|
-
table: Table;
|
|
24
|
+
table: Table | arrow.Table;
|
|
24
25
|
columnName: string;
|
|
25
26
|
|
|
26
|
-
constructor(table: Table, columnName: string) {
|
|
27
|
+
constructor(table: Table | arrow.Table, columnName: string) {
|
|
27
28
|
this.table = table;
|
|
28
29
|
this.columnName = columnName;
|
|
29
30
|
}
|
|
@@ -33,10 +34,8 @@ class ArrowLikeVector {
|
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
toArray(): ArrayLike<unknown> {
|
|
37
|
+
if (!('shape' in this.table)) return this.table.getChild(this.columnName)?.toArray();
|
|
36
38
|
switch (this.table.shape) {
|
|
37
|
-
case 'arrow-table':
|
|
38
|
-
const arrowTable = this.table.data as any;
|
|
39
|
-
return arrowTable.getChild(this.columnName)?.toArray();
|
|
40
39
|
case 'columnar-table':
|
|
41
40
|
return this.table.data[this.columnName];
|
|
42
41
|
default:
|
|
@@ -51,12 +50,13 @@ class ArrowLikeVector {
|
|
|
51
50
|
*/
|
|
52
51
|
export class ArrowLikeTable {
|
|
53
52
|
schema: ArrowLikeSchema;
|
|
54
|
-
table: Table;
|
|
53
|
+
table: Table | arrow.Table;
|
|
55
54
|
|
|
56
|
-
constructor(table: Table) {
|
|
57
|
-
const schema =
|
|
55
|
+
constructor(table: Table | arrow.Table) {
|
|
56
|
+
const schema =
|
|
57
|
+
'shape' in table ? table.schema || deduceTableSchema(table) : deduceTableSchema(table);
|
|
58
58
|
this.schema = new ArrowLikeSchema(schema.fields, schema.metadata);
|
|
59
|
-
this.table = {...table, schema};
|
|
59
|
+
this.table = 'shape' in table ? {...table, schema} : table;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// get schema() {
|
|
@@ -64,6 +64,7 @@ export class ArrowLikeTable {
|
|
|
64
64
|
// }
|
|
65
65
|
|
|
66
66
|
get data() {
|
|
67
|
+
if (!('shape' in this.table)) return this.table;
|
|
67
68
|
return this.table.shape === 'geojson-table' ? this.table.features : this.table.data;
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
ColumnarTableBatch
|
|
10
10
|
} from '@loaders.gl/core/schema';
|
|
11
11
|
import * as arrow from 'apache-arrow';
|
|
12
|
-
import {
|
|
12
|
+
import {isArrowRecordBatch} from '../../../../lib/loader-utils/native-arrow';
|
|
13
13
|
import {makeArrowMetadataBatch} from '../../arrow/arrow-metadata';
|
|
14
14
|
import {convertTable} from '../tables/convert-table';
|
|
15
15
|
|
|
@@ -21,12 +21,12 @@ export function convertBatch(
|
|
|
21
21
|
shape: 'arrow'
|
|
22
22
|
): arrow.RecordBatch;
|
|
23
23
|
|
|
24
|
-
/** Converts one batch
|
|
24
|
+
/** Converts one portable batch or returns the supplied native record batch. */
|
|
25
25
|
export function convertBatch(
|
|
26
26
|
batch: TableBatch | arrow.RecordBatch,
|
|
27
27
|
shape: 'object-row-table' | 'array-row-table' | 'columnar-table' | 'arrow'
|
|
28
28
|
): TableBatch | arrow.RecordBatch {
|
|
29
|
-
if (
|
|
29
|
+
if (isArrowRecordBatch(batch)) {
|
|
30
30
|
if (shape === 'arrow') return batch;
|
|
31
31
|
throw new Error('Convert a native RecordBatch as a table to select a row or column layout');
|
|
32
32
|
}
|
|
@@ -39,9 +39,6 @@ export function convertBatch(
|
|
|
39
39
|
return {...batch, ...convertTable(batch, 'columnar-table')};
|
|
40
40
|
case 'arrow': {
|
|
41
41
|
const table = convertTable(batch, 'arrow');
|
|
42
|
-
if (table.batches.length > 1) {
|
|
43
|
-
throw new Error('Use convertBatches to expand multiple Arrow record batches');
|
|
44
|
-
}
|
|
45
42
|
return table.batches[0] ?? makeArrowMetadataBatch(table.schema);
|
|
46
43
|
}
|
|
47
44
|
default:
|
|
@@ -68,14 +65,14 @@ export function convertBatches(
|
|
|
68
65
|
|
|
69
66
|
/**
|
|
70
67
|
* Converts batches in emission order. For Arrow output, yields native record batches,
|
|
71
|
-
*
|
|
68
|
+
* preserving the declared schema of empty inputs.
|
|
72
69
|
*/
|
|
73
70
|
export async function* convertBatches(
|
|
74
71
|
batches: Iterable<TableBatch | arrow.RecordBatch> | AsyncIterable<TableBatch | arrow.RecordBatch>,
|
|
75
72
|
shape: 'object-row-table' | 'array-row-table' | 'columnar-table' | 'arrow'
|
|
76
73
|
): AsyncIterableIterator<TableBatch | arrow.RecordBatch> {
|
|
77
74
|
for await (const batch of batches) {
|
|
78
|
-
if (
|
|
75
|
+
if (isArrowRecordBatch(batch)) {
|
|
79
76
|
if (shape !== 'arrow') throw new Error('Expected a loaders.gl table batch');
|
|
80
77
|
yield batch;
|
|
81
78
|
continue;
|
|
@@ -39,18 +39,14 @@ export function* makeArrowRecordBatchIterator(
|
|
|
39
39
|
yield* sliceNativeArrowBatches(table, options?.batchSize);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
yield*
|
|
42
|
+
yield* makePortableTableRecordBatchIterator(table, options);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
/** Converts loaders.gl table representations to record batches. */
|
|
46
|
-
export function*
|
|
46
|
+
export function* makePortableTableRecordBatchIterator(
|
|
47
47
|
table: Table,
|
|
48
48
|
options?: {batchSize?: number}
|
|
49
49
|
): IterableIterator<arrow.RecordBatch> {
|
|
50
|
-
if (table.shape === 'arrow-table') {
|
|
51
|
-
yield* sliceNativeArrowBatches(table.data, options?.batchSize);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
50
|
const arrowSchema = convertSchemaToArrow(table.schema!);
|
|
55
51
|
|
|
56
52
|
const length = getTableLength(table);
|
|
@@ -10,14 +10,9 @@ import type {
|
|
|
10
10
|
ArrayRowTable,
|
|
11
11
|
Feature
|
|
12
12
|
} from '@loaders.gl/core/schema';
|
|
13
|
-
import * as arrow from 'apache-arrow';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
mergeArrowSchemas,
|
|
17
|
-
makeArrowMetadataBatch
|
|
18
|
-
} from '../../arrow/arrow-metadata';
|
|
19
|
-
import {convertSchemaToArrow, serializeArrowSchema} from '../../schema/convert-arrow-schema';
|
|
20
|
-
import {isNativeArrowRecordBatch} from '../../../../lib/loader-utils/native-arrow';
|
|
13
|
+
import type * as arrow from 'apache-arrow';
|
|
14
|
+
import {makeArrowTableFromBatches} from '../../arrow/arrow-metadata';
|
|
15
|
+
import {isArrowRecordBatch} from '../../../../lib/loader-utils/native-arrow';
|
|
21
16
|
import {getTableLength} from '../tables/table-accessors';
|
|
22
17
|
|
|
23
18
|
/**
|
|
@@ -44,13 +39,12 @@ export async function makeTableFromBatches(
|
|
|
44
39
|
let shape: Table['shape'] | 'arrow' | null = null;
|
|
45
40
|
let schema: Schema | undefined;
|
|
46
41
|
const arrowBatches: arrow.RecordBatch[] = [];
|
|
47
|
-
let arrowSchema: arrow.Schema | undefined;
|
|
48
42
|
|
|
49
43
|
for await (const batch of batchIterator) {
|
|
50
|
-
const batchShape =
|
|
44
|
+
const batchShape = isArrowRecordBatch(batch) ? 'arrow' : batch.shape;
|
|
51
45
|
shape ??= batchShape;
|
|
52
46
|
if (shape !== batchShape) throw new Error('Batches must have the same shape');
|
|
53
|
-
if (
|
|
47
|
+
if (isArrowRecordBatch(batch)) {
|
|
54
48
|
arrowBatches.push(batch);
|
|
55
49
|
continue;
|
|
56
50
|
}
|
|
@@ -81,17 +75,6 @@ export async function makeTableFromBatches(
|
|
|
81
75
|
}
|
|
82
76
|
break;
|
|
83
77
|
|
|
84
|
-
case 'arrow-table': {
|
|
85
|
-
for (const recordBatch of batch.data.batches) {
|
|
86
|
-
arrowSchema = mergeArrowSchemas(arrowSchema, recordBatch.schema);
|
|
87
|
-
arrowBatches.push(recordBatch);
|
|
88
|
-
}
|
|
89
|
-
arrowSchema = mergeArrowSchemas(arrowSchema, batch.data.schema);
|
|
90
|
-
if (batch.schema)
|
|
91
|
-
arrowSchema = mergeArrowSchemas(arrowSchema, convertSchemaToArrow(batch.schema));
|
|
92
|
-
if (batch.data.batches.length === 0) arrowBatches.push(makeArrowMetadataBatch(arrowSchema));
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
78
|
case 'columnar-table':
|
|
96
79
|
default:
|
|
97
80
|
throw new Error('shape');
|
|
@@ -105,11 +88,6 @@ export async function makeTableFromBatches(
|
|
|
105
88
|
switch (shape) {
|
|
106
89
|
case 'arrow':
|
|
107
90
|
return makeArrowTableFromBatches(arrowBatches);
|
|
108
|
-
case 'arrow-table': {
|
|
109
|
-
const collected = await makeArrowTableFromBatches(arrowBatches);
|
|
110
|
-
const data = collected && new arrow.Table(arrowSchema || collected.schema, collected.batches);
|
|
111
|
-
return data ? {shape: 'arrow-table', data, schema: serializeArrowSchema(data.schema)} : null;
|
|
112
|
-
}
|
|
113
91
|
case 'array-row-table':
|
|
114
92
|
return {shape: 'array-row-table', data: arrayRows!, schema};
|
|
115
93
|
|
|
@@ -15,38 +15,25 @@ import type {
|
|
|
15
15
|
import {convertTable} from './convert-table';
|
|
16
16
|
import {deduceTableSchema} from '../../schema/deduce-table-schema';
|
|
17
17
|
import {convertArrowToSchema, convertSchemaToArrow} from '../../schema/convert-arrow-schema';
|
|
18
|
-
import {
|
|
18
|
+
import {makePortableTableRecordBatchIterator} from '../batches/make-arrow-batch-iterator';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Converts a loaders.gl table to native Arrow and preserves the schema on empty input.
|
|
22
|
-
* Native Arrow inputs
|
|
22
|
+
* Native Arrow inputs retain their identity.
|
|
23
23
|
*/
|
|
24
24
|
export function convertTableToArrow(
|
|
25
25
|
table: Table | arrow.Table,
|
|
26
26
|
options?: {batchSize?: number}
|
|
27
27
|
): arrow.Table {
|
|
28
28
|
if (!('shape' in table)) return table;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
case 'columnar-table':
|
|
34
|
-
// TODO - optimized implementation is possible
|
|
35
|
-
// return convertColumnarTableToArrow(table, options);
|
|
36
|
-
|
|
37
|
-
// fall through
|
|
38
|
-
|
|
39
|
-
default:
|
|
40
|
-
const schema = table.schema ?? deduceTableSchema(table);
|
|
41
|
-
return new arrow.Table(convertSchemaToArrow(schema), [
|
|
42
|
-
...makeWrappedTableRecordBatchIterator({...table, schema}, options)
|
|
43
|
-
]);
|
|
44
|
-
}
|
|
29
|
+
const schema = table.schema ?? deduceTableSchema(table);
|
|
30
|
+
return new arrow.Table(convertSchemaToArrow(schema), [
|
|
31
|
+
...makePortableTableRecordBatchIterator({...table, schema}, options)
|
|
32
|
+
]);
|
|
45
33
|
}
|
|
46
34
|
|
|
47
35
|
/** Loader table layouts produced when converting from Arrow. */
|
|
48
|
-
type
|
|
49
|
-
type NonArrowTableShape = NonArrowTable['shape'];
|
|
36
|
+
type NonArrowTableShape = Table['shape'];
|
|
50
37
|
|
|
51
38
|
/**
|
|
52
39
|
* Convert an Apache Arrow table to a loaders.gl Table
|
|
@@ -57,7 +44,7 @@ export function convertArrowToTable(arrow: arrow.Table, shape: 'columnar-table')
|
|
|
57
44
|
export function convertArrowToTable(arrow: arrow.Table, shape: 'object-row-table'): ObjectRowTable;
|
|
58
45
|
export function convertArrowToTable(arrow: arrow.Table, shape: 'array-row-table'): ArrayRowTable;
|
|
59
46
|
export function convertArrowToTable(arrow: arrow.Table, shape: 'geojson-table'): GeoJSONTable;
|
|
60
|
-
export function convertArrowToTable(arrow: arrow.Table, shape: NonArrowTableShape):
|
|
47
|
+
export function convertArrowToTable(arrow: arrow.Table, shape: NonArrowTableShape): Table;
|
|
61
48
|
|
|
62
49
|
/**
|
|
63
50
|
* Convert an Apache Arrow table to a loaders.gl Table
|
|
@@ -66,7 +53,7 @@ export function convertArrowToTable(arrow: arrow.Table, shape: NonArrowTableShap
|
|
|
66
53
|
export function convertArrowToTable(
|
|
67
54
|
arrowTable: arrow.Table,
|
|
68
55
|
shape: NonArrowTableShape | 'arrow'
|
|
69
|
-
):
|
|
56
|
+
): Table | arrow.Table {
|
|
70
57
|
switch (shape) {
|
|
71
58
|
case 'arrow':
|
|
72
59
|
return arrowTable;
|
|
@@ -141,53 +128,3 @@ function convertArrowToGeoJSONTable(arrowTable: arrow.Table): GeoJSONTable {
|
|
|
141
128
|
features
|
|
142
129
|
};
|
|
143
130
|
}
|
|
144
|
-
|
|
145
|
-
// /**
|
|
146
|
-
// * Wrap an apache arrow table in a loaders.gl table wrapper.
|
|
147
|
-
// * From this additional conversions are available.
|
|
148
|
-
// * @param arrowTable
|
|
149
|
-
// * @returns
|
|
150
|
-
// */
|
|
151
|
-
// function convertArrowToArrowTable(arrowTable: arrow.Table): ArrowTable {
|
|
152
|
-
// return {
|
|
153
|
-
// shape: 'arrow-table',
|
|
154
|
-
// schema: convertArrowToSchema(arrowTable.schema),
|
|
155
|
-
// data: arrowTable
|
|
156
|
-
// };
|
|
157
|
-
// }
|
|
158
|
-
|
|
159
|
-
// function convertArrowToArrayRowTable(arrowTable: arrow.Table): ArrayRowTable {
|
|
160
|
-
// const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
161
|
-
// return convertTable(columnarTable, 'array-row-table');
|
|
162
|
-
// }
|
|
163
|
-
|
|
164
|
-
// function convertArrowToObjectRowTable(arrowTable: arrow.Table): ObjectRowTable {
|
|
165
|
-
// const columnarTable = convertArrowToColumnarTable(arrowTable);
|
|
166
|
-
// return convertTable(columnarTable, 'object-row-table');
|
|
167
|
-
// }
|
|
168
|
-
|
|
169
|
-
// /**
|
|
170
|
-
// * Convert an Apache Arrow table to a ColumnarTable
|
|
171
|
-
// * @note Currently does not convert schema
|
|
172
|
-
// */
|
|
173
|
-
// function convertArrowToColumnarTable(arrowTable: arrow.Table): ColumnarTable {
|
|
174
|
-
// // TODO - avoid calling `getColumn` on columns we are not interested in?
|
|
175
|
-
// // Add options object?
|
|
176
|
-
|
|
177
|
-
// const columns: ColumnarTable['data'] = {};
|
|
178
|
-
|
|
179
|
-
// for (const field of arrowTable.schema.fields) {
|
|
180
|
-
// // This (is intended to) coalesce all record batches into a single typed array
|
|
181
|
-
// const arrowColumn = arrowTable.getChild(field.name);
|
|
182
|
-
// const values = arrowColumn?.toArray();
|
|
183
|
-
// columns[field.name] = values;
|
|
184
|
-
// }
|
|
185
|
-
|
|
186
|
-
// const schema = convertArrowToSchema(arrowTable.schema);
|
|
187
|
-
|
|
188
|
-
// return {
|
|
189
|
-
// shape: 'columnar-table',
|
|
190
|
-
// schema,
|
|
191
|
-
// data: columns
|
|
192
|
-
// };
|
|
193
|
-
// }
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type * as arrow from 'apache-arrow';
|
|
6
6
|
import type {Table, ArrayRowTable, ObjectRowTable, ColumnarTable} from '@loaders.gl/core/schema';
|
|
7
|
-
import {
|
|
7
|
+
import {isArrowTable} from '../../../../lib/loader-utils/native-arrow';
|
|
8
8
|
import {deduceTableSchema} from '../../schema/deduce-table-schema';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -17,7 +17,7 @@ export function makeTableFromData(data: {[column: string]: ArrayLike<unknown>}):
|
|
|
17
17
|
export function makeTableFromData(data: arrow.Table): arrow.Table;
|
|
18
18
|
|
|
19
19
|
export function makeTableFromData(data: unknown): Table | arrow.Table {
|
|
20
|
-
if (
|
|
20
|
+
if (isArrowTable(data)) return data;
|
|
21
21
|
let table: Table;
|
|
22
22
|
switch (getTableShapeFromData(data)) {
|
|
23
23
|
case 'array-row-table':
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
/* eslint-disable no-else-return */
|
|
6
6
|
|
|
7
7
|
import type {Table as NativeArrowTable} from 'apache-arrow';
|
|
8
|
-
import {
|
|
8
|
+
import {isArrowTable} from '../../../../lib/loader-utils/native-arrow';
|
|
9
9
|
import {convertArrowToSchema} from '../../schema/convert-arrow-schema';
|
|
10
10
|
import type {Table, ArrayRowTable, ObjectRowTable} from '@loaders.gl/core/schema';
|
|
11
11
|
|
|
12
12
|
/** Checks whether a value is a native Arrow table or a loaders.gl table. */
|
|
13
13
|
export function isTable(table: any): table is Table | NativeArrowTable {
|
|
14
|
-
if (
|
|
14
|
+
if (isArrowTable(table)) return true;
|
|
15
15
|
const shape = typeof table === 'object' && table?.shape;
|
|
16
16
|
switch (shape) {
|
|
17
17
|
case 'array-row-table':
|
|
@@ -24,9 +24,6 @@ export function isTable(table: any): table is Table | NativeArrowTable {
|
|
|
24
24
|
case 'columnar-table':
|
|
25
25
|
return Boolean(table.data && typeof table.data === 'object');
|
|
26
26
|
|
|
27
|
-
case 'arrow-table':
|
|
28
|
-
return Boolean(table?.data?.numRows !== undefined);
|
|
29
|
-
|
|
30
27
|
default:
|
|
31
28
|
return false;
|
|
32
29
|
}
|
|
@@ -45,9 +42,6 @@ export function getTableLength(table: Table | NativeArrowTable): number {
|
|
|
45
42
|
case 'geojson-table':
|
|
46
43
|
return table.features.length;
|
|
47
44
|
|
|
48
|
-
case 'arrow-table':
|
|
49
|
-
return getTableLength(table.data);
|
|
50
|
-
|
|
51
45
|
case 'columnar-table':
|
|
52
46
|
for (const column of Object.values(table.data)) {
|
|
53
47
|
return column.length || 0;
|
|
@@ -79,8 +73,6 @@ export function getTableNumCols(table: Table | NativeArrowTable): number {
|
|
|
79
73
|
return Object.keys(table.features[0]).length;
|
|
80
74
|
case 'columnar-table':
|
|
81
75
|
return Object.keys(table.data).length;
|
|
82
|
-
case 'arrow-table':
|
|
83
|
-
return getTableNumCols(table.data);
|
|
84
76
|
|
|
85
77
|
default:
|
|
86
78
|
throw new Error('table');
|
|
@@ -109,9 +101,6 @@ export function getTableCell(
|
|
|
109
101
|
const column = table.data[columnName];
|
|
110
102
|
return column[rowIndex];
|
|
111
103
|
|
|
112
|
-
case 'arrow-table':
|
|
113
|
-
return getTableCell(table.data, rowIndex, columnName);
|
|
114
|
-
|
|
115
104
|
default:
|
|
116
105
|
throw new Error('todo');
|
|
117
106
|
}
|
|
@@ -141,9 +130,6 @@ export function getTableCellAt(
|
|
|
141
130
|
const column = table.data[columnName3];
|
|
142
131
|
return column[rowIndex];
|
|
143
132
|
|
|
144
|
-
case 'arrow-table':
|
|
145
|
-
return getTableCellAt(table.data, rowIndex, columnIndex);
|
|
146
|
-
|
|
147
133
|
default:
|
|
148
134
|
throw new Error('todo');
|
|
149
135
|
}
|
|
@@ -248,9 +234,6 @@ export function getTableRowAsObject(
|
|
|
248
234
|
return objectRow;
|
|
249
235
|
}
|
|
250
236
|
|
|
251
|
-
case 'arrow-table':
|
|
252
|
-
return getTableRowAsObject(table.data, rowIndex, target, copy);
|
|
253
|
-
|
|
254
237
|
default:
|
|
255
238
|
throw new Error('shape');
|
|
256
239
|
}
|
|
@@ -321,9 +304,6 @@ export function getTableRowAsArray(
|
|
|
321
304
|
return arrayRow;
|
|
322
305
|
}
|
|
323
306
|
|
|
324
|
-
case 'arrow-table':
|
|
325
|
-
return getTableRowAsArray(table.data, rowIndex, target, copy);
|
|
326
|
-
|
|
327
307
|
default:
|
|
328
308
|
throw new Error('shape');
|
|
329
309
|
}
|