@loaders.gl/core 5.0.0-beta.5 → 5.0.0-beta.7
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/cluster-source.cjs +45 -1
- package/dist/cluster-source.cjs.map +1 -1
- package/dist/dist.min.js +2 -2
- package/dist/federated-table-scan-source.cjs +279 -201
- package/dist/federated-table-scan-source.cjs.map +3 -3
- package/dist/index.cjs +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/loader-utils/index.cjs +233 -12
- package/dist/loader-utils/index.cjs.map +2 -2
- package/dist/loader-utils/index.d.ts +8 -4
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +3 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.d.ts +4 -0
- package/dist/loader-utils/lib/files/http-file-transport.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/http-file-transport.js +45 -1
- package/dist/loader-utils/lib/files/http-file-transport.js.map +1 -1
- package/dist/loader-utils/lib/files/http-file-types.d.ts +2 -0
- package/dist/loader-utils/lib/files/http-file-types.d.ts.map +1 -1
- package/dist/loader-utils/lib/files/read-range-response.d.ts +3 -0
- package/dist/loader-utils/lib/files/read-range-response.d.ts.map +1 -0
- package/dist/loader-utils/lib/files/read-range-response.js +62 -0
- package/dist/loader-utils/lib/files/read-range-response.js.map +1 -0
- package/dist/loader-utils/lib/log-utils/log.js +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +38 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +96 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.d.ts → query-options.d.ts} +5 -8
- package/dist/loader-utils/lib/scan-utils/query-options.d.ts.map +1 -0
- package/dist/loader-utils/lib/scan-utils/{experimental-scan-options.js → query-options.js} +1 -1
- package/dist/loader-utils/lib/scan-utils/query-options.js.map +1 -0
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts +12 -17
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js +5 -5
- package/dist/loader-utils/lib/scan-utils/scan-query-metadata.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +33 -3
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- 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 +2 -2
- 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 +11 -3
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.d.ts +4 -0
- package/dist/loader-utils/lib/sources/data-source.d.ts.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +50 -1
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts +30 -0
- package/dist/loader-utils/lib/sources/table-source-collection.d.ts.map +1 -0
- package/dist/loader-utils/lib/sources/table-source-collection.js +5 -0
- package/dist/loader-utils/lib/sources/table-source-collection.js.map +1 -0
- package/dist/loader-utils/loader-types.d.ts +5 -5
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +110 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +9 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +60 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +266 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +18 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js +230 -0
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs +70 -0
- package/dist/scan/arrow-execution/project-arrow-table.cjs.map +7 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts +8 -0
- package/dist/scan/arrow-execution/project-arrow-table.d.ts.map +1 -0
- package/dist/scan/arrow-execution/project-arrow-table.js +39 -0
- package/dist/scan/arrow-execution/project-arrow-table.js.map +1 -0
- package/dist/scan/arrow-execution.cjs +34 -0
- package/dist/scan/arrow-execution.cjs.map +7 -0
- package/dist/scan/arrow-execution.d.ts +4 -0
- package/dist/scan/arrow-execution.d.ts.map +1 -0
- package/dist/scan/arrow-execution.js +6 -0
- package/dist/scan/arrow-execution.js.map +1 -0
- package/dist/scan/arrow-query.cjs.map +1 -1
- package/dist/scan/arrow-query.d.ts +1 -1
- package/dist/scan/arrow-query.d.ts.map +1 -1
- package/dist/scan/catalog-query-source.cjs +122 -0
- package/dist/scan/catalog-query-source.cjs.map +7 -0
- package/dist/scan/catalog-query-source.d.ts +6 -0
- package/dist/scan/catalog-query-source.d.ts.map +1 -0
- package/dist/scan/catalog-query-source.js +115 -0
- package/dist/scan/catalog-query-source.js.map +1 -0
- package/dist/scan/federated-table-scan-source.cjs +4 -4
- package/dist/scan/federated-table-scan-source.cjs.map +2 -2
- package/dist/scan/federated-table-scan-source.d.ts +1 -1
- package/dist/scan/federated-table-scan-source.d.ts.map +1 -1
- package/dist/scan/federated-table-scan-source.js +4 -4
- package/dist/scan/federated-table-scan-source.js.map +1 -1
- package/dist/scan/index.cjs +188 -4
- package/dist/scan/index.cjs.map +4 -4
- package/dist/scan/index.d.ts +9 -2
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +4 -0
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +6 -9
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -314
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-arrow-table-in-batches.cjs +65 -0
- package/dist/scan/query-arrow-table-in-batches.cjs.map +7 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts +8 -0
- package/dist/scan/query-arrow-table-in-batches.d.ts.map +1 -0
- package/dist/scan/query-arrow-table-in-batches.js +44 -0
- package/dist/scan/query-arrow-table-in-batches.js.map +1 -0
- package/dist/scan/query-arrow-table.cjs +52 -179
- package/dist/scan/query-arrow-table.cjs.map +3 -3
- package/dist/scan/query-arrow-table.d.ts +4 -37
- package/dist/scan/query-arrow-table.d.ts.map +1 -1
- package/dist/scan/query-arrow-table.js +37 -188
- package/dist/scan/query-arrow-table.js.map +1 -1
- package/dist/scan/query.cjs +344 -0
- package/dist/scan/query.cjs.map +7 -0
- package/dist/scan/query.d.ts +42 -0
- package/dist/scan/query.d.ts.map +1 -0
- package/dist/scan/query.js +367 -0
- package/dist/scan/query.js.map +1 -0
- package/dist/scan/resolve-query-source.cjs +59 -0
- package/dist/scan/resolve-query-source.cjs.map +7 -0
- package/dist/scan/resolve-query-source.d.ts +6 -0
- package/dist/scan/resolve-query-source.d.ts.map +1 -0
- package/dist/scan/resolve-query-source.js +37 -0
- package/dist/scan/resolve-query-source.js.map +1 -0
- package/dist/scan/sql-catalog.cjs +110 -0
- package/dist/scan/sql-catalog.cjs.map +7 -0
- package/dist/scan/sql-catalog.d.ts +47 -0
- package/dist/scan/sql-catalog.d.ts.map +1 -0
- package/dist/scan/sql-catalog.js +97 -0
- package/dist/scan/sql-catalog.js.map +1 -0
- package/dist/scan/table-query.cjs.map +2 -2
- package/dist/scan/table-query.d.ts +4 -1
- package/dist/scan/table-query.d.ts.map +1 -1
- package/dist/scan/table-query.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +288 -193
- package/dist/vector-table-scan-source.cjs.map +3 -3
- package/dist/worker-utils/index.cjs +2 -1
- 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/library-utils/library-utils.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/package.json +17 -7
- package/src/loader-utils/index.ts +30 -6
- package/src/loader-utils/lib/files/http-file-transport.ts +65 -1
- package/src/loader-utils/lib/files/http-file-types.ts +2 -0
- package/src/loader-utils/lib/files/read-range-response.ts +66 -0
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +164 -0
- package/src/loader-utils/lib/scan-utils/query-options.ts +44 -0
- package/src/loader-utils/lib/scan-utils/scan-query-metadata.ts +17 -26
- package/src/loader-utils/lib/scan-utils/table-query.ts +49 -8
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +25 -9
- package/src/loader-utils/lib/sources/data-source.ts +54 -1
- package/src/loader-utils/lib/sources/table-source-collection.ts +38 -0
- package/src/loader-utils/loader-types.ts +5 -5
- package/src/scan/arrow-execution/expressions.ts +86 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +309 -0
- package/src/scan/arrow-execution/project-arrow-table.ts +53 -0
- package/src/scan/arrow-execution.ts +7 -0
- package/src/scan/arrow-query.ts +3 -0
- package/src/scan/catalog-query-source.ts +132 -0
- package/src/scan/federated-table-scan-source.ts +19 -19
- package/src/scan/index.ts +28 -4
- package/src/scan/parse-sql-predicate.ts +14 -367
- package/src/scan/query-arrow-table-in-batches.ts +58 -0
- package/src/scan/query-arrow-table.ts +60 -237
- package/src/scan/query.ts +480 -0
- package/src/scan/resolve-query-source.ts +47 -0
- package/src/scan/sql-catalog.ts +167 -0
- package/src/scan/table-query.ts +6 -1
- package/src/worker-utils/lib/library-utils/library-utils.ts +1 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.d.ts.map +0 -1
- package/dist/loader-utils/lib/scan-utils/experimental-scan-options.js.map +0 -1
- package/src/loader-utils/lib/scan-utils/experimental-scan-options.ts +0 -46
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/** Reads a bounded exact byte-range response without requiring total-size discovery. */
|
|
6
|
+
export async function readRangeResponse(
|
|
7
|
+
response: Response,
|
|
8
|
+
offset: number | bigint,
|
|
9
|
+
length: number,
|
|
10
|
+
signal?: AbortSignal
|
|
11
|
+
): Promise<Uint8Array> {
|
|
12
|
+
if (
|
|
13
|
+
(typeof offset === 'number' && (!Number.isSafeInteger(offset) || offset < 0)) ||
|
|
14
|
+
(typeof offset === 'bigint' && offset < 0n) ||
|
|
15
|
+
!Number.isSafeInteger(length) ||
|
|
16
|
+
length <= 0
|
|
17
|
+
) {
|
|
18
|
+
await response.body?.cancel().catch(() => {});
|
|
19
|
+
throw new RangeError('Invalid HTTP byte range');
|
|
20
|
+
}
|
|
21
|
+
const start = BigInt(offset);
|
|
22
|
+
const end = start + BigInt(length) - 1n;
|
|
23
|
+
const value = response.headers.get('Content-Range');
|
|
24
|
+
const match = value === null ? null : /^bytes (\d+)-(\d+)\/(\d+|\*)$/.exec(value);
|
|
25
|
+
// CORS may hide metadata while still allowing a safelisted single Range.
|
|
26
|
+
// Never treat empty/malformed visible metadata as an absent header.
|
|
27
|
+
if (
|
|
28
|
+
response.status !== 206 ||
|
|
29
|
+
(value !== null &&
|
|
30
|
+
(!match ||
|
|
31
|
+
BigInt(match[1]) !== start ||
|
|
32
|
+
BigInt(match[2]) !== end ||
|
|
33
|
+
(match[3] !== '*' && BigInt(match[3]) <= end)))
|
|
34
|
+
) {
|
|
35
|
+
await response.body?.cancel().catch(() => {});
|
|
36
|
+
throw new Error('HTTP range requires 206 and matching Content-Range when visible');
|
|
37
|
+
}
|
|
38
|
+
const reader = response.body?.getReader();
|
|
39
|
+
if (!reader) throw new Error('HTTP range response has no body');
|
|
40
|
+
let received = 0;
|
|
41
|
+
const abort = () => {
|
|
42
|
+
void reader.cancel(signal?.reason).catch(() => {});
|
|
43
|
+
};
|
|
44
|
+
signal?.addEventListener('abort', abort, {once: true});
|
|
45
|
+
try {
|
|
46
|
+
signal?.throwIfAborted();
|
|
47
|
+
const bytes = new Uint8Array(length);
|
|
48
|
+
for (;;) {
|
|
49
|
+
const chunk = await reader.read();
|
|
50
|
+
signal?.throwIfAborted();
|
|
51
|
+
if (chunk.done) break;
|
|
52
|
+
if (received + chunk.value.byteLength > length)
|
|
53
|
+
throw new Error('HTTP range body exceeds requested length');
|
|
54
|
+
bytes.set(chunk.value, received);
|
|
55
|
+
received += chunk.value.byteLength;
|
|
56
|
+
}
|
|
57
|
+
if (received !== length) throw new Error('HTTP range body has truncated length');
|
|
58
|
+
return bytes;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
await reader.cancel(error).catch(() => {});
|
|
61
|
+
throw error;
|
|
62
|
+
} finally {
|
|
63
|
+
signal?.removeEventListener('abort', abort);
|
|
64
|
+
reader.releaseLock();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
validateColumnarPredicate,
|
|
7
|
+
type ColumnarPredicate,
|
|
8
|
+
type ColumnarPredicateProperty
|
|
9
|
+
} from './columnar-predicate';
|
|
10
|
+
import {
|
|
11
|
+
planTableQuery,
|
|
12
|
+
validateTableQueryLimit,
|
|
13
|
+
type TableQuery,
|
|
14
|
+
type TableReference,
|
|
15
|
+
type TableQueryPlanStep
|
|
16
|
+
} from './table-query';
|
|
17
|
+
|
|
18
|
+
/** Explicit source-to-output mapping for one selected field. */
|
|
19
|
+
export type NormalizedTableSelection = Readonly<{
|
|
20
|
+
/** Column read from the source. */
|
|
21
|
+
column: string;
|
|
22
|
+
/** Name of the returned field. */
|
|
23
|
+
as: string;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
/** Logical query with all output selections expanded into explicit mappings. */
|
|
27
|
+
export type NormalizedTableQuery<PredicateT = ColumnarPredicate> = Readonly<{
|
|
28
|
+
/** Optional source reference preserved separately from physical scan operations. */
|
|
29
|
+
from?: TableReference;
|
|
30
|
+
/** Output mappings in caller-specified order. */
|
|
31
|
+
select: readonly NormalizedTableSelection[];
|
|
32
|
+
/** Predicate resolved against source names before aliases. */
|
|
33
|
+
where?: PredicateT;
|
|
34
|
+
/** Global post-filter row limit. */
|
|
35
|
+
limit?: number;
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
/** Logical projection retaining source names separately from output names. */
|
|
39
|
+
export type LogicalTableQueryProjectStep = Readonly<{
|
|
40
|
+
/** Plan discriminator. */
|
|
41
|
+
kind: 'project';
|
|
42
|
+
/** Output mappings applied after filtering. */
|
|
43
|
+
select: readonly NormalizedTableSelection[];
|
|
44
|
+
}>;
|
|
45
|
+
|
|
46
|
+
/** Scan, filter, aliased projection, and limit operations in execution order. */
|
|
47
|
+
export type LogicalTableQueryPlan<PredicateT = ColumnarPredicate> = readonly (
|
|
48
|
+
| Exclude<TableQueryPlanStep<PredicateT>, {kind: 'project'}>
|
|
49
|
+
| LogicalTableQueryProjectStep
|
|
50
|
+
)[];
|
|
51
|
+
|
|
52
|
+
/** Validates logical query fields and expands selections without modifying caller input. */
|
|
53
|
+
export function normalizeTableQuery<
|
|
54
|
+
PredicateT extends ColumnarPredicate<unknown, ColumnarPredicateProperty> = ColumnarPredicate
|
|
55
|
+
>(
|
|
56
|
+
sourceColumnNames: readonly string[],
|
|
57
|
+
query: TableQuery<PredicateT> = {}
|
|
58
|
+
): NormalizedTableQuery<PredicateT> {
|
|
59
|
+
if (!query || typeof query !== 'object' || Array.isArray(query)) {
|
|
60
|
+
throw new Error('Table query must be an object.');
|
|
61
|
+
}
|
|
62
|
+
for (const key of Object.keys(query)) {
|
|
63
|
+
if (!['from', 'select', 'where', 'limit'].includes(key)) {
|
|
64
|
+
throw new Error(`Unsupported table query option: ${key}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (query.select !== undefined && (!Array.isArray(query.select) || query.select.length === 0)) {
|
|
68
|
+
throw new Error('Table query select must be a non-empty array.');
|
|
69
|
+
}
|
|
70
|
+
validateTableReference(query.from);
|
|
71
|
+
validateTableQueryLimit(query.limit);
|
|
72
|
+
if (query.where !== undefined) {
|
|
73
|
+
validateColumnarPredicate(query.where, new Set(sourceColumnNames));
|
|
74
|
+
}
|
|
75
|
+
const outputNames = new Set<string>();
|
|
76
|
+
const select = (query.select ?? sourceColumnNames).map(selection => {
|
|
77
|
+
if (
|
|
78
|
+
typeof selection !== 'string' &&
|
|
79
|
+
(!selection || typeof selection !== 'object' || Array.isArray(selection))
|
|
80
|
+
) {
|
|
81
|
+
throw new Error('Table query selection must be a column name or {column, as}.');
|
|
82
|
+
}
|
|
83
|
+
if (
|
|
84
|
+
typeof selection !== 'string' &&
|
|
85
|
+
Object.keys(selection).some(key => key !== 'column' && key !== 'as')
|
|
86
|
+
) {
|
|
87
|
+
throw new Error('Unsupported table query selection field.');
|
|
88
|
+
}
|
|
89
|
+
const column = typeof selection === 'string' ? selection : selection.column;
|
|
90
|
+
const outputName =
|
|
91
|
+
typeof selection === 'string'
|
|
92
|
+
? selection
|
|
93
|
+
: selection.as === undefined
|
|
94
|
+
? column
|
|
95
|
+
: selection.as;
|
|
96
|
+
if (typeof column !== 'string' || !sourceColumnNames.includes(column)) {
|
|
97
|
+
throw new Error(`Table query column not found: ${column}`);
|
|
98
|
+
}
|
|
99
|
+
if (typeof outputName !== 'string' || outputName.length === 0) {
|
|
100
|
+
throw new Error('Table query output name must be a non-empty string.');
|
|
101
|
+
}
|
|
102
|
+
if (outputNames.has(outputName)) {
|
|
103
|
+
throw new Error(`Duplicate table query output name: ${outputName}`);
|
|
104
|
+
}
|
|
105
|
+
outputNames.add(outputName);
|
|
106
|
+
return Object.freeze({column, as: outputName});
|
|
107
|
+
});
|
|
108
|
+
// Reuse source-column and predicate validation; aliases never participate in WHERE resolution.
|
|
109
|
+
planTableQuery(sourceColumnNames, {
|
|
110
|
+
columns: [...new Set(select.map(selection => selection.column))],
|
|
111
|
+
predicate: query.where,
|
|
112
|
+
limit: query.limit
|
|
113
|
+
});
|
|
114
|
+
return Object.freeze({
|
|
115
|
+
select: Object.freeze(select),
|
|
116
|
+
...(query.from === undefined
|
|
117
|
+
? {}
|
|
118
|
+
: {from: typeof query.from === 'string' ? query.from : Object.freeze({...query.from})}),
|
|
119
|
+
...(query.where === undefined ? {} : {where: query.where}),
|
|
120
|
+
...(query.limit === undefined ? {} : {limit: query.limit})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Builds a logical plan using the shared scan planner and an explicit aliased projection. */
|
|
125
|
+
export function planLogicalTableQuery<
|
|
126
|
+
PredicateT extends ColumnarPredicate<unknown, ColumnarPredicateProperty> = ColumnarPredicate
|
|
127
|
+
>(
|
|
128
|
+
sourceColumnNames: readonly string[],
|
|
129
|
+
query: TableQuery<PredicateT> = {}
|
|
130
|
+
): LogicalTableQueryPlan<PredicateT> {
|
|
131
|
+
const normalized = normalizeTableQuery(sourceColumnNames, query);
|
|
132
|
+
const plan = planTableQuery(sourceColumnNames, {
|
|
133
|
+
columns: [...new Set(normalized.select.map(selection => selection.column))],
|
|
134
|
+
predicate: normalized.where,
|
|
135
|
+
limit: normalized.limit
|
|
136
|
+
});
|
|
137
|
+
return Object.freeze(
|
|
138
|
+
plan.map(step =>
|
|
139
|
+
step.kind === 'project'
|
|
140
|
+
? Object.freeze({kind: 'project' as const, select: normalized.select})
|
|
141
|
+
: step
|
|
142
|
+
)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Validates identifiers without interpreting dots or rewriting quoted names. */
|
|
147
|
+
export function validateTableReference(
|
|
148
|
+
reference: unknown
|
|
149
|
+
): asserts reference is TableReference | undefined {
|
|
150
|
+
if (reference === undefined) return;
|
|
151
|
+
if (typeof reference === 'string' && reference.trim()) return;
|
|
152
|
+
if (reference && typeof reference === 'object' && !Array.isArray(reference)) {
|
|
153
|
+
const value = reference as Record<string, unknown>;
|
|
154
|
+
if (
|
|
155
|
+
Object.keys(value).every(key => key === 'source' || key === 'table') &&
|
|
156
|
+
typeof value.source === 'string' &&
|
|
157
|
+
value.source.trim() &&
|
|
158
|
+
typeof value.table === 'string' &&
|
|
159
|
+
value.table.trim()
|
|
160
|
+
)
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
throw new Error('FROM must be a source name or {source, table} with non-empty names.');
|
|
164
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ColumnarPredicate} from './columnar-predicate';
|
|
6
|
+
import type {ScanBounds} from './scan-query-metadata';
|
|
7
|
+
import type {TableQueryExecutionOptions} from './table-query';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Common query request accepted by loaders that implement the scan protocol.
|
|
11
|
+
*
|
|
12
|
+
* Format loaders apply the fields relevant to their query family and must reject unsupported
|
|
13
|
+
* fields rather than silently ignoring them. This intentionally remains a common superset in 5.0
|
|
14
|
+
* so applications and Deck.gl adapters can forward one stable option object.
|
|
15
|
+
*/
|
|
16
|
+
export type QueryOptions = TableQueryExecutionOptions &
|
|
17
|
+
Readonly<{
|
|
18
|
+
/** Portable predicate for table-like sources. */
|
|
19
|
+
predicate?: ColumnarPredicate;
|
|
20
|
+
/** Output columns or bands selected by the caller. */
|
|
21
|
+
columns?: readonly string[];
|
|
22
|
+
/** Maximum number of rows or points retained after filtering. */
|
|
23
|
+
limit?: number;
|
|
24
|
+
/** Source-coordinate bounds for spatial, raster, and point-cloud scans. */
|
|
25
|
+
bounds?: ScanBounds;
|
|
26
|
+
/** Raster overview or point-cloud hierarchy level. */
|
|
27
|
+
level?: number;
|
|
28
|
+
/** Shallowest point-cloud hierarchy level to read. */
|
|
29
|
+
minimumLevel?: number;
|
|
30
|
+
/** Deepest point-cloud hierarchy level to read. */
|
|
31
|
+
maximumLevel?: number;
|
|
32
|
+
/** Desired maximum point spacing for point-cloud scans. */
|
|
33
|
+
targetSpacing?: number;
|
|
34
|
+
/** Requested raster output width in pixels. */
|
|
35
|
+
width?: number;
|
|
36
|
+
/** Requested raster output height in pixels. */
|
|
37
|
+
height?: number;
|
|
38
|
+
/** Named raster variables or bands. */
|
|
39
|
+
variables?: readonly string[];
|
|
40
|
+
/** Numeric raster channel indices. */
|
|
41
|
+
channels?: readonly number[];
|
|
42
|
+
/** Raster dimension indices or half-open ranges. */
|
|
43
|
+
slices?: Readonly<Record<string, number | readonly [number, number]>>;
|
|
44
|
+
}>;
|
|
@@ -7,7 +7,8 @@ import type {ColumnarPredicate, ColumnarPredicateProperty} from './columnar-pred
|
|
|
7
7
|
import type {
|
|
8
8
|
TableQueryCapabilities,
|
|
9
9
|
TableQueryOperatorSupport,
|
|
10
|
-
TableQueryOptions
|
|
10
|
+
TableQueryOptions,
|
|
11
|
+
TableQueryExecutionOptions
|
|
11
12
|
} from './table-query';
|
|
12
13
|
import type {PointCloudQueryOptions} from './point-cloud-query';
|
|
13
14
|
import type {RasterQueryCapabilities} from './raster-query';
|
|
@@ -153,14 +154,10 @@ export type ScanQueryMetadataOptions = Readonly<{
|
|
|
153
154
|
}>;
|
|
154
155
|
|
|
155
156
|
/** Terminal state of one observable scan execution. */
|
|
156
|
-
export type
|
|
157
|
-
| 'completed'
|
|
158
|
-
| 'early-terminated'
|
|
159
|
-
| 'cancelled'
|
|
160
|
-
| 'failed';
|
|
157
|
+
export type TableQueryExecutionStatus = 'completed' | 'early-terminated' | 'cancelled' | 'failed';
|
|
161
158
|
|
|
162
159
|
/** Portable execution counters for one physical source in a federated scan. */
|
|
163
|
-
export type
|
|
160
|
+
export type TableQuerySourceExecutionSummary = Readonly<{
|
|
164
161
|
/** Stable registry id when the source was resolved through a DataSourceManager. */
|
|
165
162
|
sourceId?: string;
|
|
166
163
|
/** Format or adapter type reported by scan metadata. */
|
|
@@ -168,7 +165,7 @@ export type ScanSourceExecutionTelemetry = Readonly<{
|
|
|
168
165
|
/** Zero-based append position for a federated source. */
|
|
169
166
|
sourceIndex?: number;
|
|
170
167
|
/** Terminal state of this physical source iterator. */
|
|
171
|
-
status:
|
|
168
|
+
status: TableQueryExecutionStatus;
|
|
172
169
|
/** Physical files opened by this source, when measurable. */
|
|
173
170
|
filesOpened?: number;
|
|
174
171
|
/** Independently scheduled physical tasks opened by this source, when measurable. */
|
|
@@ -196,9 +193,9 @@ export type ScanSourceExecutionTelemetry = Readonly<{
|
|
|
196
193
|
}>;
|
|
197
194
|
|
|
198
195
|
/** Portable execution counters reported when a table scan terminates. */
|
|
199
|
-
export type
|
|
196
|
+
export type TableQueryExecutionSummary = Readonly<{
|
|
200
197
|
/** Terminal state distinguishing completion, early return, cancellation, and failure. */
|
|
201
|
-
status:
|
|
198
|
+
status: TableQueryExecutionStatus;
|
|
202
199
|
/** Number of physical sources included in the resolved plan. */
|
|
203
200
|
sourcesPlanned: number;
|
|
204
201
|
/** Number of physical source iterators that were opened. */
|
|
@@ -230,7 +227,7 @@ export type ScanExecutionTelemetry = Readonly<{
|
|
|
230
227
|
/** Why a successfully shortened execution stopped before exhausting its plan. */
|
|
231
228
|
earlyTerminationReason?: 'limit' | 'consumer-return';
|
|
232
229
|
/** Per-source physical counters in deterministic append order. */
|
|
233
|
-
sources?: readonly
|
|
230
|
+
sources?: readonly TableQuerySourceExecutionSummary[];
|
|
234
231
|
/** Source-specific immutable counters retained for detailed diagnostics. */
|
|
235
232
|
details?: Readonly<Record<string, unknown>>;
|
|
236
233
|
/** Failure or cancellation reason when one terminated the scan. */
|
|
@@ -238,21 +235,21 @@ export type ScanExecutionTelemetry = Readonly<{
|
|
|
238
235
|
}>;
|
|
239
236
|
|
|
240
237
|
/** Receives the immutable final counters for one table scan execution. */
|
|
241
|
-
export type
|
|
238
|
+
export type TableQueryCompleteCallback = (summary: TableQueryExecutionSummary) => void;
|
|
242
239
|
|
|
243
240
|
/**
|
|
244
|
-
* Delivers a
|
|
245
|
-
*
|
|
241
|
+
* Delivers a terminal query summary without allowing an observer failure to alter scan results.
|
|
242
|
+
* Completion observers are best-effort and must not become query failures.
|
|
246
243
|
*/
|
|
247
|
-
export function
|
|
248
|
-
callback:
|
|
249
|
-
|
|
244
|
+
export function emitQueryComplete(
|
|
245
|
+
callback: TableQueryCompleteCallback | undefined,
|
|
246
|
+
summary: TableQueryExecutionSummary
|
|
250
247
|
): void {
|
|
251
248
|
if (!callback) return;
|
|
252
249
|
try {
|
|
253
|
-
callback(
|
|
250
|
+
callback(summary);
|
|
254
251
|
} catch {
|
|
255
|
-
//
|
|
252
|
+
// Completion observers must never change query behavior.
|
|
256
253
|
}
|
|
257
254
|
}
|
|
258
255
|
|
|
@@ -268,13 +265,7 @@ export type TableScanReadOptions<
|
|
|
268
265
|
unknown,
|
|
269
266
|
ColumnarPredicateProperty
|
|
270
267
|
>
|
|
271
|
-
> = TableQueryOptions<PredicateT> &
|
|
272
|
-
Readonly<{
|
|
273
|
-
/** Cooperatively cancels source discovery and execution. */
|
|
274
|
-
signal?: AbortSignal;
|
|
275
|
-
/** Receives one terminal execution snapshot without changing query semantics. */
|
|
276
|
-
onTelemetry?: ScanExecutionTelemetryCallback;
|
|
277
|
-
}>;
|
|
268
|
+
> = TableQueryOptions<PredicateT> & TableQueryExecutionOptions;
|
|
278
269
|
|
|
279
270
|
/**
|
|
280
271
|
* Shared table-scan contract implemented by format-specific executors.
|
|
@@ -9,20 +9,61 @@ import {
|
|
|
9
9
|
type ColumnarPredicateProperty
|
|
10
10
|
} from './columnar-predicate';
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
export type
|
|
12
|
+
/** One source column selected for logical output, optionally under a new name. */
|
|
13
|
+
export type TableSelection =
|
|
14
|
+
| string
|
|
15
|
+
| Readonly<{
|
|
16
|
+
/** Source column name, resolved before aliases are applied. */
|
|
17
|
+
column: string;
|
|
18
|
+
/** Output field name. Defaults to the source column name. */
|
|
19
|
+
as?: string;
|
|
20
|
+
}>;
|
|
21
|
+
|
|
22
|
+
/** Named source, or a named table exposed by a source. Strings are literal names, not dotted paths. */
|
|
23
|
+
export type TableReference =
|
|
24
|
+
| string
|
|
25
|
+
| Readonly<{
|
|
26
|
+
/** Name of a registered data source. */
|
|
27
|
+
source: string;
|
|
28
|
+
/** Name of a table exposed by that source. */
|
|
29
|
+
table: string;
|
|
30
|
+
}>;
|
|
31
|
+
|
|
32
|
+
/** Logical query description, independent of cancellation and execution observers. */
|
|
33
|
+
export type TableQuery<
|
|
14
34
|
PredicateT extends ColumnarPredicate<unknown, ColumnarPredicateProperty> = ColumnarPredicate
|
|
15
35
|
> = Readonly<{
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/** Output columns in
|
|
19
|
-
|
|
20
|
-
/**
|
|
36
|
+
/** Optional named source or qualified table selected before planning. */
|
|
37
|
+
from?: TableReference;
|
|
38
|
+
/** Output columns in selection order. Omission selects all source columns. */
|
|
39
|
+
select?: readonly TableSelection[];
|
|
40
|
+
/** Predicate evaluated against source columns before output aliases are applied. */
|
|
41
|
+
where?: PredicateT;
|
|
42
|
+
/** Maximum number of rows retained after filtering. */
|
|
21
43
|
limit?: number;
|
|
22
|
-
|
|
44
|
+
}>;
|
|
45
|
+
|
|
46
|
+
/** Controls one execution without becoming part of the logical query. */
|
|
47
|
+
export type TableQueryExecutionOptions = Readonly<{
|
|
48
|
+
/** Cooperatively cancels source discovery and execution. */
|
|
23
49
|
signal?: AbortSignal;
|
|
50
|
+
/** Receives one terminal summary, including cancellation, failure, and early termination. */
|
|
51
|
+
onQueryComplete?: import('./scan-query-metadata').TableQueryCompleteCallback;
|
|
24
52
|
}>;
|
|
25
53
|
|
|
54
|
+
/** Immutable, backend-neutral request for a scan, filter, projection, and limit. */
|
|
55
|
+
export type TableQueryOptions<
|
|
56
|
+
PredicateT extends ColumnarPredicate<unknown, ColumnarPredicateProperty> = ColumnarPredicate
|
|
57
|
+
> = Pick<TableQueryExecutionOptions, 'signal'> &
|
|
58
|
+
Readonly<{
|
|
59
|
+
/** Portable predicate applied before projection. */
|
|
60
|
+
predicate?: PredicateT;
|
|
61
|
+
/** Output columns in caller-specified order. Defaults to every source column. */
|
|
62
|
+
columns?: readonly string[];
|
|
63
|
+
/** Maximum number of rows retained after filtering and projection. */
|
|
64
|
+
limit?: number;
|
|
65
|
+
}>;
|
|
66
|
+
|
|
26
67
|
/** Reads the minimum source columns required by the remaining table-query plan. */
|
|
27
68
|
export type TableQueryScanStep = Readonly<{
|
|
28
69
|
/** Plan discriminator. */
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {ArrowTable, ArrowTableBatch, TableBatch} from '@loaders.gl/core/schema';
|
|
6
|
-
import type {TableScanReadOptions,
|
|
7
|
-
import {
|
|
6
|
+
import type {TableScanReadOptions, TableQueryExecutionSummary} from './scan-query-metadata';
|
|
7
|
+
import {emitQueryComplete} from './scan-query-metadata';
|
|
8
8
|
import {filterColumnarRowIndices, validateColumnarPredicate} from './columnar-predicate';
|
|
9
9
|
import {validateTableQueryLimit} from './table-query';
|
|
10
10
|
|
|
@@ -16,8 +16,12 @@ export type TableScanBatchReader = (
|
|
|
16
16
|
|
|
17
17
|
/** Optional batch kernels for formats with a native vectorized predicate implementation. */
|
|
18
18
|
export type TableScanBatchOperators = Readonly<{
|
|
19
|
-
/** Applies a residual predicate
|
|
20
|
-
filter?: (
|
|
19
|
+
/** Applies a residual predicate locally or on a worker; async kernels must observe the signal. */
|
|
20
|
+
filter?: (
|
|
21
|
+
batch: TableBatch,
|
|
22
|
+
predicate: TableScanReadOptions['predicate'],
|
|
23
|
+
signal?: AbortSignal
|
|
24
|
+
) => TableBatch | Promise<TableBatch>;
|
|
21
25
|
/** Applies a projection while preserving the source batch shape. */
|
|
22
26
|
project?: (batch: TableBatch, columns?: readonly string[]) => TableBatch;
|
|
23
27
|
}>;
|
|
@@ -48,12 +52,13 @@ export async function* executeTableScanBatches(
|
|
|
48
52
|
let rowsRetained = 0;
|
|
49
53
|
let rowsReturned = 0;
|
|
50
54
|
let bytesFetched = 0;
|
|
51
|
-
let status:
|
|
52
|
-
let earlyTerminationReason:
|
|
55
|
+
let status: TableQueryExecutionSummary['status'] = 'early-terminated';
|
|
56
|
+
let earlyTerminationReason: TableQueryExecutionSummary['earlyTerminationReason'];
|
|
53
57
|
let executionError: unknown;
|
|
54
58
|
let remaining =
|
|
55
59
|
options.limit === undefined ? Number.POSITIVE_INFINITY : Math.max(0, options.limit);
|
|
56
60
|
try {
|
|
61
|
+
options.signal?.throwIfAborted();
|
|
57
62
|
if (remaining <= 0) {
|
|
58
63
|
earlyTerminationReason = 'limit';
|
|
59
64
|
return;
|
|
@@ -67,9 +72,15 @@ export async function* executeTableScanBatches(
|
|
|
67
72
|
earlyTerminationReason = 'limit';
|
|
68
73
|
return;
|
|
69
74
|
}
|
|
75
|
+
options.signal?.throwIfAborted();
|
|
70
76
|
batchesRead++;
|
|
71
77
|
rowsRead += batch.length;
|
|
72
|
-
const filteredBatch = (operators.filter || filterTableBatch)(
|
|
78
|
+
const filteredBatch = await (operators.filter || filterTableBatch)(
|
|
79
|
+
batch,
|
|
80
|
+
options.predicate,
|
|
81
|
+
options.signal
|
|
82
|
+
);
|
|
83
|
+
options.signal?.throwIfAborted();
|
|
73
84
|
if (options.predicate) {
|
|
74
85
|
rowsTested += batch.length;
|
|
75
86
|
rowsRetained += filteredBatch.length;
|
|
@@ -82,6 +93,11 @@ export async function* executeTableScanBatches(
|
|
|
82
93
|
remaining -= projectedBatch.length;
|
|
83
94
|
rowsReturned += projectedBatch.length;
|
|
84
95
|
yield projectedBatch;
|
|
96
|
+
if (remaining === 0) {
|
|
97
|
+
earlyTerminationReason = 'limit';
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
options.signal?.throwIfAborted();
|
|
85
101
|
} else {
|
|
86
102
|
const outputBatch = truncateTableBatch(projectedBatch, remaining);
|
|
87
103
|
rowsReturned += outputBatch.length;
|
|
@@ -99,8 +115,8 @@ export async function* executeTableScanBatches(
|
|
|
99
115
|
if (status === 'early-terminated' && !earlyTerminationReason) {
|
|
100
116
|
earlyTerminationReason = 'consumer-return';
|
|
101
117
|
}
|
|
102
|
-
|
|
103
|
-
options.
|
|
118
|
+
emitQueryComplete(
|
|
119
|
+
options.onQueryComplete,
|
|
104
120
|
Object.freeze({
|
|
105
121
|
status,
|
|
106
122
|
sourcesPlanned: 1,
|
|
@@ -18,6 +18,8 @@ export type DataSourceOptions = StrictLoaderOptions & {
|
|
|
18
18
|
core?: StrictLoaderOptions['core'] & {
|
|
19
19
|
/** Allows application to specify which source should be selected. Matches `Source.type`. Defaults to 'auto' */
|
|
20
20
|
type?: string;
|
|
21
|
+
/** Stable query-visible source name. Defaults to an available data or file name. */
|
|
22
|
+
name?: string;
|
|
21
23
|
/** Any dataset attributions (in case underlying metadata does not include attributions) */
|
|
22
24
|
attributions?: string[];
|
|
23
25
|
/** Removed in v5. Move these options to `core` and the root loader namespaces. */
|
|
@@ -95,6 +97,8 @@ export abstract class DataSource<DataT, OptionsT extends DataSourceOptions> {
|
|
|
95
97
|
options: Required<OptionsT & DataSourceOptions>;
|
|
96
98
|
readonly data: DataT;
|
|
97
99
|
readonly url: string;
|
|
100
|
+
/** Stable query-visible name, resolved without fetching source data. */
|
|
101
|
+
readonly name: string;
|
|
98
102
|
|
|
99
103
|
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
100
104
|
loadOptions: StrictLoaderOptions;
|
|
@@ -118,6 +122,7 @@ export abstract class DataSource<DataT, OptionsT extends DataSourceOptions> {
|
|
|
118
122
|
) as Required<OptionsT & DataSourceOptions>;
|
|
119
123
|
this.data = data;
|
|
120
124
|
this.url = typeof data === 'string' ? resolvePath(data) : '';
|
|
125
|
+
this.name = getDataSourceName(data, this.options);
|
|
121
126
|
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
122
127
|
this.loadOptions = loadOptions;
|
|
123
128
|
const fetch = getFetchFunction(loadOptions);
|
|
@@ -127,6 +132,8 @@ export abstract class DataSource<DataT, OptionsT extends DataSourceOptions> {
|
|
|
127
132
|
}
|
|
128
133
|
|
|
129
134
|
setProps(options: OptionsT) {
|
|
135
|
+
if (options.core?.name !== undefined && options.core.name !== this.name)
|
|
136
|
+
throw new Error('Data source names are fixed at creation.');
|
|
130
137
|
const mergedOptions = mergeOptions<DataSourceOptions>(this.options, options) as Required<
|
|
131
138
|
OptionsT & DataSourceOptions
|
|
132
139
|
>;
|
|
@@ -193,7 +200,7 @@ export function getSourceLoaderOptions(options: DataSourceOptions): StrictLoader
|
|
|
193
200
|
if (options?.core) {
|
|
194
201
|
loadOptions.core = {...options.core};
|
|
195
202
|
const parserCore = loadOptions.core as Record<string, unknown>;
|
|
196
|
-
for (const key of ['type', 'attributions', 'loaders', 'onError', 'loadOptions']) {
|
|
203
|
+
for (const key of ['type', 'name', 'attributions', 'loaders', 'onError', 'loadOptions']) {
|
|
197
204
|
delete parserCore[key];
|
|
198
205
|
}
|
|
199
206
|
if (Object.keys(parserCore).length === 0) {
|
|
@@ -234,3 +241,49 @@ function unavailableCoreApiMethod(methodName: keyof CoreAPI) {
|
|
|
234
241
|
);
|
|
235
242
|
};
|
|
236
243
|
}
|
|
244
|
+
|
|
245
|
+
/** Derives a stable identifier from explicit options or already available data metadata. */
|
|
246
|
+
function getDataSourceName(data: unknown, options: DataSourceOptions): string {
|
|
247
|
+
const explicitName = options.core?.name;
|
|
248
|
+
if (explicitName !== undefined) {
|
|
249
|
+
if (typeof explicitName !== 'string' || !explicitName.trim())
|
|
250
|
+
throw new Error('Data source name must be a non-empty string.');
|
|
251
|
+
return explicitName;
|
|
252
|
+
}
|
|
253
|
+
if (data && typeof data === 'object') {
|
|
254
|
+
const named = data as {
|
|
255
|
+
name?: unknown;
|
|
256
|
+
schema?: {metadata?: Map<string, unknown> | Record<string, unknown>};
|
|
257
|
+
};
|
|
258
|
+
if (typeof named.name === 'string' && named.name.trim())
|
|
259
|
+
return data instanceof Blob ? removeFileExtension(named.name) : named.name;
|
|
260
|
+
const metadata = named.schema?.metadata;
|
|
261
|
+
const embeddedName = metadata instanceof Map ? metadata.get('name') : metadata?.name;
|
|
262
|
+
if (typeof embeddedName === 'string' && embeddedName.trim()) return embeddedName;
|
|
263
|
+
}
|
|
264
|
+
if (typeof data === 'string') {
|
|
265
|
+
try {
|
|
266
|
+
const url = new URL(data.replace(/\\/g, '/'), 'https://source.invalid/');
|
|
267
|
+
if (!['data:', 'blob:'].includes(url.protocol)) {
|
|
268
|
+
let basename = url.pathname.split('/').filter(Boolean).pop();
|
|
269
|
+
if (basename) {
|
|
270
|
+
try {
|
|
271
|
+
basename = decodeURIComponent(basename);
|
|
272
|
+
} catch {
|
|
273
|
+
/* Keep malformed encoded names literal. */
|
|
274
|
+
}
|
|
275
|
+
return removeFileExtension(basename);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
} catch {
|
|
279
|
+
/* Invalid URLs still receive a source-type fallback name. */
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return options.core?.type && options.core.type !== 'auto' ? options.core.type : 'source';
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** Removes a filename suffix without erasing a hidden filename. */
|
|
286
|
+
function removeFileExtension(name: string): string {
|
|
287
|
+
const extension = name.lastIndexOf('.');
|
|
288
|
+
return extension > 0 ? name.slice(0, extension) : name;
|
|
289
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {ArrowTable, Schema} from '@loaders.gl/core/schema';
|
|
6
|
+
import type {TableScanSource} from '../scan-utils/scan-query-metadata';
|
|
7
|
+
|
|
8
|
+
/** Source exposing named tables. Returned handles remain owned by the source or caller. */
|
|
9
|
+
export interface TableSourceCollection {
|
|
10
|
+
/** Resolves one table without loading unrelated tables. */
|
|
11
|
+
getTable(
|
|
12
|
+
name: string,
|
|
13
|
+
options?: {signal?: AbortSignal}
|
|
14
|
+
): ArrowTable | TableScanSource | Promise<ArrowTable | TableScanSource>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Metadata for one named table without reading its result rows. */
|
|
18
|
+
export type TableMetadata = Readonly<{
|
|
19
|
+
/** Unique loaded table name within its parent source. */
|
|
20
|
+
name: string;
|
|
21
|
+
/** Already available schema; table listings may omit it for lazy discovery. */
|
|
22
|
+
schema?: Schema;
|
|
23
|
+
/** Whether the source exposes this table through the common query contract. */
|
|
24
|
+
queryable?: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
|
|
27
|
+
/** Metadata-only discovery implemented by sources exposing multiple tables. */
|
|
28
|
+
export interface TableDiscoverySource {
|
|
29
|
+
/** Lists table names without opening their row readers. */
|
|
30
|
+
getTablesMetadata(options?: {
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
}): readonly TableMetadata[] | Promise<readonly TableMetadata[]>;
|
|
33
|
+
/** Discovers one table schema without materializing its rows. */
|
|
34
|
+
getTableMetadata?(
|
|
35
|
+
name: string,
|
|
36
|
+
options?: {signal?: AbortSignal}
|
|
37
|
+
): TableMetadata | Promise<TableMetadata>;
|
|
38
|
+
}
|