@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
|
@@ -2,5 +2,74 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
+
import type {LoaderOptions} from '../../loader-utils/loader-types';
|
|
6
|
+
|
|
5
7
|
export {setGlobalOptions as setLoaderOptions} from '../loader-utils/option-utils';
|
|
6
8
|
export {getGlobalLoaderOptions as getLoaderOptions} from '../loader-utils/option-utils';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Compares two option inputs without applying loader defaults or global options.
|
|
12
|
+
* Compares plain objects and arrays recursively, and callbacks and other objects by reference.
|
|
13
|
+
*/
|
|
14
|
+
export function compareLoaderOptions(
|
|
15
|
+
left: LoaderOptions | undefined,
|
|
16
|
+
right: LoaderOptions | undefined
|
|
17
|
+
): boolean {
|
|
18
|
+
return Object.is(left, right) || compareOptionValues(left, right, new WeakMap());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Compares option values and tracks visited object pairs to handle cycles. */
|
|
22
|
+
function compareOptionValues(
|
|
23
|
+
left: unknown,
|
|
24
|
+
right: unknown,
|
|
25
|
+
visited: WeakMap<object, WeakSet<object>>
|
|
26
|
+
): boolean {
|
|
27
|
+
if (Object.is(left, right)) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (!left || !right || typeof left !== 'object' || typeof right !== 'object') {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const leftPrototype = Object.getPrototypeOf(left);
|
|
35
|
+
if (leftPrototype !== Object.getPrototypeOf(right)) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (Array.isArray(left)) {
|
|
39
|
+
if (!Array.isArray(right) || left.length !== right.length) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
} else if (leftPrototype !== Object.prototype && leftPrototype !== null) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let rightValues = visited.get(left);
|
|
47
|
+
if (rightValues?.has(right)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (!rightValues) {
|
|
51
|
+
rightValues = new WeakSet();
|
|
52
|
+
visited.set(left, rightValues);
|
|
53
|
+
}
|
|
54
|
+
rightValues.add(right);
|
|
55
|
+
|
|
56
|
+
const leftKeys = getEnumerableKeys(left);
|
|
57
|
+
const rightKeys = getEnumerableKeys(right);
|
|
58
|
+
const leftOptions = left as Record<PropertyKey, unknown>;
|
|
59
|
+
const rightOptions = right as Record<PropertyKey, unknown>;
|
|
60
|
+
return (
|
|
61
|
+
leftKeys.length === rightKeys.length &&
|
|
62
|
+
leftKeys.every(
|
|
63
|
+
key =>
|
|
64
|
+
Object.prototype.propertyIsEnumerable.call(right, key) &&
|
|
65
|
+
compareOptionValues(leftOptions[key], rightOptions[key], visited)
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Returns own enumerable keys, including symbols. */
|
|
71
|
+
function getEnumerableKeys(value: object): PropertyKey[] {
|
|
72
|
+
return Reflect.ownKeys(value).filter(key =>
|
|
73
|
+
Object.prototype.propertyIsEnumerable.call(value, key)
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
|
|
6
|
-
|
|
7
5
|
import type {
|
|
8
6
|
LoaderArrayOptionsType,
|
|
9
7
|
LoaderShapeType,
|
|
@@ -118,21 +116,14 @@ export async function parseFile(
|
|
|
118
116
|
url,
|
|
119
117
|
normalizedOptions
|
|
120
118
|
);
|
|
121
|
-
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
|
|
122
119
|
context = getLoaderContext(
|
|
123
120
|
// @ts-expect-error candidateLoaders may be a single forced loader
|
|
124
121
|
{url, _parse: parse, loaders: candidateLoaders},
|
|
125
|
-
|
|
122
|
+
strictOptions,
|
|
126
123
|
context || null
|
|
127
124
|
);
|
|
128
125
|
|
|
129
|
-
|
|
130
|
-
loader,
|
|
131
|
-
file,
|
|
132
|
-
nativeArrowOptions || strictOptions,
|
|
133
|
-
context
|
|
134
|
-
);
|
|
135
|
-
return nativeArrowOptions ? unwrapArrowTable(result) : result;
|
|
126
|
+
return parseFileWithLoader(loader, file, strictOptions, context);
|
|
136
127
|
}
|
|
137
128
|
|
|
138
129
|
/**
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
usesNativeArrowBatches,
|
|
7
|
+
isArrowTable,
|
|
8
|
+
normalizeNativeArrowBatches
|
|
9
9
|
} from '../loader-utils/native-arrow';
|
|
10
10
|
|
|
11
11
|
import type {Batch, Table} from '@loaders.gl/core/schema';
|
|
@@ -146,10 +146,10 @@ export async function parseInBatches(
|
|
|
146
146
|
url || '',
|
|
147
147
|
normalizedOptions
|
|
148
148
|
);
|
|
149
|
-
const
|
|
149
|
+
const nativeArrow = usesNativeArrowBatches(loader, strictOptions);
|
|
150
150
|
context = getLoaderContext(
|
|
151
151
|
{url, _parseInBatches: parseInBatches, _parse: parse, loaders: loaderArray},
|
|
152
|
-
|
|
152
|
+
strictOptions,
|
|
153
153
|
context || null
|
|
154
154
|
);
|
|
155
155
|
|
|
@@ -158,10 +158,10 @@ export async function parseInBatches(
|
|
|
158
158
|
loader,
|
|
159
159
|
loaderWithParser,
|
|
160
160
|
data,
|
|
161
|
-
|
|
161
|
+
strictOptions,
|
|
162
162
|
context
|
|
163
163
|
);
|
|
164
|
-
return
|
|
164
|
+
return nativeArrow ? normalizeNativeArrowBatches(batches) : batches;
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/**
|
|
@@ -289,7 +289,7 @@ async function* parseChunkInBatches(
|
|
|
289
289
|
context
|
|
290
290
|
);
|
|
291
291
|
|
|
292
|
-
if (
|
|
292
|
+
if (isArrowTable(parsedData)) {
|
|
293
293
|
yield* parsedData.batches;
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
@@ -334,8 +334,6 @@ function isTable(value: unknown): value is Table {
|
|
|
334
334
|
return Array.isArray(table.features);
|
|
335
335
|
case 'columnar-table':
|
|
336
336
|
return Boolean(table.data && typeof table.data === 'object');
|
|
337
|
-
case 'arrow-table':
|
|
338
|
-
return Boolean(table.data && typeof table.data === 'object' && 'numRows' in table.data);
|
|
339
337
|
default:
|
|
340
338
|
return false;
|
|
341
339
|
}
|
|
@@ -349,8 +347,6 @@ function getTableLength(table: Table): number {
|
|
|
349
347
|
return table.data.length;
|
|
350
348
|
case 'geojson-table':
|
|
351
349
|
return table.features.length;
|
|
352
|
-
case 'arrow-table':
|
|
353
|
-
return table.data.numRows;
|
|
354
350
|
case 'columnar-table':
|
|
355
351
|
for (const column of Object.values(table.data)) {
|
|
356
352
|
return column.length || 0;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
|
|
6
|
-
|
|
7
5
|
import type {
|
|
8
6
|
LoaderArrayOptionsType,
|
|
9
7
|
LoaderShapeType,
|
|
@@ -116,21 +114,19 @@ export function parseSync(
|
|
|
116
114
|
const parse = () => {
|
|
117
115
|
throw new Error('parseSync called parse (which is async');
|
|
118
116
|
};
|
|
119
|
-
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
|
|
120
117
|
context = getLoaderContext(
|
|
121
118
|
{url, _parseSync: parse, _parse: parse, loaders: loaders as Loader[]},
|
|
122
|
-
|
|
119
|
+
strictOptions,
|
|
123
120
|
context || null
|
|
124
121
|
);
|
|
125
122
|
|
|
126
123
|
const loaderWithParser = getLoaderImplementationSync(loader);
|
|
127
|
-
|
|
124
|
+
return parseWithLoaderSync(
|
|
128
125
|
loaderWithParser || (loader as LoaderWithParser),
|
|
129
126
|
data,
|
|
130
|
-
|
|
127
|
+
strictOptions,
|
|
131
128
|
context
|
|
132
129
|
);
|
|
133
|
-
return nativeArrowOptions ? unwrapArrowTable(result, loader.supportsNativeArrow) : result;
|
|
134
130
|
}
|
|
135
131
|
|
|
136
132
|
// TODO - should accept loader.parseSync/parse and generate 1 chunk asyncIterator
|
package/src/lib/api/parse.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {getNativeArrowOptions, unwrapArrowTable} from '../loader-utils/native-arrow';
|
|
6
|
-
|
|
7
5
|
import {resolveLoaderAuthenticationOptions} from '@loaders.gl/core/loader-utils';
|
|
8
6
|
import type {
|
|
9
7
|
LoaderArrayOptionsType,
|
|
@@ -146,16 +144,14 @@ export async function parse(
|
|
|
146
144
|
);
|
|
147
145
|
|
|
148
146
|
// Get a context (if already present, will be unchanged)
|
|
149
|
-
const nativeArrowOptions = getNativeArrowOptions(loader, strictOptions, false);
|
|
150
147
|
context = getLoaderContext(
|
|
151
148
|
// @ts-expect-error
|
|
152
149
|
{url, _parse: parse, loaders: candidateLoaders},
|
|
153
|
-
|
|
150
|
+
strictOptions,
|
|
154
151
|
context || null
|
|
155
152
|
);
|
|
156
153
|
|
|
157
|
-
|
|
158
|
-
return nativeArrowOptions ? unwrapArrowTable(result, loader.supportsNativeArrow) : result;
|
|
154
|
+
return parseWithLoader(loader, data, strictOptions, context);
|
|
159
155
|
}
|
|
160
156
|
|
|
161
157
|
// TODO - should accept loader.parseAsyncIterator and concatenate.
|
|
@@ -14,56 +14,28 @@ export function getShapeOptionKey(loader: Loader): string | undefined {
|
|
|
14
14
|
return keys.includes(loader.id) ? loader.id : keys.length === 1 ? keys[0] : undefined;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
export function
|
|
19
|
-
loader: Loader,
|
|
20
|
-
options: StrictLoaderOptions,
|
|
21
|
-
inBatches = false
|
|
22
|
-
): StrictLoaderOptions | null {
|
|
17
|
+
/** Checks for an Arrow stream and validates its metadata options. */
|
|
18
|
+
export function usesNativeArrowBatches(loader: Loader, options: StrictLoaderOptions): boolean {
|
|
23
19
|
const key = getShapeOptionKey(loader);
|
|
24
20
|
const scopedOptions = key && options[key];
|
|
25
|
-
if (
|
|
26
|
-
loader.supportsNativeArrow &&
|
|
27
|
-
scopedOptions &&
|
|
28
|
-
typeof scopedOptions === 'object' &&
|
|
29
|
-
'shape' in scopedOptions &&
|
|
30
|
-
scopedOptions.shape === 'arrow-table'
|
|
31
|
-
) {
|
|
32
|
-
throw new Error('This loader uses shape: "arrow" for native Arrow output');
|
|
33
|
-
}
|
|
34
21
|
if (
|
|
35
22
|
!scopedOptions ||
|
|
36
23
|
typeof scopedOptions !== 'object' ||
|
|
37
24
|
!('shape' in scopedOptions) ||
|
|
38
25
|
scopedOptions.shape !== 'arrow'
|
|
39
26
|
) {
|
|
40
|
-
return
|
|
27
|
+
return false;
|
|
41
28
|
}
|
|
42
|
-
if (
|
|
29
|
+
if (options.core?.metadata) {
|
|
43
30
|
throw new Error(
|
|
44
31
|
'shape: "arrow" carries metadata in the Arrow schema and does not support core.metadata envelopes'
|
|
45
32
|
);
|
|
46
33
|
}
|
|
47
|
-
|
|
48
|
-
return {
|
|
49
|
-
...options,
|
|
50
|
-
core: {...options.core, ...(options.core?.shape === 'arrow' ? {shape: 'arrow-table'} : {})},
|
|
51
|
-
[key!]: {...scopedOptions, shape: 'arrow-table'}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Unwraps legacy tables and passes through results from native parsers. */
|
|
56
|
-
export function unwrapArrowTable(result: unknown): arrow.Table;
|
|
57
|
-
export function unwrapArrowTable(result: unknown, nativeParser: boolean | undefined): unknown;
|
|
58
|
-
export function unwrapArrowTable(result: unknown, nativeParser?: boolean): unknown {
|
|
59
|
-
const table = result as {shape?: string; data?: arrow.Table} | null;
|
|
60
|
-
if (table?.shape === 'arrow-table' && Array.isArray(table.data?.batches)) return table.data;
|
|
61
|
-
if (nativeParser || isNativeArrowTable(result)) return result;
|
|
62
|
-
throw new Error('shape: "arrow" requires a loader that supports "arrow-table" output');
|
|
34
|
+
return true;
|
|
63
35
|
}
|
|
64
36
|
|
|
65
37
|
/** Yields every record batch, preserving order and iterator cancellation. */
|
|
66
|
-
export async function*
|
|
38
|
+
export async function* normalizeNativeArrowBatches(
|
|
67
39
|
batches: AsyncIterable<unknown> | Iterable<unknown>
|
|
68
40
|
): AsyncIterable<arrow.RecordBatch> {
|
|
69
41
|
for await (const batch of batches) {
|
|
@@ -76,16 +48,18 @@ export async function* unwrapArrowBatches(
|
|
|
76
48
|
) {
|
|
77
49
|
continue;
|
|
78
50
|
}
|
|
79
|
-
if (
|
|
51
|
+
if (isArrowRecordBatch(batch)) {
|
|
80
52
|
yield batch;
|
|
53
|
+
} else if (isArrowTable(batch)) {
|
|
54
|
+
yield* batch.batches;
|
|
81
55
|
} else {
|
|
82
|
-
|
|
56
|
+
throw new Error('shape: "arrow" requires a native Arrow table or record batch');
|
|
83
57
|
}
|
|
84
58
|
}
|
|
85
59
|
}
|
|
86
60
|
|
|
87
61
|
/** Identifies native Arrow tables without loading Arrow in the core entry point. */
|
|
88
|
-
export function
|
|
62
|
+
export function isArrowTable(value: unknown): value is arrow.Table {
|
|
89
63
|
return Boolean(
|
|
90
64
|
value &&
|
|
91
65
|
typeof value === 'object' &&
|
|
@@ -100,7 +74,7 @@ export function isNativeArrowTable(value: unknown): value is arrow.Table {
|
|
|
100
74
|
}
|
|
101
75
|
|
|
102
76
|
/** Identifies native record batches across Arrow package instances. */
|
|
103
|
-
export function
|
|
77
|
+
export function isArrowRecordBatch(value: unknown): value is arrow.RecordBatch {
|
|
104
78
|
return Boolean(
|
|
105
79
|
value &&
|
|
106
80
|
typeof value === 'object' &&
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {SQLQuery} from '@math.gl/
|
|
5
|
+
import type {SQLQuery} from '@math.gl/sql/parser';
|
|
6
6
|
import type {DataType, FieldMetadata, Schema} from '@loaders.gl/core/schema';
|
|
7
7
|
import type {ColumnarPredicate, ColumnarPredicateProperty} from './columnar-predicate';
|
|
8
8
|
import type {
|
|
@@ -148,6 +148,8 @@ export type ScanQueryMetadata = Readonly<{
|
|
|
148
148
|
statistics?: ScanSourceStatistics;
|
|
149
149
|
/** Optional multiscale raster levels. */
|
|
150
150
|
levels?: readonly ScanRasterLevel[];
|
|
151
|
+
/** The source or a child applies a configured row window to direct reads by default. */
|
|
152
|
+
hasDefaultRowWindow?: boolean;
|
|
151
153
|
}>;
|
|
152
154
|
|
|
153
155
|
/** Options accepted by query metadata discovery methods. */
|
|
@@ -341,6 +343,8 @@ export type CreateScanQueryMetadataOptions = Readonly<{
|
|
|
341
343
|
statistics?: ScanSourceStatistics;
|
|
342
344
|
/** Optional multiscale raster levels. */
|
|
343
345
|
levels?: readonly ScanRasterLevel[];
|
|
346
|
+
/** The source or a child applies a configured row window to direct reads by default. */
|
|
347
|
+
hasDefaultRowWindow?: boolean;
|
|
344
348
|
}>;
|
|
345
349
|
|
|
346
350
|
/**
|
|
@@ -381,6 +385,7 @@ export function createScanQueryMetadata(options: CreateScanQueryMetadataOptions)
|
|
|
381
385
|
columns: Object.freeze(columns),
|
|
382
386
|
capabilities: queryCapabilities,
|
|
383
387
|
queryCapabilities,
|
|
388
|
+
...(options.hasDefaultRowWindow ? {hasDefaultRowWindow: true} : {}),
|
|
384
389
|
spatial: options.spatial
|
|
385
390
|
? Object.freeze({
|
|
386
391
|
...options.spatial,
|
|
@@ -454,11 +459,7 @@ export type TableQueryPushdownPlan = Readonly<{
|
|
|
454
459
|
/** Exact output schema, including aliases, CAST types, and nullability. */
|
|
455
460
|
schema: Schema;
|
|
456
461
|
/** Executes on demand with equivalent order, error semantics, and cancellation. */
|
|
457
|
-
read: (
|
|
458
|
-
options?: ScanQueryMetadataOptions
|
|
459
|
-
) => AsyncIterable<
|
|
460
|
-
import('apache-arrow').RecordBatch | import('@loaders.gl/core/schema').ArrowTableBatch
|
|
461
|
-
>;
|
|
462
|
+
read: (options?: ScanQueryMetadataOptions) => AsyncIterable<import('apache-arrow').RecordBatch>;
|
|
462
463
|
}>;
|
|
463
464
|
|
|
464
465
|
/** Preferred name for source discovery metadata. */
|
|
@@ -2,51 +2,51 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {Table as ApacheArrowTable, RecordBatch} from 'apache-arrow';
|
|
6
|
+
import type {TableBatch} from '@loaders.gl/core/schema';
|
|
6
7
|
import type {TableScanReadOptions, TableQueryExecutionSummary} from './scan-query-metadata';
|
|
7
8
|
import {emitQueryComplete} from './scan-query-metadata';
|
|
8
9
|
import {filterColumnarRowIndices, validateColumnarPredicate} from './columnar-predicate';
|
|
9
10
|
import {validateTableQueryLimit, validateTableQueryOffset} from './table-query';
|
|
10
11
|
|
|
12
|
+
/** Physical batches handled by the shared scan executor. */
|
|
13
|
+
type ScanBatch = TableBatch | ApacheArrowTable | RecordBatch;
|
|
14
|
+
|
|
11
15
|
/** Reads source batches while allowing the shared executor to observe fetched bytes. */
|
|
12
|
-
export type TableScanBatchReader = (
|
|
16
|
+
export type TableScanBatchReader<BatchT = TableBatch> = (
|
|
13
17
|
signal?: AbortSignal,
|
|
14
18
|
onByteLength?: (byteLength: number) => void
|
|
15
|
-
) => AsyncIterable<
|
|
19
|
+
) => AsyncIterable<BatchT>;
|
|
16
20
|
|
|
17
21
|
/** Optional batch kernels for formats with a native vectorized predicate implementation. */
|
|
18
|
-
export type TableScanBatchOperators = Readonly<{
|
|
22
|
+
export type TableScanBatchOperators<BatchT = TableBatch> = Readonly<{
|
|
19
23
|
/** Applies a residual predicate locally or on a worker; async kernels must observe the signal. */
|
|
20
24
|
filter?: (
|
|
21
|
-
batch:
|
|
25
|
+
batch: BatchT,
|
|
22
26
|
predicate: TableScanReadOptions['predicate'],
|
|
23
27
|
signal?: AbortSignal
|
|
24
|
-
) =>
|
|
28
|
+
) => BatchT | Promise<BatchT>;
|
|
25
29
|
/** Applies a projection while preserving the source batch shape. */
|
|
26
|
-
project?: (batch:
|
|
30
|
+
project?: (batch: BatchT, columns?: readonly string[]) => BatchT;
|
|
27
31
|
}>;
|
|
28
32
|
|
|
29
|
-
/** Wraps an Arrow table in the standard single-result scan batch envelope. */
|
|
30
|
-
export function makeTableScanBatch(table: ArrowTable): ArrowTableBatch {
|
|
31
|
-
return {...table, batchType: 'data', length: table.data.numRows} as ArrowTableBatch;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
33
|
/**
|
|
35
|
-
* Executes the common residual table-scan stages for row and
|
|
34
|
+
* Executes the common residual table-scan stages for row, columnar, and native Arrow chunks.
|
|
35
|
+
* Native Arrow predicates require a format-supplied filter kernel.
|
|
36
36
|
*
|
|
37
37
|
* Format adapters provide only their parser-specific batch reader. Keeping filtering, projection,
|
|
38
38
|
* limits, cancellation, and telemetry here avoids copying the same executor into every format
|
|
39
39
|
* package while preserving each format's native batch shape.
|
|
40
40
|
*/
|
|
41
|
-
export async function* executeTableScanBatches(
|
|
42
|
-
readBatches: TableScanBatchReader
|
|
41
|
+
export async function* executeTableScanBatches<BatchT extends ScanBatch>(
|
|
42
|
+
readBatches: TableScanBatchReader<BatchT>,
|
|
43
43
|
options: TableScanReadOptions &
|
|
44
44
|
Readonly<{
|
|
45
45
|
/** Omits empty batches from the output stream. */
|
|
46
46
|
skipEmptyBatches?: boolean;
|
|
47
47
|
}> = {},
|
|
48
|
-
operators: TableScanBatchOperators = {}
|
|
49
|
-
): AsyncIterable<
|
|
48
|
+
operators: TableScanBatchOperators<NoInfer<BatchT>> = {}
|
|
49
|
+
): AsyncIterable<BatchT> {
|
|
50
50
|
validateTableQueryLimit(options.limit);
|
|
51
51
|
validateTableQueryOffset(options.offset);
|
|
52
52
|
let skip = options.offset ?? 0;
|
|
@@ -80,30 +80,37 @@ export async function* executeTableScanBatches(
|
|
|
80
80
|
}
|
|
81
81
|
options.signal?.throwIfAborted();
|
|
82
82
|
batchesRead++;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
const rowCount = getScanBatchRowCount(batch);
|
|
84
|
+
rowsRead += rowCount;
|
|
85
|
+
if (options.predicate && !operators.filter && !('shape' in batch)) {
|
|
86
|
+
throw new Error('Native Arrow scans require a filter kernel for residual predicates.');
|
|
87
|
+
}
|
|
88
|
+
const filteredBatch = operators.filter
|
|
89
|
+
? await operators.filter(batch, options.predicate, options.signal)
|
|
90
|
+
: (('shape' in batch ? filterTableBatch(batch, options.predicate) : batch) as BatchT);
|
|
89
91
|
options.signal?.throwIfAborted();
|
|
92
|
+
const filteredRowCount = getScanBatchRowCount(filteredBatch);
|
|
90
93
|
if (options.predicate) {
|
|
91
|
-
rowsTested +=
|
|
92
|
-
rowsRetained +=
|
|
94
|
+
rowsTested += rowCount;
|
|
95
|
+
rowsRetained += filteredRowCount;
|
|
93
96
|
}
|
|
94
|
-
if (skip >=
|
|
95
|
-
skip -=
|
|
97
|
+
if (skip >= filteredRowCount && (skip > 0 || options.skipEmptyBatches)) {
|
|
98
|
+
skip -= filteredRowCount;
|
|
96
99
|
continue;
|
|
97
100
|
}
|
|
98
|
-
const end = Math.min(
|
|
101
|
+
const end = Math.min(filteredRowCount, skip + remaining);
|
|
99
102
|
const window =
|
|
100
|
-
skip || end <
|
|
101
|
-
?
|
|
103
|
+
skip || end < filteredRowCount
|
|
104
|
+
? (('shape' in filteredBatch
|
|
105
|
+
? sliceTableBatch(filteredBatch, skip, end)
|
|
106
|
+
: filteredBatch.slice(skip, end)) as BatchT)
|
|
102
107
|
: filteredBatch;
|
|
103
108
|
skip = 0;
|
|
104
|
-
const output =
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
const output = operators.project
|
|
110
|
+
? operators.project(window, options.columns)
|
|
111
|
+
: projectTableBatch(window, options.columns);
|
|
112
|
+
remaining -= getScanBatchRowCount(window);
|
|
113
|
+
rowsReturned += getScanBatchRowCount(output);
|
|
107
114
|
if (remaining === 0) earlyTerminationReason = 'limit';
|
|
108
115
|
yield output;
|
|
109
116
|
if (remaining === 0) return;
|
|
@@ -142,9 +149,19 @@ export async function* executeTableScanBatches(
|
|
|
142
149
|
}
|
|
143
150
|
}
|
|
144
151
|
|
|
152
|
+
/** Reads the row count from native Arrow chunks and portable batch envelopes. */
|
|
153
|
+
function getScanBatchRowCount(batch: ScanBatch): number {
|
|
154
|
+
return 'shape' in batch ? batch.length : batch.numRows;
|
|
155
|
+
}
|
|
156
|
+
|
|
145
157
|
/** Truncates a batch without changing its native representation. */
|
|
146
|
-
export function truncateTableBatch
|
|
147
|
-
|
|
158
|
+
export function truncateTableBatch<BatchType extends ScanBatch>(
|
|
159
|
+
batch: BatchType,
|
|
160
|
+
length: number
|
|
161
|
+
): BatchType {
|
|
162
|
+
return (
|
|
163
|
+
'shape' in batch ? sliceTableBatch(batch, 0, length) : batch.slice(0, length)
|
|
164
|
+
) as BatchType;
|
|
148
165
|
}
|
|
149
166
|
|
|
150
167
|
/** Slices rows in a batch, preserving Arrow buffers and the batch shape. */
|
|
@@ -165,30 +182,36 @@ function sliceTableBatch(batch: TableBatch, start: number, end: number): TableBa
|
|
|
165
182
|
length
|
|
166
183
|
};
|
|
167
184
|
}
|
|
168
|
-
if (batch.shape === 'arrow-table') return {...batch, data: batch.data.slice(start, end), length};
|
|
169
185
|
return {...batch, features: batch.features.slice(start, end), length};
|
|
170
186
|
}
|
|
171
187
|
|
|
172
188
|
/** Projects a batch in the caller-requested order while preserving its shape. */
|
|
173
|
-
export function projectTableBatch
|
|
189
|
+
export function projectTableBatch<BatchType extends ScanBatch>(
|
|
190
|
+
batch: BatchType,
|
|
191
|
+
columns?: readonly string[]
|
|
192
|
+
): BatchType {
|
|
174
193
|
if (columns === undefined) return batch;
|
|
194
|
+
if (!('shape' in batch)) {
|
|
195
|
+
const indices = columns
|
|
196
|
+
.map(column => batch.schema.fields.findIndex(field => field.name === column))
|
|
197
|
+
.filter(index => index >= 0);
|
|
198
|
+
return batch.selectAt(indices) as BatchType;
|
|
199
|
+
}
|
|
175
200
|
const schema = projectTableSchema(batch, columns);
|
|
176
201
|
if (batch.shape === 'object-row-table') {
|
|
177
202
|
return {
|
|
178
203
|
...batch,
|
|
179
204
|
schema,
|
|
180
205
|
data: batch.data.map(row => Object.fromEntries(columns.map(column => [column, row[column]])))
|
|
181
|
-
} as
|
|
206
|
+
} as BatchType;
|
|
182
207
|
}
|
|
183
208
|
if (batch.shape === 'columnar-table') {
|
|
184
209
|
return {
|
|
185
210
|
...batch,
|
|
186
211
|
schema,
|
|
187
212
|
data: Object.fromEntries(columns.map(column => [column, batch.data[column]]))
|
|
188
|
-
};
|
|
213
|
+
} as BatchType;
|
|
189
214
|
}
|
|
190
|
-
if (batch.shape === 'arrow-table')
|
|
191
|
-
return {...batch, schema, data: batch.data.select([...columns])};
|
|
192
215
|
return batch;
|
|
193
216
|
}
|
|
194
217
|
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import type {ArrowTable
|
|
5
|
+
import type {Table as ArrowTable} from 'apache-arrow';
|
|
6
|
+
import type {Schema} from '@loaders.gl/core/schema';
|
|
6
7
|
import type {TableScanSource} from '../scan-utils/scan-query-metadata';
|
|
7
8
|
|
|
8
9
|
/** Source exposing named tables. Returned handles remain owned by the source or caller. */
|
|
@@ -3,17 +3,11 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Table} from 'apache-arrow';
|
|
6
|
-
import type {
|
|
7
|
-
Schema,
|
|
8
|
-
Feature,
|
|
9
|
-
GeoJSONTable,
|
|
10
|
-
BinaryFeatureCollection,
|
|
11
|
-
ArrowTable
|
|
12
|
-
} from '@loaders.gl/core/schema';
|
|
6
|
+
import type {Schema, Feature, GeoJSONTable, BinaryFeatureCollection} from '@loaders.gl/core/schema';
|
|
13
7
|
import {TileSource, TileSourceProps, GetTileParameters} from './tile-source';
|
|
14
8
|
import type {GetTileDataParameters} from './tile-source';
|
|
15
9
|
|
|
16
|
-
export type VectorTile = Feature[] | GeoJSONTable | BinaryFeatureCollection |
|
|
10
|
+
export type VectorTile = Feature[] | GeoJSONTable | BinaryFeatureCollection | Table;
|
|
17
11
|
|
|
18
12
|
export type VectorTileSourceProps = TileSourceProps;
|
|
19
13
|
|
|
@@ -26,5 +20,5 @@ export interface VectorTileSource extends TileSource {
|
|
|
26
20
|
getVectorTile(parameters: GetTileParameters): Promise<VectorTile | null>;
|
|
27
21
|
getTileData(
|
|
28
22
|
parameters: GetTileDataParameters
|
|
29
|
-
): Promise<Feature[] | GeoJSONTable | BinaryFeatureCollection |
|
|
23
|
+
): Promise<Feature[] | GeoJSONTable | BinaryFeatureCollection | Table | null>;
|
|
30
24
|
}
|
|
@@ -492,9 +492,9 @@ type NativeArrowOutput<T, Options, Wrapped, Native> = [Options] extends [never]
|
|
|
492
492
|
: never;
|
|
493
493
|
|
|
494
494
|
/** Selects native output when certain and a union when shape selection is dynamic. */
|
|
495
|
-
type NativeArrowOutputForOption<T, Options, Wrapped, Native> = [
|
|
496
|
-
|
|
497
|
-
]
|
|
495
|
+
type NativeArrowOutputForOption<T, Options, Wrapped, Native> = [Extract<Wrapped, Native>] extends [
|
|
496
|
+
never
|
|
497
|
+
]
|
|
498
498
|
? Wrapped
|
|
499
499
|
: [RequiredOutputShape<T, Options>] extends [never]
|
|
500
500
|
? [
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import {compileArrowArray, compileArrowExpression} from '@math.gl/
|
|
7
|
-
import type {TableSelection} from '@math.gl/
|
|
8
|
-
import {getExpressionColumns} from '@math.gl/expressions';
|
|
6
|
+
import {compileArrowArray, compileArrowExpression} from '@math.gl/sql/arrow';
|
|
7
|
+
import type {TableSelection} from '@math.gl/sql/parser';
|
|
8
|
+
import {getExpressionColumns} from '@math.gl/sql/expressions';
|
|
9
9
|
|
|
10
|
-
export {compileArrowExpression, compileArrowPredicate} from '@math.gl/
|
|
11
|
-
export {getExpressionColumns} from '@math.gl/expressions';
|
|
10
|
+
export {compileArrowExpression, compileArrowPredicate} from '@math.gl/sql/arrow';
|
|
11
|
+
export {getExpressionColumns} from '@math.gl/sql/expressions';
|
|
12
12
|
|
|
13
13
|
/** Finds source columns and rejects ambiguous projection shapes before a scan. */
|
|
14
14
|
export function getProjectionColumns(selections: readonly TableSelection[]): string[] {
|
|
@@ -87,8 +87,8 @@ export function compileArrowProjection(
|
|
|
87
87
|
|
|
88
88
|
/** Converts typed SELECT items into ordinary SQL CAST expressions. */
|
|
89
89
|
export function normalizeTypedProjection(
|
|
90
|
-
query: import('../query').TypedTableQuery | import('@math.gl/
|
|
91
|
-
): import('@math.gl/
|
|
90
|
+
query: import('../query').TypedTableQuery | import('@math.gl/sql/parser').TableQuery
|
|
91
|
+
): import('@math.gl/sql/parser').TableQuery {
|
|
92
92
|
return {
|
|
93
93
|
...query,
|
|
94
94
|
select: query.select?.map(item => {
|