@loaders.gl/core 5.0.0-rc.1 → 5.0.0
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 +8 -8
- package/dist/arrow-geometry/binary-features.cjs +2 -2
- package/dist/arrow-geometry/binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/binary-features.js +1 -1
- package/dist/arrow-geometry/binary-features.js.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.cjs +51 -50
- package/dist/arrow-geometry/geometry-codecs.cjs.map +3 -3
- package/dist/arrow-geometry/geometry-codecs.d.ts +1 -1
- package/dist/arrow-geometry/geometry-codecs.d.ts.map +1 -1
- package/dist/arrow-geometry/geometry-codecs.js +27 -60
- package/dist/arrow-geometry/geometry-codecs.js.map +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.cjs +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.cjs.map +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.js.map +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.cjs +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.cjs.map +2 -2
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.js +1 -1
- package/dist/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.js.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb.cjs +33 -118
- package/dist/arrow-geometry/triangulate-wkb.cjs.map +2 -2
- package/dist/arrow-geometry/triangulate-wkb.d.ts.map +1 -1
- package/dist/arrow-geometry/triangulate-wkb.js +39 -142
- package/dist/arrow-geometry/triangulate-wkb.js.map +1 -1
- package/dist/cluster-source.cjs +128 -374
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/constants/index.cjs +2 -2
- package/dist/constants/index.d.ts +4 -4
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +2 -2
- package/dist/constants/index.js.map +1 -1
- package/dist/dist.dev.js +63 -15
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +174 -660
- package/dist/federated-table-scan-source.cjs.map +3 -3
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs +15 -0
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.cjs.map +2 -2
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js +19 -1
- package/dist/geoarrow/geoarrow-converter/convert-geoarrow-geometry.js.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs +6 -27
- package/dist/geoarrow/get-geoarrow-vertex-count.cjs.map +2 -2
- package/dist/geoarrow/get-geoarrow-vertex-count.d.ts.map +1 -1
- package/dist/geoarrow/get-geoarrow-vertex-count.js +9 -24
- package/dist/geoarrow/get-geoarrow-vertex-count.js.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs +3 -5
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.cjs.map +2 -2
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts +2 -24
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.d.ts.map +1 -1
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js +6 -28
- package/dist/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.js.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs +20 -226
- package/dist/geoarrow/lib/kernels/decode-wkt-native.cjs.map +2 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts +1 -2
- package/dist/geoarrow/lib/kernels/decode-wkt-native.d.ts.map +1 -1
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js +23 -264
- package/dist/geoarrow/lib/kernels/decode-wkt-native.js.map +1 -1
- package/dist/index.cjs +67 -19
- package/dist/index.cjs.map +1 -1
- package/dist/lib/api/load.js +36 -7
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse.js +5 -2
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/loader-utils/index.cjs +67 -229
- package/dist/loader-utils/index.cjs.map +2 -2
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/json-loader.js.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts +4 -52
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js +16 -236
- package/dist/loader-utils/lib/scan-utils/columnar-predicate.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts +2 -0
- package/dist/loader-utils/lib/scan-utils/relational-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/relational-query.js.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.js +1 -1
- package/dist/loader-utils/lib/sources/tile-grid.js.map +1 -1
- package/dist/loader-utils/lib/sources/tile-source-adapter.js +1 -1
- package/dist/loader-utils/lib/sources/tile-source-adapter.js.map +1 -1
- package/dist/loader-utils/lib/sources/tile-source.d.ts +1 -1
- package/dist/loader-utils/lib/sources/tile-source.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +6 -0
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/tile-grid.cjs +5 -5
- package/dist/loader-utils/tile-grid.cjs.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-loader.js.map +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +9 -78
- package/dist/scan/arrow-execution/expressions.cjs.map +3 -3
- package/dist/scan/arrow-execution/expressions.d.ts +2 -8
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +2 -55
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +41 -179
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +3 -3
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +1 -5
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +44 -190
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/arrow-execution.cjs +2 -2
- package/dist/scan/arrow-execution.cjs.map +2 -2
- package/dist/scan/arrow-execution.d.ts +1 -1
- package/dist/scan/arrow-execution.d.ts.map +1 -1
- package/dist/scan/arrow-execution.js +1 -1
- package/dist/scan/arrow-execution.js.map +1 -1
- package/dist/scan/arrow-query.cjs +3 -3
- package/dist/scan/arrow-query.cjs.map +2 -2
- package/dist/scan/arrow-query.d.ts +2 -2
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/arrow-query.js +2 -2
- package/dist/scan/arrow-query.js.map +1 -1
- package/dist/scan/federated-table-scan-source.cjs +3 -3
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.js +1 -1
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +9 -49
- package/dist/scan/index.cjs.map +3 -3
- package/dist/scan/index.d.ts +2 -2
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +2 -2
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/plan-arrow-table-query.cjs +271 -0
- package/dist/scan/plan-arrow-table-query.cjs.map +7 -0
- package/dist/scan/plan-arrow-table-query.d.ts +50 -0
- package/dist/scan/plan-arrow-table-query.d.ts.map +1 -0
- package/dist/scan/plan-arrow-table-query.js +257 -0
- package/dist/scan/plan-arrow-table-query.js.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.cjs +2 -39
- package/dist/scan/query-arrow-table-in-batches.cjs.map +2 -2
- package/dist/scan/query-arrow-table-in-batches.d.ts +1 -1
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.js +3 -26
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -1
- package/dist/scan/query-arrow-table.cjs +7 -443
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +6 -54
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +6 -475
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query-pushdown.cjs +3 -4
- package/dist/scan/query-pushdown.cjs.map +2 -2
- package/dist/scan/query-pushdown.js +4 -5
- package/dist/scan/query-pushdown.js.map +1 -1
- package/dist/scan/query-scales.cjs +2 -1
- package/dist/scan/query-scales.cjs.map +2 -2
- package/dist/scan/query-scales.d.ts +2 -1
- package/dist/scan/query-scales.d.ts.map +1 -1
- package/dist/scan/query-scales.js +2 -1
- package/dist/scan/query-scales.js.map +1 -1
- package/dist/scan/query.cjs +10 -9
- package/dist/scan/query.cjs.map +2 -2
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +14 -5
- package/dist/scan/query.js.map +1 -1
- package/dist/scan/scan-engine.cjs +14 -7
- package/dist/scan/scan-engine.cjs.map +2 -2
- package/dist/scan/scan-engine.d.ts +2 -2
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js +5 -10
- package/dist/scan/scan-engine.js.map +1 -1
- package/dist/scan/sql-predicate-schema.cjs +10 -94
- package/dist/scan/sql-predicate-schema.cjs.map +3 -3
- package/dist/scan/sql-predicate-schema.d.ts +1 -1
- package/dist/scan/sql-predicate-schema.d.ts.map +1 -1
- package/dist/scan/sql-predicate-schema.js +9 -103
- package/dist/scan/sql-predicate-schema.js.map +1 -1
- package/dist/scan/sql-predicate-zod.cjs.map +1 -1
- package/dist/scan/sql-predicate-zod.d.ts +1 -1
- package/dist/scan/sql-predicate-zod.js +1 -1
- package/dist/scan/vector-table-scan-source.cjs +14 -3
- package/dist/scan/vector-table-scan-source.cjs.map +2 -2
- package/dist/scan/vector-table-scan-source.d.ts +1 -1
- package/dist/scan/vector-table-scan-source.d.ts.map +1 -1
- package/dist/scan/vector-table-scan-source.js +2 -1
- package/dist/scan/vector-table-scan-source.js.map +1 -1
- package/dist/schema-utils/index.cjs +11 -47
- package/dist/schema-utils/index.cjs.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts +2 -4
- package/dist/schema-utils/lib/arrow/arrow-metadata.d.ts.map +1 -1
- package/dist/schema-utils/lib/arrow/arrow-metadata.js +2 -43
- package/dist/schema-utils/lib/arrow/arrow-metadata.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +905 -1453
- package/dist/vector-table-scan-source.cjs.map +3 -3
- package/dist/wkt/twkb/index.cjs +68 -5
- package/dist/wkt/twkb/index.cjs.map +3 -3
- package/dist/wkt/twkb/index.d.ts +10 -2
- package/dist/wkt/twkb/index.d.ts.map +1 -1
- package/dist/wkt/twkb/index.js +49 -2
- package/dist/wkt/twkb/index.js.map +1 -1
- package/dist/worker-utils/index.cjs +33 -9
- package/dist/worker-utils/index.cjs.map +1 -1
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/env-utils/version.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts +4 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/process-on-worker.js +40 -6
- package/dist/worker-utils/lib/worker-api/process-on-worker.js.map +1 -1
- package/package.json +24 -104
- package/src/arrow-geometry/binary-features.ts +1 -1
- package/src/arrow-geometry/geometry-codecs.ts +35 -78
- package/src/arrow-geometry/legacy-binary/convert-flat-geojson-to-binary-features.ts +1 -1
- package/src/arrow-geometry/legacy-binary/convert-geojson-to-flat-geojson.ts +1 -1
- package/src/arrow-geometry/triangulate-wkb.ts +37 -169
- package/src/constants/index.ts +2 -2
- package/src/geoarrow/geoarrow-converter/convert-geoarrow-geometry.ts +22 -1
- package/src/geoarrow/get-geoarrow-vertex-count.ts +7 -32
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +1 -1
- package/src/geoarrow/lib/geometry-converters/wkb/helpers/parse-wkb-header.ts +6 -30
- package/src/geoarrow/lib/kernels/decode-wkt-native.ts +23 -269
- package/src/lib/api/load.ts +36 -7
- package/src/lib/api/parse.ts +6 -2
- package/src/loader-utils/lib/scan-utils/columnar-predicate.ts +46 -363
- package/src/loader-utils/lib/scan-utils/relational-query.ts +7 -1
- package/src/loader-utils/lib/sources/tile-grid.ts +6 -2
- package/src/loader-utils/lib/sources/tile-source-adapter.ts +1 -1
- package/src/loader-utils/lib/sources/tile-source.ts +1 -1
- package/src/loader-utils/loader-types.ts +6 -0
- package/src/scan/arrow-execution/expressions.ts +2 -86
- package/src/scan/arrow-execution/filter-arrow-table.ts +54 -238
- package/src/scan/arrow-execution.ts +1 -1
- package/src/scan/arrow-query.ts +2 -2
- package/src/scan/federated-table-scan-source.ts +1 -1
- package/src/scan/index.ts +2 -2
- package/src/scan/plan-arrow-table-query.ts +367 -0
- package/src/scan/query-arrow-table-in-batches.ts +4 -33
- package/src/scan/query-arrow-table.ts +10 -626
- package/src/scan/query-pushdown.ts +3 -4
- package/src/scan/query-scales.ts +3 -4
- package/src/scan/query.ts +16 -10
- package/src/scan/scan-engine.ts +5 -12
- package/src/scan/sql-predicate-schema.ts +14 -125
- package/src/scan/sql-predicate-zod.ts +1 -1
- package/src/scan/vector-table-scan-source.ts +2 -1
- package/src/schema-utils/lib/arrow/arrow-metadata.ts +2 -50
- package/src/wkt/twkb/index.ts +63 -2
- package/src/worker-utils/lib/worker-api/process-on-worker.ts +39 -6
- package/dist/scan/arrow-execution/portable-predicate-compatibility.cjs +0 -41
- package/dist/scan/arrow-execution/portable-predicate-compatibility.cjs.map +0 -7
- package/dist/scan/arrow-execution/portable-predicate-compatibility.d.ts +0 -5
- package/dist/scan/arrow-execution/portable-predicate-compatibility.d.ts.map +0 -1
- package/dist/scan/arrow-execution/portable-predicate-compatibility.js +0 -23
- package/dist/scan/arrow-execution/portable-predicate-compatibility.js.map +0 -1
- package/dist/scan/arrow-execution/project-arrow-table.cjs +0 -70
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +0 -7
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +0 -8
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +0 -1
- package/dist/scan/arrow-execution/project-arrow-table.js +0 -39
- package/dist/scan/arrow-execution/project-arrow-table.js.map +0 -1
- package/dist/scan/query-arrow-table-math.cjs +0 -41
- package/dist/scan/query-arrow-table-math.cjs.map +0 -7
- package/dist/scan/query-arrow-table-math.d.ts +0 -5
- package/dist/scan/query-arrow-table-math.d.ts.map +0 -1
- package/dist/scan/query-arrow-table-math.js +0 -14
- package/dist/scan/query-arrow-table-math.js.map +0 -1
- package/dist/wkt/twkb/convert-geometry-to-twkb.cjs +0 -211
- package/dist/wkt/twkb/convert-geometry-to-twkb.cjs.map +0 -7
- package/dist/wkt/twkb/convert-geometry-to-twkb.d.ts +0 -6
- package/dist/wkt/twkb/convert-geometry-to-twkb.d.ts.map +0 -1
- package/dist/wkt/twkb/convert-geometry-to-twkb.js +0 -204
- package/dist/wkt/twkb/convert-geometry-to-twkb.js.map +0 -1
- package/dist/wkt/twkb/convert-twkb-to-geometry.cjs +0 -251
- package/dist/wkt/twkb/convert-twkb-to-geometry.cjs.map +0 -7
- package/dist/wkt/twkb/convert-twkb-to-geometry.d.ts +0 -10
- package/dist/wkt/twkb/convert-twkb-to-geometry.d.ts.map +0 -1
- package/dist/wkt/twkb/convert-twkb-to-geometry.js +0 -261
- package/dist/wkt/twkb/convert-twkb-to-geometry.js.map +0 -1
- package/dist/wkt/twkb/twkb-io.cjs +0 -102
- package/dist/wkt/twkb/twkb-io.cjs.map +0 -7
- package/dist/wkt/twkb/twkb-io.d.ts +0 -33
- package/dist/wkt/twkb/twkb-io.d.ts.map +0 -1
- package/dist/wkt/twkb/twkb-io.js +0 -78
- package/dist/wkt/twkb/twkb-io.js.map +0 -1
- package/dist/wkt/twkb/twkb-types.cjs +0 -40
- package/dist/wkt/twkb/twkb-types.cjs.map +0 -7
- package/dist/wkt/twkb/twkb-types.d.ts +0 -11
- package/dist/wkt/twkb/twkb-types.d.ts.map +0 -1
- package/dist/wkt/twkb/twkb-types.js +0 -15
- package/dist/wkt/twkb/twkb-types.js.map +0 -1
- package/src/scan/arrow-execution/portable-predicate-compatibility.ts +0 -27
- package/src/scan/arrow-execution/project-arrow-table.ts +0 -53
- package/src/scan/query-arrow-table-math.ts +0 -23
- package/src/wkt/twkb/convert-geometry-to-twkb.ts +0 -317
- package/src/wkt/twkb/convert-twkb-to-geometry.ts +0 -373
- package/src/wkt/twkb/twkb-io.ts +0 -85
- package/src/wkt/twkb/twkb-types.ts +0 -14
package/src/scan/query.ts
CHANGED
|
@@ -269,15 +269,23 @@ async function* queryAppendBatches(
|
|
|
269
269
|
}
|
|
270
270
|
const sourceSchema = inMemory ? inMemory.schema : convertSchemaToArrow(metadata!.schema);
|
|
271
271
|
const names = sourceSchema.fields.map(field => field.name);
|
|
272
|
-
const {select, where, ...controls} = logicalQuery;
|
|
272
|
+
const {select: requestedSelect, where, ...controls} = logicalQuery;
|
|
273
273
|
const computedProjection =
|
|
274
|
-
Array.isArray(
|
|
275
|
-
|
|
274
|
+
Array.isArray(requestedSelect) &&
|
|
275
|
+
requestedSelect.some(
|
|
276
276
|
selection =>
|
|
277
277
|
selection &&
|
|
278
278
|
typeof selection === 'object' &&
|
|
279
279
|
('expression' in selection || 'array' in selection)
|
|
280
280
|
);
|
|
281
|
+
// Resolve the public scan aliases before planning either native or residual projection.
|
|
282
|
+
const select = computedProjection
|
|
283
|
+
? requestedSelect.map((item, index) =>
|
|
284
|
+
item && typeof item === 'object' && ('expression' in item || 'array' in item)
|
|
285
|
+
? {...item, as: item.as ?? `column${index + 1}`}
|
|
286
|
+
: item
|
|
287
|
+
)
|
|
288
|
+
: requestedSelect;
|
|
281
289
|
const expressionFilter =
|
|
282
290
|
where && typeof where === 'object' && 'expression' in where ? where : undefined;
|
|
283
291
|
const portablePredicate = expressionFilter ? undefined : (where as TableQuery['where']);
|
|
@@ -355,12 +363,10 @@ async function* queryAppendBatches(
|
|
|
355
363
|
if (compiledFilter && !arrow.DataType.isBool(compiledFilter.outputField.type))
|
|
356
364
|
throw new Error('SQL WHERE expression must return Boolean.');
|
|
357
365
|
const project = computedProjection
|
|
358
|
-
? expressionTools!.
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
options.functions
|
|
363
|
-
)
|
|
366
|
+
? expressionTools!.prepareArrowProjection(inputSchema, select!, {
|
|
367
|
+
signal: options.signal,
|
|
368
|
+
functions: options.functions
|
|
369
|
+
}).projectTable
|
|
364
370
|
: (data: arrow.Table) => projectArrowTable(data, normalized.select);
|
|
365
371
|
const empty = project(new arrow.Table(inputSchema));
|
|
366
372
|
const comparisonSchema = convertSchemaToArrow(convertArrowToSchema(empty.schema));
|
|
@@ -371,7 +377,7 @@ async function* queryAppendBatches(
|
|
|
371
377
|
(source as TableScanSource).planQueryPushdown
|
|
372
378
|
? await (await import('./query-pushdown')).planQueryPushdown(
|
|
373
379
|
source as TableScanSource,
|
|
374
|
-
logicalQuery,
|
|
380
|
+
{...logicalQuery, select},
|
|
375
381
|
capabilities,
|
|
376
382
|
comparisonSchema,
|
|
377
383
|
Boolean(computedProjection || expressionFilter),
|
package/src/scan/scan-engine.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {Table} from 'apache-arrow';
|
|
6
|
-
import {explainArrowTableQuery,
|
|
6
|
+
import {explainArrowTableQuery, type ArrowQueryOptions} from './plan-arrow-table-query';
|
|
7
7
|
import {type SQLPredicate} from './sql-predicate-types';
|
|
8
8
|
import type {TableQueryExplain} from '@loaders.gl/core/loader-utils';
|
|
9
9
|
|
|
@@ -39,24 +39,17 @@ export type ScanEngine = ScanBackend & {
|
|
|
39
39
|
|
|
40
40
|
const scanBackends = new Map<ScanBackendName, ScanBackend | ScanBackendLoader>();
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
query: queryArrowTable,
|
|
45
|
-
queryAsync: (sourceTable, options) =>
|
|
46
|
-
Promise.resolve().then(() => queryArrowTable(sourceTable, options)),
|
|
47
|
-
explain: explainArrowTableQuery
|
|
42
|
+
scanBackends.set('arrow', async () => {
|
|
43
|
+
const {queryArrowTable} = await import('./query-arrow-table');
|
|
44
|
+
return {name: 'arrow', query: queryArrowTable, explain: explainArrowTableQuery};
|
|
48
45
|
});
|
|
49
46
|
|
|
50
|
-
// Store the built-in backend directly. Apart from avoiding needless indirection, this keeps
|
|
51
|
-
// coverage stable when browser shards transform this shared module independently.
|
|
52
|
-
scanBackends.set('arrow', arrowScanBackend);
|
|
53
|
-
|
|
54
47
|
/**
|
|
55
48
|
* Registers a lazy scan backend without adding it to the default bundle.
|
|
56
49
|
*
|
|
57
50
|
* This is the extension point for future DuckDB and GPU implementations. The backend package can
|
|
58
51
|
* register a dynamic loader from application code while the public import remains
|
|
59
|
-
* `@loaders.gl/core/
|
|
52
|
+
* `@loaders.gl/core/query`.
|
|
60
53
|
*/
|
|
61
54
|
export function registerScanBackend(name: ScanBackendName, loader: ScanBackendLoader): void {
|
|
62
55
|
if (!name || !loader) {
|
|
@@ -3,13 +3,10 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
type SQLPredicate
|
|
8
|
-
|
|
9
|
-
} from './sql-predicate-types';
|
|
10
|
-
|
|
11
|
-
const MAXIMUM_PREDICATE_DEPTH = 64;
|
|
12
|
-
const MAXIMUM_PREDICATE_NODES = 4096;
|
|
6
|
+
validateSQLPredicate as validateMathSQLPredicate,
|
|
7
|
+
type SQLPredicate as MathSQLPredicate
|
|
8
|
+
} from '@math.gl/sql/parser';
|
|
9
|
+
import type {SQLPredicate} from './sql-predicate-types';
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
* JSON Schema for the JSON-serializable portion of the loaders.gl SQL predicate AST.
|
|
@@ -127,125 +124,17 @@ export function isSQLPredicate(value: unknown): value is SQLPredicate {
|
|
|
127
124
|
|
|
128
125
|
/** Validates an unknown portable SQL predicate or throws a path-specific error. */
|
|
129
126
|
export function validateSQLPredicate(value: unknown): asserts value is SQLPredicate {
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
validateMathSQLPredicate(value);
|
|
128
|
+
rejectPredicateCasts(value, '$');
|
|
132
129
|
}
|
|
133
130
|
|
|
134
|
-
/**
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
throw new Error(`SQL predicate ${path} exceeds the maximum nesting depth`);
|
|
143
|
-
}
|
|
144
|
-
state.nodes++;
|
|
145
|
-
if (state.nodes > MAXIMUM_PREDICATE_NODES) {
|
|
146
|
-
throw new Error('SQL predicate exceeds the maximum node count');
|
|
147
|
-
}
|
|
148
|
-
if (!isRecord(value) || !hasExactKeys(value, ['op', 'args'])) {
|
|
149
|
-
throw new Error(`SQL predicate ${path} must contain only op and args`);
|
|
150
|
-
}
|
|
151
|
-
if (typeof value.op !== 'string' || !Array.isArray(value.args)) {
|
|
152
|
-
throw new Error(`SQL predicate ${path} requires string op and array args`);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
switch (value.op) {
|
|
156
|
-
case 'and':
|
|
157
|
-
case 'or':
|
|
158
|
-
if (value.args.length < 2) {
|
|
159
|
-
throw new Error(`SQL predicate ${path}.${value.op} requires at least two arguments`);
|
|
160
|
-
}
|
|
161
|
-
for (let index = 0; index < value.args.length; index++) {
|
|
162
|
-
validatePredicateNode(value.args[index], `${path}.args[${index}]`, depth + 1, state);
|
|
163
|
-
}
|
|
164
|
-
return;
|
|
165
|
-
case 'not':
|
|
166
|
-
if (value.args.length !== 1) {
|
|
167
|
-
throw new Error(`SQL predicate ${path}.not requires exactly one argument`);
|
|
168
|
-
}
|
|
169
|
-
validatePredicateNode(value.args[0], `${path}.args[0]`, depth + 1, state);
|
|
170
|
-
return;
|
|
171
|
-
case 'isNull':
|
|
172
|
-
if (value.args.length !== 1) {
|
|
173
|
-
throw new Error(`SQL predicate ${path}.isNull requires exactly one argument`);
|
|
174
|
-
}
|
|
175
|
-
validatePredicateProperty(value.args[0], `${path}.args[0]`);
|
|
176
|
-
return;
|
|
177
|
-
case 'in':
|
|
178
|
-
if (value.args.length !== 2 || !Array.isArray(value.args[1]) || value.args[1].length === 0) {
|
|
179
|
-
throw new Error(`SQL predicate ${path}.in requires a property and non-empty value list`);
|
|
180
|
-
}
|
|
181
|
-
validatePredicateProperty(value.args[0], `${path}.args[0]`);
|
|
182
|
-
value.args[1].forEach((item, index) =>
|
|
183
|
-
validatePredicateValue(item, `${path}.args[1][${index}]`)
|
|
184
|
-
);
|
|
185
|
-
return;
|
|
186
|
-
case '=':
|
|
187
|
-
case '<>':
|
|
188
|
-
case '<':
|
|
189
|
-
case '<=':
|
|
190
|
-
case '>':
|
|
191
|
-
case '>=':
|
|
192
|
-
if (value.args.length !== 2) {
|
|
193
|
-
throw new Error(`SQL predicate ${path}.${value.op} requires exactly two arguments`);
|
|
194
|
-
}
|
|
195
|
-
validatePredicateProperty(value.args[0], `${path}.args[0]`);
|
|
196
|
-
validatePredicateValue(value.args[1], `${path}.args[1]`);
|
|
197
|
-
return;
|
|
198
|
-
default:
|
|
199
|
-
throw new Error(`SQL predicate ${path} has unsupported operator ${JSON.stringify(value.op)}`);
|
|
131
|
+
/** Rejects casts after math.gl has validated the structure and bounded its depth. */
|
|
132
|
+
function rejectPredicateCasts(predicate: MathSQLPredicate, path: string): void {
|
|
133
|
+
if (predicate.op === 'and' || predicate.op === 'or' || predicate.op === 'not') {
|
|
134
|
+
predicate.args.forEach((child, index) =>
|
|
135
|
+
rejectPredicateCasts(child, path + '.args[' + index + ']')
|
|
136
|
+
);
|
|
137
|
+
} else if (Object.hasOwn(predicate.args[0], 'casts')) {
|
|
138
|
+
throw new Error('SQL predicate ' + path + '.args[0] requires a non-empty property reference');
|
|
200
139
|
}
|
|
201
140
|
}
|
|
202
|
-
|
|
203
|
-
/** Validates one property reference. */
|
|
204
|
-
function validatePredicateProperty(value: unknown, path: string): void {
|
|
205
|
-
if (
|
|
206
|
-
!isRecord(value) ||
|
|
207
|
-
!hasAllowedKeys(value, ['property', 'quoted']) ||
|
|
208
|
-
typeof value.property !== 'string' ||
|
|
209
|
-
value.property.length === 0 ||
|
|
210
|
-
(value.quoted !== undefined && typeof value.quoted !== 'boolean')
|
|
211
|
-
) {
|
|
212
|
-
throw new Error(`SQL predicate ${path} requires a non-empty property reference`);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/** Validates one structured-cloneable predicate scalar. */
|
|
217
|
-
function validatePredicateValue(value: unknown, path: string): asserts value is SQLPredicateValue {
|
|
218
|
-
if (isSQLPredicateParameter(value)) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
if (
|
|
222
|
-
typeof value === 'boolean' ||
|
|
223
|
-
typeof value === 'bigint' ||
|
|
224
|
-
typeof value === 'string' ||
|
|
225
|
-
value instanceof Uint8Array
|
|
226
|
-
) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (value instanceof Date && Number.isFinite(value.getTime())) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
throw new Error(`SQL predicate ${path} contains an unsupported scalar value`);
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
/** Returns whether an unknown value is a non-null object. */
|
|
239
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
240
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/** Returns whether an object contains exactly the expected enumerable keys. */
|
|
244
|
-
function hasExactKeys(value: Record<string, unknown>, expectedKeys: readonly string[]): boolean {
|
|
245
|
-
const keys = Object.keys(value);
|
|
246
|
-
return keys.length === expectedKeys.length && expectedKeys.every(key => keys.includes(key));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function hasAllowedKeys(value: Record<string, unknown>, allowedKeys: readonly string[]): boolean {
|
|
250
|
-
return Object.keys(value).every(key => allowedKeys.includes(key));
|
|
251
|
-
}
|
|
@@ -24,7 +24,7 @@ const SQLPredicatePropertySchema = z
|
|
|
24
24
|
/**
|
|
25
25
|
* Optional Zod schema for validating the portable loaders.gl SQL predicate AST.
|
|
26
26
|
*
|
|
27
|
-
* Import from `@loaders.gl/core/
|
|
27
|
+
* Import from `@loaders.gl/core/query/sql-predicate-zod`; the package root does not load Zod.
|
|
28
28
|
*/
|
|
29
29
|
export const SQLPredicateSchema: z.ZodType<SQLPredicate> = z.lazy(() =>
|
|
30
30
|
z.union([
|
|
@@ -18,7 +18,7 @@ import type {
|
|
|
18
18
|
} from '@loaders.gl/core/loader-utils';
|
|
19
19
|
import {createScanQueryMetadata} from '@loaders.gl/core/loader-utils';
|
|
20
20
|
import {ARROW_TABLE_QUERY_CAPABILITIES} from './table-query-capabilities';
|
|
21
|
-
import {explainArrowTableQuery,
|
|
21
|
+
import {explainArrowTableQuery, type ArrowQueryOptions} from './plan-arrow-table-query';
|
|
22
22
|
import {type SQLPredicate} from './sql-predicate-types';
|
|
23
23
|
|
|
24
24
|
/** Shared display and provenance options for an addressed vector-table scan. */
|
|
@@ -106,6 +106,7 @@ export abstract class AddressedVectorTableScanSource {
|
|
|
106
106
|
/** Applies the portable Arrow query to the addressed feature table. */
|
|
107
107
|
async query(options: ArrowQueryOptions = {}): Promise<Table> {
|
|
108
108
|
const table = await this.getTable(options.signal);
|
|
109
|
+
const {queryArrowTable} = await import('./query-arrow-table');
|
|
109
110
|
return queryArrowTable(table, options);
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -3,57 +3,9 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import
|
|
7
|
-
import {serializeArrowSchema, deserializeArrowSchema} from '../schema/convert-arrow-schema';
|
|
6
|
+
import {mergeArrowSchemas, snapshotArrowSchema} from '@math.gl/core/arrow';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
export function snapshotArrowSchema(schema: arrow.Schema): arrow.Schema {
|
|
11
|
-
return deserializeArrowSchema(serializeArrowSchema(schema));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** Merges compatible schema snapshots, with later metadata values taking precedence. */
|
|
15
|
-
export function mergeArrowSchemas(
|
|
16
|
-
previous: arrow.Schema | undefined,
|
|
17
|
-
next: arrow.Schema
|
|
18
|
-
): arrow.Schema {
|
|
19
|
-
if (!previous) return snapshotArrowSchema(next);
|
|
20
|
-
// Arrow validates names, order, nullability and types, but intentionally ignores metadata.
|
|
21
|
-
new arrow.Table(previous, [new arrow.RecordBatch(next, undefined)]);
|
|
22
|
-
const earlier = serializeArrowSchema(previous);
|
|
23
|
-
const later = serializeArrowSchema(next);
|
|
24
|
-
return deserializeArrowSchema({
|
|
25
|
-
...later,
|
|
26
|
-
fields: later.fields.map((field, index) => mergeFieldMetadata(earlier.fields[index], field)),
|
|
27
|
-
metadata: {...earlier.metadata, ...later.metadata}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** Merges metadata recursively without changing a field's structural definition. */
|
|
32
|
-
function mergeFieldMetadata(previous: Field, next: Field): Field {
|
|
33
|
-
return {
|
|
34
|
-
...next,
|
|
35
|
-
type: mergeTypeMetadata(previous.type, next.type),
|
|
36
|
-
metadata: {...previous.metadata, ...next.metadata}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** Preserves nested field metadata, including fields inside dictionary values. */
|
|
41
|
-
function mergeTypeMetadata(previous: DataType, next: DataType): DataType {
|
|
42
|
-
if (typeof previous !== 'object' || typeof next !== 'object') return next;
|
|
43
|
-
if ('children' in previous && 'children' in next) {
|
|
44
|
-
const previousChildren = previous.children;
|
|
45
|
-
return {
|
|
46
|
-
...next,
|
|
47
|
-
children: next.children.map((field, index) =>
|
|
48
|
-
mergeFieldMetadata(previousChildren[index], field)
|
|
49
|
-
)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (previous.type === 'dictionary' && next.type === 'dictionary') {
|
|
53
|
-
return {...next, dictionary: mergeTypeMetadata(previous.dictionary, next.dictionary)};
|
|
54
|
-
}
|
|
55
|
-
return next;
|
|
56
|
-
}
|
|
8
|
+
export {mergeArrowSchemas, snapshotArrowSchema};
|
|
57
9
|
|
|
58
10
|
/** Snapshots a batch's schema and metadata while retaining its data buffers and row count. */
|
|
59
11
|
function snapshotArrowBatch(batch: arrow.RecordBatch, schema: arrow.Schema): arrow.RecordBatch {
|
package/src/wkt/twkb/index.ts
CHANGED
|
@@ -2,5 +2,66 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import {parseTWKB, writeTWKB, type WellKnownDimension} from '@math.gl/core/twkb';
|
|
6
|
+
import {ensureArrayBuffer} from '../../loader-utils/lib/binary-utils/memory-conversion-utils';
|
|
7
|
+
import type {Geometry} from '@loaders.gl/core/schema';
|
|
8
|
+
|
|
9
|
+
/** Checks the TWKB family nibble in a potential binary payload. */
|
|
10
|
+
export function isTWKB(input: ArrayBufferLike): boolean {
|
|
11
|
+
if (input.byteLength < 2) return false;
|
|
12
|
+
const type = new Uint8Array(input, 0, 1)[0] & 15;
|
|
13
|
+
return type >= 1 && type <= 7;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Decodes a TWKB payload as GeoJSON geometry. */
|
|
17
|
+
export function convertTWKBToGeometry(input: ArrayBuffer): Geometry {
|
|
18
|
+
return parseTWKB(input).geometry as Geometry;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Encodes a geometry using the loader's explicit Z and M options. */
|
|
22
|
+
export function convertGeometryToTWKB(
|
|
23
|
+
geometry: Geometry,
|
|
24
|
+
options?: {hasZ?: boolean; hasM?: boolean}
|
|
25
|
+
): ArrayBuffer {
|
|
26
|
+
const dimension: WellKnownDimension = options?.hasZ
|
|
27
|
+
? options.hasM
|
|
28
|
+
? 'xyzm'
|
|
29
|
+
: 'xyz'
|
|
30
|
+
: options?.hasM
|
|
31
|
+
? 'xym'
|
|
32
|
+
: 'xy';
|
|
33
|
+
return ensureArrayBuffer(writeTWKB(normalizeGeometry(geometry, dimension), {dimension}));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Adapts legacy coordinate tuples to the selected TWKB dimension. */
|
|
37
|
+
function normalizeGeometry(geometry: Geometry, dimension: WellKnownDimension): Geometry {
|
|
38
|
+
if (geometry.type === 'GeometryCollection') {
|
|
39
|
+
return {
|
|
40
|
+
...geometry,
|
|
41
|
+
geometries: geometry.geometries.map(child => normalizeGeometry(child, dimension))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
if (!Array.isArray(geometry.coordinates)) throw new Error('unsupported geometry type');
|
|
45
|
+
return {
|
|
46
|
+
...geometry,
|
|
47
|
+
coordinates: normalizeCoordinates(geometry.coordinates, dimension)
|
|
48
|
+
} as Geometry;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Visits nested coordinates, retaining the legacy fourth-slot measure when present. */
|
|
52
|
+
function normalizeCoordinates(
|
|
53
|
+
coordinates: readonly unknown[],
|
|
54
|
+
dimension: WellKnownDimension
|
|
55
|
+
): readonly unknown[] {
|
|
56
|
+
if (!coordinates.length) return coordinates;
|
|
57
|
+
if (typeof coordinates[0] !== 'number') {
|
|
58
|
+
const children = coordinates.map(child =>
|
|
59
|
+
normalizeCoordinates(child as readonly unknown[], dimension)
|
|
60
|
+
);
|
|
61
|
+
return children.every(child => child.length === 0) ? [] : children;
|
|
62
|
+
}
|
|
63
|
+
return Array.from(
|
|
64
|
+
dimension,
|
|
65
|
+
(axis, index) => coordinates[axis === 'm' && coordinates.length === 4 ? 3 : index] ?? 0
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -50,7 +50,10 @@ export function canProcessOnWorkerInBatches(
|
|
|
50
50
|
return Boolean(worker.workerInBatches && !getConfiguredWorkerURL(worker, options));
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Runs one loader request and closes its task handle. A pending input lets the
|
|
55
|
+
* task initialize while the caller reads the data.
|
|
56
|
+
*/
|
|
54
57
|
export async function processOnWorker(
|
|
55
58
|
worker: WorkerObject,
|
|
56
59
|
data: any,
|
|
@@ -58,18 +61,47 @@ export async function processOnWorker(
|
|
|
58
61
|
context: CallerThreadContext = {},
|
|
59
62
|
jobContext: WorkerJobContext = {}
|
|
60
63
|
): Promise<any> {
|
|
61
|
-
const
|
|
64
|
+
const controller = new AbortController();
|
|
65
|
+
const signal = options.signal
|
|
66
|
+
? AbortSignal.any([options.signal, controller.signal])
|
|
67
|
+
: controller.signal;
|
|
68
|
+
const sessionPromise = openSession(worker, {...options, signal}, context, jobContext);
|
|
69
|
+
// Observe startup failure immediately, but keep input errors first as in serial parsing.
|
|
70
|
+
void sessionPromise.catch(() => {});
|
|
62
71
|
try {
|
|
72
|
+
const input = data instanceof Promise ? await waitForInput(data, signal) : data;
|
|
73
|
+
const session = await sessionPromise;
|
|
63
74
|
const result = await session.handle.runTask(
|
|
64
|
-
{value:
|
|
75
|
+
{value: input},
|
|
65
76
|
{
|
|
66
77
|
...getControls(options),
|
|
67
78
|
options: getParserOptions(options)
|
|
68
79
|
}
|
|
69
80
|
);
|
|
70
81
|
return result.value;
|
|
82
|
+
} catch (error) {
|
|
83
|
+
controller.abort(error);
|
|
84
|
+
throw error;
|
|
85
|
+
} finally {
|
|
86
|
+
const session = await sessionPromise.catch(() => undefined);
|
|
87
|
+
await session?.close();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Releases the task on cancellation even when the input producer ignores the signal. */
|
|
92
|
+
async function waitForInput<T>(input: Promise<T>, signal: AbortSignal): Promise<T> {
|
|
93
|
+
let onAbort: () => void;
|
|
94
|
+
try {
|
|
95
|
+
const aborted = new Promise<never>((_resolve, reject) => {
|
|
96
|
+
onAbort = () => reject(signal.reason);
|
|
97
|
+
signal.addEventListener('abort', onAbort, {once: true});
|
|
98
|
+
if (signal.aborted) {
|
|
99
|
+
onAbort();
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
return await Promise.race([input, aborted]);
|
|
71
103
|
} finally {
|
|
72
|
-
|
|
104
|
+
signal.removeEventListener('abort', onAbort!);
|
|
73
105
|
}
|
|
74
106
|
}
|
|
75
107
|
|
|
@@ -131,12 +163,13 @@ function getTask(worker: WorkerObject, options: WorkerOptions): WorkerTask {
|
|
|
131
163
|
'Inline legacy worker source is unsupported; use a TaskRunner worker URL or factory'
|
|
132
164
|
);
|
|
133
165
|
const create = !getCustomWorkerURL(worker, options) && isBrowser ? worker.loadWorker : undefined;
|
|
134
|
-
const url = getWorkerURL(worker, options);
|
|
135
166
|
return {
|
|
136
167
|
id: `${worker.module}:${worker.id}`,
|
|
137
168
|
initialize: state => state,
|
|
138
169
|
worker: {
|
|
139
|
-
...(create
|
|
170
|
+
...(create
|
|
171
|
+
? {create: () => create() ?? createModuleWorker(getWorkerURL(worker, options))}
|
|
172
|
+
: {url: getWorkerURL(worker, options)}),
|
|
140
173
|
capabilities: {atomic: true, streaming: true}
|
|
141
174
|
}
|
|
142
175
|
};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/scan/arrow-execution/portable-predicate-compatibility.ts
|
|
21
|
-
var portable_predicate_compatibility_exports = {};
|
|
22
|
-
__export(portable_predicate_compatibility_exports, {
|
|
23
|
-
needsPortablePredicateCompatibility: () => needsPortablePredicateCompatibility
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(portable_predicate_compatibility_exports);
|
|
26
|
-
var import_apache_arrow = require("apache-arrow");
|
|
27
|
-
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
28
|
-
function needsPortablePredicateCompatibility(schema, predicate) {
|
|
29
|
-
return (0, import_loader_utils.getColumnarPredicatePaths)(predicate).some((path) => {
|
|
30
|
-
if (path.length > 1) return true;
|
|
31
|
-
let type = schema.fields.find((field) => field.name === path[0])?.type;
|
|
32
|
-
while (type && import_apache_arrow.DataType.isDictionary(type)) type = type.dictionary;
|
|
33
|
-
if (!type) return false;
|
|
34
|
-
return !(import_apache_arrow.DataType.isInt(type) || import_apache_arrow.DataType.isFloat(type) && type.precision !== import_apache_arrow.Precision.HALF || import_apache_arrow.DataType.isBool(type) || import_apache_arrow.DataType.isUtf8(type) || import_apache_arrow.DataType.isBinary(type));
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
needsPortablePredicateCompatibility
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=portable-predicate-compatibility.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/scan/arrow-execution/portable-predicate-compatibility.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport {DataType, Precision, type Schema} from 'apache-arrow';\nimport {getColumnarPredicatePaths} from '@loaders.gl/core/loader-utils';\nimport type {SQLPredicate} from '../sql-predicate-types';\n\n/** Retains portable evaluation when RC.2 does not support the path, storage type or literal units. */\nexport function needsPortablePredicateCompatibility(\n schema: Schema,\n predicate: SQLPredicate\n): boolean {\n return getColumnarPredicatePaths(predicate).some(path => {\n if (path.length > 1) return true;\n let type = schema.fields.find(field => field.name === path[0])?.type;\n while (type && DataType.isDictionary(type)) type = type.dictionary;\n if (!type) return false; // The upstream binder reports a missing top-level column.\n return !(\n DataType.isInt(type) ||\n (DataType.isFloat(type) && type.precision !== Precision.HALF) ||\n DataType.isBool(type) ||\n DataType.isUtf8(type) ||\n DataType.isBinary(type)\n );\n });\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,0BAA+C;AAC/C,0BAAwC;AAIjC,SAAS,oCACd,QACA,WACS;AACT,aAAO,+CAA0B,SAAS,EAAE,KAAK,UAAQ;AACvD,QAAI,KAAK,SAAS,EAAG,QAAO;AAC5B,QAAI,OAAO,OAAO,OAAO,KAAK,WAAS,MAAM,SAAS,KAAK,CAAC,CAAC,GAAG;AAChE,WAAO,QAAQ,6BAAS,aAAa,IAAI,EAAG,QAAO,KAAK;AACxD,QAAI,CAAC,KAAM,QAAO;AAClB,WAAO,EACL,6BAAS,MAAM,IAAI,KAClB,6BAAS,QAAQ,IAAI,KAAK,KAAK,cAAc,8BAAU,QACxD,6BAAS,OAAO,IAAI,KACpB,6BAAS,OAAO,IAAI,KACpB,6BAAS,SAAS,IAAI;AAAA,EAE1B,CAAC;AACH;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { type Schema } from 'apache-arrow';
|
|
2
|
-
import type { SQLPredicate } from "../sql-predicate-types.js";
|
|
3
|
-
/** Retains portable evaluation when RC.2 does not support the path, storage type or literal units. */
|
|
4
|
-
export declare function needsPortablePredicateCompatibility(schema: Schema, predicate: SQLPredicate): boolean;
|
|
5
|
-
//# sourceMappingURL=portable-predicate-compatibility.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portable-predicate-compatibility.d.ts","sourceRoot":"","sources":["../../../src/scan/arrow-execution/portable-predicate-compatibility.ts"],"names":[],"mappings":"AAIA,OAAO,EAAsB,KAAK,MAAM,EAAC,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAC,YAAY,EAAC,kCAA+B;AAEzD,sGAAsG;AACtG,wBAAgB,mCAAmC,CACjD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,YAAY,GACtB,OAAO,CAcT"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { DataType, Precision } from 'apache-arrow';
|
|
5
|
-
import { getColumnarPredicatePaths } from '@loaders.gl/core/loader-utils';
|
|
6
|
-
/** Retains portable evaluation when RC.2 does not support the path, storage type or literal units. */
|
|
7
|
-
export function needsPortablePredicateCompatibility(schema, predicate) {
|
|
8
|
-
return getColumnarPredicatePaths(predicate).some(path => {
|
|
9
|
-
if (path.length > 1)
|
|
10
|
-
return true;
|
|
11
|
-
let type = schema.fields.find(field => field.name === path[0])?.type;
|
|
12
|
-
while (type && DataType.isDictionary(type))
|
|
13
|
-
type = type.dictionary;
|
|
14
|
-
if (!type)
|
|
15
|
-
return false; // The upstream binder reports a missing top-level column.
|
|
16
|
-
return !(DataType.isInt(type) ||
|
|
17
|
-
(DataType.isFloat(type) && type.precision !== Precision.HALF) ||
|
|
18
|
-
DataType.isBool(type) ||
|
|
19
|
-
DataType.isUtf8(type) ||
|
|
20
|
-
DataType.isBinary(type));
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=portable-predicate-compatibility.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"portable-predicate-compatibility.js","sourceRoot":"","sources":["../../../src/scan/arrow-execution/portable-predicate-compatibility.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,EAAC,QAAQ,EAAE,SAAS,EAAc,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAC,yBAAyB,EAAC,MAAM,+BAA+B,CAAC;AAGxE,sGAAsG;AACtG,MAAM,UAAU,mCAAmC,CACjD,MAAc,EACd,SAAuB;IAEvB,OAAO,yBAAyB,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACtD,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,IAAI,CAAC;QACjC,IAAI,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;QACrE,OAAO,IAAI,IAAI,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC;YAAE,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC;QACnE,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC,CAAC,0DAA0D;QACnF,OAAO,CAAC,CACN,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;YACpB,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC,IAAI,CAAC;YAC7D,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;YACrB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;YACrB,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CACxB,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/scan/arrow-execution/project-arrow-table.ts
|
|
31
|
-
var project_arrow_table_exports = {};
|
|
32
|
-
__export(project_arrow_table_exports, {
|
|
33
|
-
projectArrowTable: () => projectArrowTable
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(project_arrow_table_exports);
|
|
36
|
-
var arrow = __toESM(require("apache-arrow"), 1);
|
|
37
|
-
function projectArrowTable(source, selections) {
|
|
38
|
-
const outputNames = /* @__PURE__ */ new Set();
|
|
39
|
-
const indices = [];
|
|
40
|
-
const fields = selections.map((selection) => {
|
|
41
|
-
const column = typeof selection === "string" ? selection : selection.column;
|
|
42
|
-
const name = typeof selection === "string" ? selection : selection.as === void 0 ? column : selection.as;
|
|
43
|
-
const index = source.schema.fields.findIndex((field) => field.name === column);
|
|
44
|
-
if (index < 0) throw new Error(`Arrow projection column not found: ${column}`);
|
|
45
|
-
if (typeof name !== "string" || typeof selection !== "string" && selection.as !== void 0 && !name.length || outputNames.has(name)) {
|
|
46
|
-
throw new Error(`Invalid or duplicate Arrow projection output name: ${name}`);
|
|
47
|
-
}
|
|
48
|
-
outputNames.add(name);
|
|
49
|
-
indices.push(index);
|
|
50
|
-
return source.schema.fields[index].clone({ name });
|
|
51
|
-
});
|
|
52
|
-
const schema = new arrow.Schema(fields, source.schema.metadata);
|
|
53
|
-
const batches = source.batches.map(
|
|
54
|
-
(batch) => new arrow.RecordBatch(
|
|
55
|
-
schema,
|
|
56
|
-
arrow.makeData({
|
|
57
|
-
type: new arrow.Struct(fields),
|
|
58
|
-
length: batch.numRows,
|
|
59
|
-
children: indices.map((index) => batch.data.children[index])
|
|
60
|
-
}),
|
|
61
|
-
batch.metadata
|
|
62
|
-
)
|
|
63
|
-
);
|
|
64
|
-
return new arrow.Table(schema, batches);
|
|
65
|
-
}
|
|
66
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
-
0 && (module.exports = {
|
|
68
|
-
projectArrowTable
|
|
69
|
-
});
|
|
70
|
-
//# sourceMappingURL=project-arrow-table.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/scan/arrow-execution/project-arrow-table.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport * as arrow from 'apache-arrow';\nimport type {TableSelection} from '@loaders.gl/core/loader-utils';\n\n/**\n * Projects and renames Arrow fields without copying column data buffers.\n * New schema and batch wrappers preserve source row order, batch boundaries, and metadata.\n */\nexport function projectArrowTable(\n source: arrow.Table,\n selections: readonly TableSelection[]\n): arrow.Table {\n const outputNames = new Set<string>();\n const indices: number[] = [];\n const fields = selections.map(selection => {\n const column = typeof selection === 'string' ? selection : selection.column;\n const name =\n typeof selection === 'string'\n ? selection\n : selection.as === undefined\n ? column\n : selection.as;\n const index = source.schema.fields.findIndex(field => field.name === column);\n if (index < 0) throw new Error(`Arrow projection column not found: ${column}`);\n if (\n typeof name !== 'string' ||\n (typeof selection !== 'string' && selection.as !== undefined && !name.length) ||\n outputNames.has(name)\n ) {\n throw new Error(`Invalid or duplicate Arrow projection output name: ${name}`);\n }\n outputNames.add(name);\n indices.push(index);\n return source.schema.fields[index].clone({name});\n });\n const schema = new arrow.Schema(fields, source.schema.metadata);\n const batches = source.batches.map(\n batch =>\n new arrow.RecordBatch(\n schema,\n arrow.makeData({\n type: new arrow.Struct(fields),\n length: batch.numRows,\n children: indices.map(index => batch.data.children[index])\n }),\n batch.metadata\n )\n );\n return new arrow.Table(schema, batches);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,YAAuB;AAOhB,SAAS,kBACd,QACA,YACa;AACb,QAAM,cAAc,oBAAI,IAAY;AACpC,QAAM,UAAoB,CAAC;AAC3B,QAAM,SAAS,WAAW,IAAI,eAAa;AACzC,UAAM,SAAS,OAAO,cAAc,WAAW,YAAY,UAAU;AACrE,UAAM,OACJ,OAAO,cAAc,WACjB,YACA,UAAU,OAAO,SACf,SACA,UAAU;AAClB,UAAM,QAAQ,OAAO,OAAO,OAAO,UAAU,WAAS,MAAM,SAAS,MAAM;AAC3E,QAAI,QAAQ,EAAG,OAAM,IAAI,MAAM,sCAAsC,MAAM,EAAE;AAC7E,QACE,OAAO,SAAS,YACf,OAAO,cAAc,YAAY,UAAU,OAAO,UAAa,CAAC,KAAK,UACtE,YAAY,IAAI,IAAI,GACpB;AACA,YAAM,IAAI,MAAM,sDAAsD,IAAI,EAAE;AAAA,IAC9E;AACA,gBAAY,IAAI,IAAI;AACpB,YAAQ,KAAK,KAAK;AAClB,WAAO,OAAO,OAAO,OAAO,KAAK,EAAE,MAAM,EAAC,KAAI,CAAC;AAAA,EACjD,CAAC;AACD,QAAM,SAAS,IAAU,aAAO,QAAQ,OAAO,OAAO,QAAQ;AAC9D,QAAM,UAAU,OAAO,QAAQ;AAAA,IAC7B,WACE,IAAU;AAAA,MACR;AAAA,MACM,eAAS;AAAA,QACb,MAAM,IAAU,aAAO,MAAM;AAAA,QAC7B,QAAQ,MAAM;AAAA,QACd,UAAU,QAAQ,IAAI,WAAS,MAAM,KAAK,SAAS,KAAK,CAAC;AAAA,MAC3D,CAAC;AAAA,MACD,MAAM;AAAA,IACR;AAAA,EACJ;AACA,SAAO,IAAU,YAAM,QAAQ,OAAO;AACxC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|