@loaders.gl/core 5.0.0-beta.7 → 5.0.0-beta.8
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/geojson-table.cjs +26 -15
- package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
- package/dist/arrow-geometry/geojson-table.d.ts +8 -1
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +18 -9
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/cluster-source.cjs +78 -8
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/dist.dev.js +354 -319
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +177 -176
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
- 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.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +351 -281
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +14 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +14 -18
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +11 -64
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +14 -3
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +43 -40
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +11 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +52 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.js +2 -2
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +21 -10
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/index.cjs +143 -42
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +2 -2
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts +24 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +5 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +13 -5
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +5 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +27 -20
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +3 -3
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +15 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +102 -27
- 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/source-types.d.ts +5 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +5 -1
- package/dist/loader-utils/source-types.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/polyfills/index.cjs +3 -2
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +9 -9
- package/dist/scan/arrow-execution/expressions.cjs.map +3 -3
- package/dist/scan/arrow-execution/expressions.d.ts +3 -3
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -1
- package/dist/scan/arrow-execution/expressions.js +4 -4
- package/dist/scan/arrow-execution/expressions.js.map +1 -1
- package/dist/scan/index.cjs +21 -6
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +1 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +1 -1
- package/dist/scan/parse-sql-predicate.cjs.map +1 -1
- package/dist/scan/parse-sql-predicate.js +1 -1
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-progressive.cjs +191 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +174 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query.cjs +42 -8
- package/dist/scan/query.cjs.map +3 -3
- package/dist/scan/query.d.ts +26 -6
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +48 -7
- package/dist/scan/query.js.map +1 -1
- package/dist/schema-utils/index.cjs +262 -241
- package/dist/schema-utils/index.cjs.map +2 -2
- package/dist/schema-utils/index.d.ts +1 -0
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +1 -0
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +28 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +26 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +2 -1
- package/dist/vector-table-scan-source.cjs.map +1 -1
- package/dist/worker-utils/index.cjs +49 -9
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +2 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/package.json +8 -7
- package/src/arrow-geometry/geojson-table.ts +27 -17
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -1
- package/src/lib/api/create-data-source.ts +136 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +21 -20
- package/src/lib/api/load.ts +49 -121
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +49 -12
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +56 -53
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +70 -0
- package/src/lib/loader-utils/option-defaults.ts +2 -2
- package/src/lib/loader-utils/option-utils.ts +21 -10
- package/src/loader-utils/index.ts +2 -1
- package/src/loader-utils/lib/log-utils/log.ts +39 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +18 -8
- package/src/loader-utils/lib/scan-utils/table-query.ts +10 -1
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +36 -25
- package/src/loader-utils/lib/sources/data-source.ts +3 -3
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +16 -1
- package/src/loader-utils/loader-types.ts +168 -43
- package/src/loader-utils/source-types.ts +12 -6
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +5 -5
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +1 -1
- package/src/scan/query-progressive.ts +231 -0
- package/src/scan/query.ts +92 -10
- package/src/schema-utils/index.ts +5 -0
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +58 -0
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/worker-utils/lib/library-utils/library-utils.ts +2 -1
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
package/src/scan/index.ts
CHANGED
|
@@ -134,5 +134,11 @@ export {queryArrowTableInBatches} from './query-arrow-table-in-batches';
|
|
|
134
134
|
export {projectArrowTable, filterArrowTable} from './arrow-execution';
|
|
135
135
|
export type {ArrowFilterOptions} from './arrow-execution';
|
|
136
136
|
|
|
137
|
-
export {query, queryInBatches} from './query';
|
|
137
|
+
export {query, queryInBatches, queryProgressive} from './query';
|
|
138
|
+
export type {
|
|
139
|
+
ProgressiveAggregate,
|
|
140
|
+
ProgressiveAggregateQuery,
|
|
141
|
+
ProgressiveQueryOptions,
|
|
142
|
+
ProgressiveQuerySnapshot
|
|
143
|
+
} from './query-progressive';
|
|
138
144
|
export type {Query, QueryOptions, SQLQueryParser} from './query';
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {parseSQLPredicate as parseMathSQLPredicate} from '@math.gl/
|
|
5
|
+
import {parseSQLPredicate as parseMathSQLPredicate} from '@math.gl/expressions/sql';
|
|
6
6
|
import {validateSQLPredicate} from './sql-predicate-schema';
|
|
7
7
|
import type {
|
|
8
8
|
BoundSQLPredicate,
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import * as arrow from 'apache-arrow';
|
|
6
|
+
import type {ArrowTable} from '@loaders.gl/core/schema';
|
|
7
|
+
import {convertArrowToTable} from '@loaders.gl/core/schema-utils';
|
|
8
|
+
import type {TableQuery} from '@loaders.gl/core/loader-utils';
|
|
9
|
+
import {queryInBatches, type QueryOptions} from './query';
|
|
10
|
+
|
|
11
|
+
/** Supported incremental, bounded-state aggregate operations. */
|
|
12
|
+
export type ProgressiveAggregate = Readonly<{
|
|
13
|
+
function: 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
14
|
+
/** Optional only for COUNT(*); COUNT(column) ignores nulls. */
|
|
15
|
+
column?: string;
|
|
16
|
+
/** Result column name. */
|
|
17
|
+
as: string;
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Incremental aggregation over one table input.
|
|
22
|
+
*
|
|
23
|
+
* Pass GROUP BY as a structured request. Each snapshot replaces the previous result.
|
|
24
|
+
*/
|
|
25
|
+
export type ProgressiveAggregateQuery = Readonly<{
|
|
26
|
+
from?: TableQuery['from'];
|
|
27
|
+
where?: TableQuery['where'];
|
|
28
|
+
groupBy?: string;
|
|
29
|
+
aggregates: readonly ProgressiveAggregate[];
|
|
30
|
+
}>;
|
|
31
|
+
|
|
32
|
+
export type ProgressiveQueryOptions = QueryOptions &
|
|
33
|
+
Readonly<{
|
|
34
|
+
/** Emit a provisional complete table after this many nonempty input batches. Default: 1. */
|
|
35
|
+
emitEveryBatches?: number;
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
/** Each table is independent of later updates and replaces all previous snapshots. */
|
|
39
|
+
export type ProgressiveQuerySnapshot = Readonly<{
|
|
40
|
+
table: ArrowTable;
|
|
41
|
+
rowsProcessed: number;
|
|
42
|
+
final: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
|
|
45
|
+
type AggregateState = {
|
|
46
|
+
count: number;
|
|
47
|
+
sum: number;
|
|
48
|
+
min: number | null;
|
|
49
|
+
max: number | null;
|
|
50
|
+
};
|
|
51
|
+
type GroupKey = string | number | boolean | null;
|
|
52
|
+
|
|
53
|
+
const MAX_SAFE_COUNT = Number.MAX_SAFE_INTEGER;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Consumes Arrow batches without retaining input rows. Group state is O(number of groups).
|
|
57
|
+
* Snapshot creation is O(number of groups × number of aggregates) and can be throttled
|
|
58
|
+
* with emitEveryBatches. Consumer early return closes the underlying source iterator.
|
|
59
|
+
*/
|
|
60
|
+
export async function* executeProgressiveQuery(
|
|
61
|
+
query: ProgressiveAggregateQuery,
|
|
62
|
+
options: ProgressiveQueryOptions
|
|
63
|
+
): AsyncIterable<ProgressiveQuerySnapshot> {
|
|
64
|
+
validateQuery(query, options);
|
|
65
|
+
const {emitEveryBatches = 1, ...queryOptions} = options;
|
|
66
|
+
const inputs = new Set<string>();
|
|
67
|
+
if (query.groupBy) inputs.add(query.groupBy);
|
|
68
|
+
for (const aggregate of query.aggregates) if (aggregate.column) inputs.add(aggregate.column);
|
|
69
|
+
const columns = [...inputs];
|
|
70
|
+
const groups = new Map<GroupKey, AggregateState[]>();
|
|
71
|
+
let sourceSchema: arrow.Schema | undefined;
|
|
72
|
+
let rowsProcessed = 0;
|
|
73
|
+
let batchesSinceEmission = 0;
|
|
74
|
+
if (query.groupBy === undefined) groups.set(null, makeAggregateStates(query.aggregates.length));
|
|
75
|
+
|
|
76
|
+
// A COUNT(*) request can have no input columns, but the query pipeline still needs
|
|
77
|
+
// a source column to preserve row counts. The absence of select means all source
|
|
78
|
+
// columns are read; no source data is retained beyond each batch.
|
|
79
|
+
const tableQuery: TableQuery = {
|
|
80
|
+
...(query.from === undefined ? {} : {from: query.from}),
|
|
81
|
+
...(query.where === undefined ? {} : {where: query.where}),
|
|
82
|
+
...(columns.length ? {select: columns} : {})
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
for await (const batch of queryInBatches(tableQuery, {...queryOptions, queryOutput: undefined})) {
|
|
86
|
+
options.signal?.throwIfAborted();
|
|
87
|
+
sourceSchema ??= batch.data.schema;
|
|
88
|
+
if (batch.length === 0) continue;
|
|
89
|
+
const keyVector = query.groupBy ? batch.data.getChild(query.groupBy) : undefined;
|
|
90
|
+
const aggregateVectors = query.aggregates.map(aggregate =>
|
|
91
|
+
aggregate.column ? batch.data.getChild(aggregate.column) : undefined
|
|
92
|
+
);
|
|
93
|
+
for (let row = 0; row < batch.length; row++) {
|
|
94
|
+
if ((row & 1023) === 0) options.signal?.throwIfAborted();
|
|
95
|
+
const key = keyVector ? normalizeKey(keyVector.get(row)) : null;
|
|
96
|
+
let group = groups.get(key);
|
|
97
|
+
if (!group) {
|
|
98
|
+
group = makeAggregateStates(query.aggregates.length);
|
|
99
|
+
groups.set(key, group);
|
|
100
|
+
}
|
|
101
|
+
for (let index = 0; index < query.aggregates.length; index++) {
|
|
102
|
+
const operation = query.aggregates[index];
|
|
103
|
+
const value = aggregateVectors[index]?.get(row);
|
|
104
|
+
if (operation.function === 'count') {
|
|
105
|
+
if (!operation.column || (value !== null && value !== undefined)) {
|
|
106
|
+
increaseCount(group[index]);
|
|
107
|
+
}
|
|
108
|
+
} else if (value !== null && value !== undefined) {
|
|
109
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
110
|
+
throw new Error(
|
|
111
|
+
`Progressive ${operation.function} requires finite numeric values in column ${operation.column}`
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
updateNumeric(group[index], value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
rowsProcessed += batch.length;
|
|
119
|
+
if (++batchesSinceEmission >= emitEveryBatches) {
|
|
120
|
+
yield {table: createSnapshot(groups, query, sourceSchema), rowsProcessed, final: false};
|
|
121
|
+
batchesSinceEmission = 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// The terminal snapshot is always emitted, including empty inputs and when the
|
|
126
|
+
// previous provisional snapshot already has the same values.
|
|
127
|
+
yield {
|
|
128
|
+
table: createSnapshot(groups, query, sourceSchema),
|
|
129
|
+
rowsProcessed,
|
|
130
|
+
final: true
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function validateQuery(query: ProgressiveAggregateQuery, options: ProgressiveQueryOptions): void {
|
|
135
|
+
if (!query || typeof query !== 'object' || Array.isArray(query)) {
|
|
136
|
+
throw new Error('Progressive query must be an object.');
|
|
137
|
+
}
|
|
138
|
+
if (Object.keys(query).some(key => !['from', 'where', 'groupBy', 'aggregates'].includes(key))) {
|
|
139
|
+
throw new Error('Unsupported progressive query field.');
|
|
140
|
+
}
|
|
141
|
+
if (query.groupBy !== undefined && (typeof query.groupBy !== 'string' || !query.groupBy)) {
|
|
142
|
+
throw new Error('Progressive groupBy must be a nonempty column name.');
|
|
143
|
+
}
|
|
144
|
+
if (!Array.isArray(query.aggregates) || !query.aggregates.length) {
|
|
145
|
+
throw new Error('Progressive query requires at least one aggregate.');
|
|
146
|
+
}
|
|
147
|
+
const names = new Set(query.groupBy ? [query.groupBy] : []);
|
|
148
|
+
for (const aggregate of query.aggregates) {
|
|
149
|
+
if (!aggregate || !['count', 'sum', 'avg', 'min', 'max'].includes(aggregate.function)) {
|
|
150
|
+
throw new Error('Unsupported progressive aggregate function.');
|
|
151
|
+
}
|
|
152
|
+
if (Object.keys(aggregate).some(key => !['function', 'column', 'as'].includes(key))) {
|
|
153
|
+
throw new Error('Unsupported progressive aggregate field.');
|
|
154
|
+
}
|
|
155
|
+
if (!aggregate.as || typeof aggregate.as !== 'string' || names.has(aggregate.as)) {
|
|
156
|
+
throw new Error('Progressive aggregate aliases must be unique nonempty output names.');
|
|
157
|
+
}
|
|
158
|
+
if (
|
|
159
|
+
aggregate.column !== undefined &&
|
|
160
|
+
(typeof aggregate.column !== 'string' || !aggregate.column)
|
|
161
|
+
) {
|
|
162
|
+
throw new Error('Progressive aggregate column must be nonempty.');
|
|
163
|
+
}
|
|
164
|
+
if (aggregate.function !== 'count' && !aggregate.column) {
|
|
165
|
+
throw new Error(`Progressive ${aggregate.function} requires an input column.`);
|
|
166
|
+
}
|
|
167
|
+
names.add(aggregate.as);
|
|
168
|
+
}
|
|
169
|
+
const interval = options.emitEveryBatches ?? 1;
|
|
170
|
+
if (!Number.isSafeInteger(interval) || interval <= 0) {
|
|
171
|
+
throw new Error('emitEveryBatches must be a positive safe integer.');
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Initializes the independent aggregate state for one group. */
|
|
176
|
+
function makeAggregateStates(length: number): AggregateState[] {
|
|
177
|
+
return Array.from({length}, () => ({count: 0, sum: 0, min: null, max: null}));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function normalizeKey(value: unknown): GroupKey {
|
|
181
|
+
if (value === null || value === undefined) return null;
|
|
182
|
+
if (typeof value === 'string' || typeof value === 'boolean') return value;
|
|
183
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
184
|
+
throw new Error('Progressive GROUP BY supports finite numeric, string, boolean, and null keys.');
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function increaseCount(state: AggregateState): void {
|
|
188
|
+
if (state.count >= MAX_SAFE_COUNT)
|
|
189
|
+
throw new Error('Progressive aggregate count exceeds safe integer range.');
|
|
190
|
+
state.count++;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function updateNumeric(state: AggregateState, value: number): void {
|
|
194
|
+
increaseCount(state);
|
|
195
|
+
state.sum += value;
|
|
196
|
+
state.min = state.min === null ? value : Math.min(state.min, value);
|
|
197
|
+
state.max = state.max === null ? value : Math.max(state.max, value);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function createSnapshot(
|
|
201
|
+
groups: Map<GroupKey, AggregateState[]>,
|
|
202
|
+
query: ProgressiveAggregateQuery,
|
|
203
|
+
sourceSchema: arrow.Schema | undefined
|
|
204
|
+
): ArrowTable {
|
|
205
|
+
const resultColumns: Record<string, arrow.Vector> = {};
|
|
206
|
+
if (query.groupBy) {
|
|
207
|
+
const field = sourceSchema?.fields.find(candidate => candidate.name === query.groupBy);
|
|
208
|
+
if (!field) throw new Error(`Progressive group column not found: ${query.groupBy}`);
|
|
209
|
+
resultColumns[query.groupBy] = arrow.vectorFromArray([...groups.keys()], field.type);
|
|
210
|
+
}
|
|
211
|
+
for (let index = 0; index < query.aggregates.length; index++) {
|
|
212
|
+
const aggregate = query.aggregates[index];
|
|
213
|
+
const values = [...groups.values()].map(group => {
|
|
214
|
+
const state = group[index];
|
|
215
|
+
switch (aggregate.function) {
|
|
216
|
+
case 'count':
|
|
217
|
+
return state.count;
|
|
218
|
+
case 'sum':
|
|
219
|
+
return state.count ? state.sum : null;
|
|
220
|
+
case 'avg':
|
|
221
|
+
return state.count ? state.sum / state.count : null;
|
|
222
|
+
case 'min':
|
|
223
|
+
return state.min;
|
|
224
|
+
case 'max':
|
|
225
|
+
return state.max;
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
resultColumns[aggregate.as] = arrow.vectorFromArray(values, new arrow.Float64());
|
|
229
|
+
}
|
|
230
|
+
return convertArrowToTable(new arrow.Table(resultColumns), 'arrow-table');
|
|
231
|
+
}
|
package/src/scan/query.ts
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import * as arrow from 'apache-arrow';
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
ProgressiveAggregateQuery,
|
|
8
|
+
ProgressiveQueryOptions,
|
|
9
|
+
ProgressiveQuerySnapshot
|
|
10
|
+
} from './query-progressive';
|
|
11
|
+
import type {SQLQuery} from '@math.gl/expressions/sql';
|
|
7
12
|
import type {ArrowTable, ArrowTableBatch, TableBatch, Schema} from '@loaders.gl/core/schema';
|
|
8
13
|
import {
|
|
9
14
|
normalizeTableQuery,
|
|
@@ -18,7 +23,7 @@ import {
|
|
|
18
23
|
type TableScanReadOptions,
|
|
19
24
|
type LoaderOptions,
|
|
20
25
|
type DataSourceOptions,
|
|
21
|
-
type
|
|
26
|
+
type Loader,
|
|
22
27
|
resolveLoaderAuthenticationOptions,
|
|
23
28
|
isSourceLoader
|
|
24
29
|
} from '@loaders.gl/core/loader-utils';
|
|
@@ -50,6 +55,8 @@ export type QueryOptions = TableQueryExecutionOptions &
|
|
|
50
55
|
sources?: readonly DataSource<unknown, DataSourceOptions>[];
|
|
51
56
|
/** Parser or lazy parser promise, required only for SQL string input. */
|
|
52
57
|
sqlParser?: SQLQueryParser | Promise<SQLQueryParser>;
|
|
58
|
+
/** Append-only batches (default), or complete progressive replacement snapshots. */
|
|
59
|
+
queryOutput?: 'batches' | 'snapshots';
|
|
53
60
|
}> &
|
|
54
61
|
Readonly<
|
|
55
62
|
| {
|
|
@@ -70,7 +77,7 @@ export type QueryOptions = TableQueryExecutionOptions &
|
|
|
70
77
|
/** URL opened lazily with the explicitly supplied source loaders. */
|
|
71
78
|
source: string;
|
|
72
79
|
/** URL-capable source loaders; registered loaders are never selected implicitly. */
|
|
73
|
-
loaders:
|
|
80
|
+
loaders: Loader | Loader[];
|
|
74
81
|
}
|
|
75
82
|
>;
|
|
76
83
|
|
|
@@ -81,7 +88,7 @@ export async function query(
|
|
|
81
88
|
): Promise<ArrowTable> {
|
|
82
89
|
let schema: arrow.Schema | undefined;
|
|
83
90
|
const batches: arrow.RecordBatch[] = [];
|
|
84
|
-
for await (const batch of queryInBatches(tableQuery, options)) {
|
|
91
|
+
for await (const batch of queryInBatches(tableQuery, {...options, queryOutput: undefined})) {
|
|
85
92
|
schema = batch.data.schema;
|
|
86
93
|
batches.push(...batch.data.batches);
|
|
87
94
|
}
|
|
@@ -89,8 +96,71 @@ export async function query(
|
|
|
89
96
|
return {shape: 'arrow-table', schema: convertArrowToSchema(data.schema), data};
|
|
90
97
|
}
|
|
91
98
|
|
|
92
|
-
/**
|
|
99
|
+
/**
|
|
100
|
+
* Without queryOutput, preserves the legacy loaders.gl ArrowTableBatch envelope.
|
|
101
|
+
* With queryOutput, yields pure Arrow RecordBatch objects. Each snapshot replaces
|
|
102
|
+
* all earlier snapshots; batches are append-only.
|
|
103
|
+
*/
|
|
104
|
+
export function queryInBatches(
|
|
105
|
+
tableQuery: ProgressiveAggregateQuery,
|
|
106
|
+
options: QueryOptions & {queryOutput: 'snapshots'; emitEveryBatches?: number}
|
|
107
|
+
): AsyncIterable<arrow.RecordBatch>;
|
|
108
|
+
export function queryInBatches(
|
|
109
|
+
tableQuery: Query | string,
|
|
110
|
+
options: QueryOptions & {queryOutput: 'batches'}
|
|
111
|
+
): AsyncIterable<arrow.RecordBatch>;
|
|
112
|
+
export function queryInBatches(
|
|
113
|
+
tableQuery: Query | string,
|
|
114
|
+
options: QueryOptions & {queryOutput?: undefined}
|
|
115
|
+
): AsyncIterable<ArrowTableBatch>;
|
|
116
|
+
export function queryInBatches(
|
|
117
|
+
tableQuery: Query | string | ProgressiveAggregateQuery,
|
|
118
|
+
options: QueryOptions
|
|
119
|
+
): AsyncIterable<ArrowTableBatch | arrow.RecordBatch>;
|
|
93
120
|
export async function* queryInBatches(
|
|
121
|
+
tableQuery: Query | string | ProgressiveAggregateQuery,
|
|
122
|
+
options: QueryOptions
|
|
123
|
+
): AsyncIterable<ArrowTableBatch | arrow.RecordBatch> {
|
|
124
|
+
if (options.queryOutput === 'snapshots') {
|
|
125
|
+
if (
|
|
126
|
+
!tableQuery ||
|
|
127
|
+
typeof tableQuery !== 'object' ||
|
|
128
|
+
!('aggregates' in tableQuery) ||
|
|
129
|
+
!Array.isArray(tableQuery.aggregates)
|
|
130
|
+
) {
|
|
131
|
+
throw new Error('Snapshot query output currently requires a structured aggregate query.');
|
|
132
|
+
}
|
|
133
|
+
for await (const snapshot of queryProgressive(tableQuery, options)) {
|
|
134
|
+
yield* snapshot.table.data.batches;
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (options.queryOutput !== undefined && options.queryOutput !== 'batches') {
|
|
139
|
+
throw new Error('Unsupported queryOutput; expected batches or snapshots.');
|
|
140
|
+
}
|
|
141
|
+
if (typeof tableQuery === 'object' && tableQuery && 'aggregates' in tableQuery) {
|
|
142
|
+
throw new Error('Aggregate queries require queryOutput: snapshots.');
|
|
143
|
+
}
|
|
144
|
+
for await (const batch of queryAppendBatches(tableQuery as Query | string, options)) {
|
|
145
|
+
if (options.queryOutput === 'batches') {
|
|
146
|
+
yield* batch.data.batches;
|
|
147
|
+
} else {
|
|
148
|
+
yield batch;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** Streams complete aggregate snapshots and loads the grouped executor on demand. */
|
|
154
|
+
export async function* queryProgressive(
|
|
155
|
+
query: ProgressiveAggregateQuery,
|
|
156
|
+
options: ProgressiveQueryOptions
|
|
157
|
+
): AsyncIterable<ProgressiveQuerySnapshot> {
|
|
158
|
+
const {executeProgressiveQuery} = await import('./query-progressive');
|
|
159
|
+
yield* executeProgressiveQuery(query, options);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Executes one logical query with bounded batch buffering and cooperative cancellation. */
|
|
163
|
+
async function* queryAppendBatches(
|
|
94
164
|
tableQuery: Query | string,
|
|
95
165
|
options: QueryOptions
|
|
96
166
|
): AsyncIterable<ArrowTableBatch> {
|
|
@@ -214,6 +284,8 @@ export async function* queryInBatches(
|
|
|
214
284
|
['pushdown', 'pushdown+residual'].includes(capabilities.predicate)
|
|
215
285
|
);
|
|
216
286
|
const residual = delegatePredicate ? undefined : normalized.where;
|
|
287
|
+
const requestedRows =
|
|
288
|
+
normalized.limit === undefined ? undefined : (normalized.offset ?? 0) + normalized.limit;
|
|
217
289
|
const readOptions: TableScanReadOptions = {
|
|
218
290
|
signal: options.signal,
|
|
219
291
|
...(capabilities && capabilities.projection !== 'unsupported'
|
|
@@ -223,9 +295,11 @@ export async function* queryInBatches(
|
|
|
223
295
|
...(!residual &&
|
|
224
296
|
!expressionFilter &&
|
|
225
297
|
!castPredicate &&
|
|
298
|
+
requestedRows !== undefined &&
|
|
299
|
+
Number.isSafeInteger(requestedRows) &&
|
|
226
300
|
capabilities &&
|
|
227
301
|
['pushdown', 'pushdown+residual'].includes(capabilities.limit)
|
|
228
|
-
? {limit:
|
|
302
|
+
? {limit: requestedRows}
|
|
229
303
|
: {})
|
|
230
304
|
};
|
|
231
305
|
const inputSchema = readOptions.columns
|
|
@@ -276,7 +350,9 @@ export async function* queryInBatches(
|
|
|
276
350
|
() => inputs(),
|
|
277
351
|
{
|
|
278
352
|
predicate: residual,
|
|
353
|
+
offset: normalized.offset,
|
|
279
354
|
limit: normalized.limit,
|
|
355
|
+
skipEmptyBatches: true,
|
|
280
356
|
signal: options.signal
|
|
281
357
|
},
|
|
282
358
|
{
|
|
@@ -386,9 +462,15 @@ function wrapBatch(data: arrow.Table): ArrowTableBatch {
|
|
|
386
462
|
/** Opens only explicit URL source loaders; the public query owns the returned source. */
|
|
387
463
|
async function openQuerySource(options: QueryOptions): Promise<unknown> {
|
|
388
464
|
const candidates = Array.isArray(options.loaders) ? options.loaders : [options.loaders];
|
|
389
|
-
if (
|
|
465
|
+
if (
|
|
466
|
+
!candidates.length ||
|
|
467
|
+
!candidates.every(isSourceLoader) ||
|
|
468
|
+
candidates.some(loader => !loader.fromUrl)
|
|
469
|
+
) {
|
|
390
470
|
throw new Error('Query source must specify explicit URL-capable source loaders for a URL.');
|
|
391
|
-
|
|
471
|
+
}
|
|
472
|
+
const {source, sources, loaders, sqlParser, onQueryComplete, queryOutput, ...sourceOptions} =
|
|
473
|
+
options;
|
|
392
474
|
const url = source as string;
|
|
393
475
|
const selected =
|
|
394
476
|
candidates.length === 1 ? candidates[0]! : candidates.find(loader => loader!.testURL(url));
|
|
@@ -403,10 +485,10 @@ async function openQuerySource(options: QueryOptions): Promise<unknown> {
|
|
|
403
485
|
{...sourceOptions, core: {...sourceOptions.core, ignoreRegisteredLoaders: true}}
|
|
404
486
|
);
|
|
405
487
|
options.signal?.throwIfAborted();
|
|
406
|
-
return implementation.
|
|
488
|
+
return implementation.createDataSourceSync(url, authenticatedOptions as DataSourceOptions);
|
|
407
489
|
}
|
|
408
490
|
|
|
409
|
-
export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/
|
|
491
|
+
export {parseSQLQuery, parseSQLSelect, type SQLSelectParserOptions} from '@math.gl/expressions/sql';
|
|
410
492
|
|
|
411
493
|
export {createSQLCatalog} from './sql-catalog';
|
|
412
494
|
export type {SQLCatalog, SQLCatalogQuery, SQLCatalogSource, SQLCatalogTable} from './sql-catalog';
|
|
@@ -29,6 +29,11 @@ export type {
|
|
|
29
29
|
export {getArrowViewTypeSupport} from './lib/schema/convert-arrow-schema';
|
|
30
30
|
export {getDataTypeFromArray} from './lib/schema/data-type';
|
|
31
31
|
|
|
32
|
+
export {
|
|
33
|
+
convertArrowTable,
|
|
34
|
+
convertArrowTableBatch
|
|
35
|
+
} from './lib/table/tables/convert-arrow-table-wrapper';
|
|
36
|
+
|
|
32
37
|
// TABLE CATEGORY UTILS
|
|
33
38
|
|
|
34
39
|
export {deduceTableSchema} from './lib/schema/deduce-table-schema';
|
|
@@ -55,9 +55,11 @@ function deduceSchemaFromRows(rowTable: unknown[][] | {[key: string]: unknown}[]
|
|
|
55
55
|
const row0 = rowTable[0];
|
|
56
56
|
// TODO - fields can be nullable, false detection...
|
|
57
57
|
// Could look at additional rows if nulls in first row
|
|
58
|
-
//
|
|
58
|
+
// Positional rows use the same one-based generated names as headerless CSV.
|
|
59
|
+
// Object rows keep their original keys, including numeric-looking names.
|
|
59
60
|
for (const [columnName, value] of Object.entries(row0)) {
|
|
60
|
-
|
|
61
|
+
const name = Array.isArray(row0) ? `column${Number(columnName) + 1}` : columnName;
|
|
62
|
+
fields.push(deduceFieldFromValue(value, name));
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
return {fields, metadata: {}};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ArrowTable, ArrowTableBatch, Table, TableBatch} from '@loaders.gl/core/schema';
|
|
6
|
+
import {convertArrowToTable} from './convert-arrow-table';
|
|
7
|
+
|
|
8
|
+
/** Table layouts supported by the Arrow wrapper adapters. */
|
|
9
|
+
type ArrowTableShape = Exclude<Table['shape'], 'geojson-table'>;
|
|
10
|
+
|
|
11
|
+
/** A converted layout retaining the input wrapper's additional properties. */
|
|
12
|
+
type ConvertedArrowTable<Input, Shape extends ArrowTableShape> = Omit<
|
|
13
|
+
Input,
|
|
14
|
+
'shape' | 'data' | 'schema'
|
|
15
|
+
> &
|
|
16
|
+
Extract<Table, {shape: Shape}>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts an Arrow wrapper while preserving its schema and additional metadata.
|
|
20
|
+
* Returns the original wrapper for Arrow output. Other layouts use the existing
|
|
21
|
+
* Arrow conversion semantics, inferring a schema only when the wrapper omits it.
|
|
22
|
+
* @param table Arrow table wrapper.
|
|
23
|
+
* @param shape Requested table layout.
|
|
24
|
+
* @returns Converted table with the input wrapper's metadata.
|
|
25
|
+
*/
|
|
26
|
+
export function convertArrowTable<Input extends ArrowTable, Shape extends ArrowTableShape>(
|
|
27
|
+
table: Input,
|
|
28
|
+
shape: Shape
|
|
29
|
+
): ConvertedArrowTable<Input, Shape>;
|
|
30
|
+
export function convertArrowTable(table: ArrowTable, shape: ArrowTableShape): Table {
|
|
31
|
+
if (shape === table.shape) {
|
|
32
|
+
return table;
|
|
33
|
+
}
|
|
34
|
+
const converted = convertArrowToTable(table.data, shape);
|
|
35
|
+
return {
|
|
36
|
+
...table,
|
|
37
|
+
...converted,
|
|
38
|
+
schema: table.schema ?? converted.schema
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Converts an Arrow batch while retaining length, batch type, progress and metadata.
|
|
44
|
+
* Returns the original batch for Arrow output. Does not combine or buffer batches.
|
|
45
|
+
* @param batch Arrow table batch.
|
|
46
|
+
* @param shape Requested table layout.
|
|
47
|
+
* @returns Converted batch with the input batch's metadata.
|
|
48
|
+
*/
|
|
49
|
+
export function convertArrowTableBatch<
|
|
50
|
+
Input extends ArrowTableBatch,
|
|
51
|
+
Shape extends ArrowTableShape
|
|
52
|
+
>(
|
|
53
|
+
batch: Input,
|
|
54
|
+
shape: Shape
|
|
55
|
+
): ConvertedArrowTable<Input, Shape> & Extract<TableBatch, {shape: Shape}> {
|
|
56
|
+
return convertArrowTable(batch, shape) as ConvertedArrowTable<Input, Shape> &
|
|
57
|
+
Extract<TableBatch, {shape: Shape}>;
|
|
58
|
+
}
|
|
@@ -17,7 +17,7 @@ export function convertToObjectRow(
|
|
|
17
17
|
}
|
|
18
18
|
} else {
|
|
19
19
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
20
|
-
const columnName = `column
|
|
20
|
+
const columnName = `column${i + 1}`;
|
|
21
21
|
objectRow[columnName] = arrayRow[i];
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -47,7 +47,7 @@ export function convertToArrayRow(
|
|
|
47
47
|
export function inferHeadersFromArrayRow(arrayRow: unknown[]) {
|
|
48
48
|
const headers: string[] = [];
|
|
49
49
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
50
|
-
const columnName = `column
|
|
50
|
+
const columnName = `column${i + 1}`;
|
|
51
51
|
headers.push(columnName);
|
|
52
52
|
}
|
|
53
53
|
return headers;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
/* global importScripts */
|
|
6
|
+
import {log as loaderLog} from './../../../loader-utils/lib/log-utils/log';
|
|
6
7
|
import {isBrowser, isWorker} from '../env-utils/globals';
|
|
7
8
|
import {assert} from '../env-utils/assert';
|
|
8
9
|
import {VERSION} from '../env-utils/version';
|
|
@@ -190,7 +191,7 @@ async function loadLibraryFromFile(libraryUrl: string, moduleLibraryUrl: string)
|
|
|
190
191
|
// ignore
|
|
191
192
|
}
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
+
loaderLog.error(String(error))();
|
|
194
195
|
return null;
|
|
195
196
|
}
|
|
196
197
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
/* eslint-disable no-console */
|
|
6
|
+
import {log as loaderLog} from './../../../loader-utils/lib/log-utils/log';
|
|
6
7
|
import {getAvailablePort} from './process-utils';
|
|
7
8
|
|
|
8
9
|
type NodeChildProcess = import('child_process').ChildProcess;
|
|
@@ -44,7 +45,7 @@ const DEFAULT_PROPS: ChildProcessProxyProps = {
|
|
|
44
45
|
autoPort: true,
|
|
45
46
|
wait: 2000,
|
|
46
47
|
onSuccess: processProxy => {
|
|
47
|
-
|
|
48
|
+
loaderLog.log(0, `Started ${processProxy.props.command}`)();
|
|
48
49
|
}
|
|
49
50
|
};
|
|
50
51
|
|
|
@@ -91,7 +92,7 @@ export default class ChildProcessProxy {
|
|
|
91
92
|
resolve({});
|
|
92
93
|
});
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
loaderLog.log(0, `Spawning ${props.command} ${props.arguments.join(' ')}`)();
|
|
95
96
|
if (props.spawn?.shell) {
|
|
96
97
|
throw new Error('ChildProcessProxy does not support shell execution');
|
|
97
98
|
}
|
|
@@ -104,22 +105,22 @@ export default class ChildProcessProxy {
|
|
|
104
105
|
this.childProcess = childProcess;
|
|
105
106
|
|
|
106
107
|
childProcess.stdout?.on('data', data => {
|
|
107
|
-
|
|
108
|
+
loaderLog.log(0, data.toString())();
|
|
108
109
|
});
|
|
109
110
|
childProcess.stderr?.on('data', data => {
|
|
110
|
-
|
|
111
|
+
loaderLog.log(0, `Child process wrote to stderr: "${data}".`)();
|
|
111
112
|
if (!props.ignoreStderr) {
|
|
112
113
|
this._clearTimeout();
|
|
113
114
|
reject(new Error(data));
|
|
114
115
|
}
|
|
115
116
|
});
|
|
116
117
|
childProcess.on('error', error => {
|
|
117
|
-
|
|
118
|
+
loaderLog.log(0, `Child process errored with ${error}`)();
|
|
118
119
|
this._clearTimeout();
|
|
119
120
|
reject(error);
|
|
120
121
|
});
|
|
121
122
|
childProcess.on('close', code => {
|
|
122
|
-
|
|
123
|
+
loaderLog.log(0, `Child process exited with ${code}`)();
|
|
123
124
|
this.childProcess = null;
|
|
124
125
|
this._clearTimeout();
|
|
125
126
|
resolve({});
|
|
@@ -145,7 +146,7 @@ export default class ChildProcessProxy {
|
|
|
145
146
|
// eslint-disable-next-line no-process-exit
|
|
146
147
|
process.exit(statusCode);
|
|
147
148
|
} catch (error) {
|
|
148
|
-
|
|
149
|
+
loaderLog.error(String((error as Error).message || error))();
|
|
149
150
|
// eslint-disable-next-line no-process-exit
|
|
150
151
|
process.exit(1);
|
|
151
152
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// SPDX-License-Identifier: MIT
|
|
7
7
|
// Copyright (c) vis.gl contributors
|
|
8
8
|
|
|
9
|
+
import {log as loaderLog} from './../../../loader-utils/lib/log-utils/log';
|
|
9
10
|
import type {WorkerObject, WorkerOptions} from '../../types';
|
|
10
11
|
import {assert} from '../env-utils/assert';
|
|
11
12
|
import {isBrowser} from '../env-utils/globals';
|
|
@@ -121,8 +122,8 @@ function warnIfUsingNpmTagFallback(worker: WorkerObject, url: string): void {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
warnedWorkerVersionFallbacks.add(workerId);
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
|
|
126
|
+
loaderLog.warn(
|
|
126
127
|
`loaders.gl: ${worker.name} loader worker version is "latest" because __VERSION__ was not injected. Fetching ${url} from CDN.`
|
|
127
|
-
);
|
|
128
|
+
)();
|
|
128
129
|
}
|
|
@@ -72,10 +72,5 @@ function getLoadableWorkerURLFromSource(workerSource: string): string {
|
|
|
72
72
|
*/
|
|
73
73
|
function buildScriptSource(workerUrl: string): string {
|
|
74
74
|
return `\
|
|
75
|
-
|
|
76
|
-
importScripts('${workerUrl}');
|
|
77
|
-
} catch (error) {
|
|
78
|
-
console.error(error);
|
|
79
|
-
throw error;
|
|
80
|
-
}`;
|
|
75
|
+
importScripts('${workerUrl}');`;
|
|
81
76
|
}
|