@loaders.gl/core 5.0.0-rc.2 → 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/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/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 +124 -370
- 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 +2 -2
- package/dist/dist.min.js +2 -2
- package/dist/federated-table-scan-source.cjs +166 -564
- 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/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 +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/init.js.map +1 -1
- package/dist/loader-utils/index.cjs +31 -217
- 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/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.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 +1 -1
- package/dist/scan/scan-engine.d.ts.map +1 -1
- package/dist/scan/scan-engine.js +4 -9
- package/dist/scan/scan-engine.js.map +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 +854 -1314
- 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 +4 -4
- 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/package.json +7 -7
- package/src/arrow-geometry/geometry-codecs.ts +35 -78
- 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/geometry-converters/wkb/helpers/parse-wkb-header.ts +6 -30
- package/src/geoarrow/lib/kernels/decode-wkt-native.ts +23 -269
- 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/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.ts +16 -10
- package/src/scan/scan-engine.ts +4 -11
- 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/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,18 +39,11 @@ 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
|
*
|
|
@@ -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
|
+
}
|
|
@@ -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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as arrow from 'apache-arrow';
|
|
2
|
-
import type { TableSelection } from '@loaders.gl/core/loader-utils';
|
|
3
|
-
/**
|
|
4
|
-
* Projects and renames Arrow fields without copying column data buffers.
|
|
5
|
-
* New schema and batch wrappers preserve source row order, batch boundaries, and metadata.
|
|
6
|
-
*/
|
|
7
|
-
export declare function projectArrowTable(source: arrow.Table, selections: readonly TableSelection[]): arrow.Table;
|
|
8
|
-
//# sourceMappingURL=project-arrow-table.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-arrow-table.d.ts","sourceRoot":"","sources":["../../../src/scan/arrow-execution/project-arrow-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,+BAA+B,CAAC;AAElE;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,KAAK,CAAC,KAAK,EACnB,UAAU,EAAE,SAAS,cAAc,EAAE,GACpC,KAAK,CAAC,KAAK,CAsCb"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import * as arrow from 'apache-arrow';
|
|
5
|
-
/**
|
|
6
|
-
* Projects and renames Arrow fields without copying column data buffers.
|
|
7
|
-
* New schema and batch wrappers preserve source row order, batch boundaries, and metadata.
|
|
8
|
-
*/
|
|
9
|
-
export function projectArrowTable(source, selections) {
|
|
10
|
-
const outputNames = new Set();
|
|
11
|
-
const indices = [];
|
|
12
|
-
const fields = selections.map(selection => {
|
|
13
|
-
const column = typeof selection === 'string' ? selection : selection.column;
|
|
14
|
-
const name = typeof selection === 'string'
|
|
15
|
-
? selection
|
|
16
|
-
: selection.as === undefined
|
|
17
|
-
? column
|
|
18
|
-
: selection.as;
|
|
19
|
-
const index = source.schema.fields.findIndex(field => field.name === column);
|
|
20
|
-
if (index < 0)
|
|
21
|
-
throw new Error(`Arrow projection column not found: ${column}`);
|
|
22
|
-
if (typeof name !== 'string' ||
|
|
23
|
-
(typeof selection !== 'string' && selection.as !== undefined && !name.length) ||
|
|
24
|
-
outputNames.has(name)) {
|
|
25
|
-
throw new Error(`Invalid or duplicate Arrow projection output name: ${name}`);
|
|
26
|
-
}
|
|
27
|
-
outputNames.add(name);
|
|
28
|
-
indices.push(index);
|
|
29
|
-
return source.schema.fields[index].clone({ name });
|
|
30
|
-
});
|
|
31
|
-
const schema = new arrow.Schema(fields, source.schema.metadata);
|
|
32
|
-
const batches = source.batches.map(batch => new arrow.RecordBatch(schema, arrow.makeData({
|
|
33
|
-
type: new arrow.Struct(fields),
|
|
34
|
-
length: batch.numRows,
|
|
35
|
-
children: indices.map(index => batch.data.children[index])
|
|
36
|
-
}), batch.metadata));
|
|
37
|
-
return new arrow.Table(schema, batches);
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=project-arrow-table.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-arrow-table.js","sourceRoot":"","sources":["../../../src/scan/arrow-execution/project-arrow-table.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAC/B,MAAmB,EACnB,UAAqC;IAErC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QACxC,MAAM,MAAM,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC;QAC5E,MAAM,IAAI,GACR,OAAO,SAAS,KAAK,QAAQ;YAC3B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,CAAC,EAAE,KAAK,SAAS;gBAC1B,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC;QACrB,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;QAC7E,IAAI,KAAK,GAAG,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,sCAAsC,MAAM,EAAE,CAAC,CAAC;QAC/E,IACE,OAAO,IAAI,KAAK,QAAQ;YACxB,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;YAC7E,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EACrB,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,sDAAsD,IAAI,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,EAAC,IAAI,EAAC,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAChC,KAAK,CAAC,EAAE,CACN,IAAI,KAAK,CAAC,WAAW,CACnB,MAAM,EACN,KAAK,CAAC,QAAQ,CAAC;QACb,IAAI,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9B,MAAM,EAAE,KAAK,CAAC,OAAO;QACrB,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;KAC3D,CAAC,EACF,KAAK,CAAC,QAAQ,CACf,CACJ,CAAC;IACF,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -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/query-arrow-table-math.ts
|
|
21
|
-
var query_arrow_table_math_exports = {};
|
|
22
|
-
__export(query_arrow_table_math_exports, {
|
|
23
|
-
queryArrowTable: () => queryArrowTable
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(query_arrow_table_math_exports);
|
|
26
|
-
var import_portable_predicate_compatibility = require("./arrow-execution/portable-predicate-compatibility.cjs");
|
|
27
|
-
var import_query = require("@math.gl/sql/query");
|
|
28
|
-
var import_query_arrow_table = require("./query-arrow-table.cjs");
|
|
29
|
-
function queryArrowTable(source, options) {
|
|
30
|
-
const predicate = options?.predicate;
|
|
31
|
-
return (0, import_query_arrow_table.queryArrowTable)(
|
|
32
|
-
source,
|
|
33
|
-
options,
|
|
34
|
-
predicate && (0, import_portable_predicate_compatibility.needsPortablePredicateCompatibility)(source.schema, predicate) ? void 0 : import_query.queryArrowTable
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
queryArrowTable
|
|
40
|
-
});
|
|
41
|
-
//# sourceMappingURL=query-arrow-table-math.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/scan/query-arrow-table-math.ts"],
|
|
4
|
-
"sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {Table} from 'apache-arrow';\nimport {needsPortablePredicateCompatibility} from './arrow-execution/portable-predicate-compatibility';\nimport {queryArrowTable as executeArrowQuery} from '@math.gl/sql/query';\nimport {\n queryArrowTable as planAndQueryArrowTable,\n type ArrowQueryOptions\n} from './query-arrow-table';\n\n/** Executes a validated Arrow query with math.gl as the linear executor. */\nexport function queryArrowTable(source: Table, options?: ArrowQueryOptions): Table {\n const predicate = options?.predicate;\n return planAndQueryArrowTable(\n source,\n options,\n predicate && needsPortablePredicateCompatibility(source.schema, predicate)\n ? undefined\n : executeArrowQuery\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,8CAAkD;AAClD,mBAAmD;AACnD,+BAGO;AAGA,SAAS,gBAAgB,QAAe,SAAoC;AACjF,QAAM,YAAY,SAAS;AAC3B,aAAO,yBAAAA;AAAA,IACL;AAAA,IACA;AAAA,IACA,iBAAa,6EAAoC,OAAO,QAAQ,SAAS,IACrE,SACA,aAAAC;AAAA,EACN;AACF;",
|
|
6
|
-
"names": ["planAndQueryArrowTable", "executeArrowQuery"]
|
|
7
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Table } from 'apache-arrow';
|
|
2
|
-
import { type ArrowQueryOptions } from "./query-arrow-table.js";
|
|
3
|
-
/** Executes a validated Arrow query with math.gl as the linear executor. */
|
|
4
|
-
export declare function queryArrowTable(source: Table, options?: ArrowQueryOptions): Table;
|
|
5
|
-
//# sourceMappingURL=query-arrow-table-math.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-arrow-table-math.d.ts","sourceRoot":"","sources":["../../src/scan/query-arrow-table-math.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAGxC,OAAO,EAEL,KAAK,iBAAiB,EACvB,+BAA4B;AAE7B,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,KAAK,CASjF"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
import { needsPortablePredicateCompatibility } from "./arrow-execution/portable-predicate-compatibility.js";
|
|
5
|
-
import { queryArrowTable as executeArrowQuery } from '@math.gl/sql/query';
|
|
6
|
-
import { queryArrowTable as planAndQueryArrowTable } from "./query-arrow-table.js";
|
|
7
|
-
/** Executes a validated Arrow query with math.gl as the linear executor. */
|
|
8
|
-
export function queryArrowTable(source, options) {
|
|
9
|
-
const predicate = options?.predicate;
|
|
10
|
-
return planAndQueryArrowTable(source, options, predicate && needsPortablePredicateCompatibility(source.schema, predicate)
|
|
11
|
-
? undefined
|
|
12
|
-
: executeArrowQuery);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=query-arrow-table-math.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-arrow-table-math.js","sourceRoot":"","sources":["../../src/scan/query-arrow-table-math.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAGpC,OAAO,EAAC,mCAAmC,EAAC,8DAA2D;AACvG,OAAO,EAAC,eAAe,IAAI,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AACxE,OAAO,EACL,eAAe,IAAI,sBAAsB,EAE1C,+BAA4B;AAE7B,4EAA4E;AAC5E,MAAM,UAAU,eAAe,CAAC,MAAa,EAAE,OAA2B;IACxE,MAAM,SAAS,GAAG,OAAO,EAAE,SAAS,CAAC;IACrC,OAAO,sBAAsB,CAC3B,MAAM,EACN,OAAO,EACP,SAAS,IAAI,mCAAmC,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;QACxE,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,iBAAiB,CACtB,CAAC;AACJ,CAAC"}
|