@luma.gl/graph 10.0.0-alpha.5 → 10.0.0-alpha.6
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/LICENSE +38 -0
- package/README.md +7 -1
- package/dist/arrow/dggs/dggs-gpu-polygons.cjs +667 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.d.ts +75 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.d.ts.map +1 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.js +651 -0
- package/dist/arrow/dggs/dggs-gpu-polygons.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.cjs +411 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts +31 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.d.ts.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js +395 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-adapter.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.cjs +304 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts +32 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.d.ts.map +1 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js +293 -0
- package/dist/arrow/geoarrow/arrow-geoarrow-conversion.js.map +1 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.cjs +232 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.d.ts +54 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.d.ts.map +1 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js +222 -0
- package/dist/arrow/geoarrow/arrow-polygon-tessellation.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.cjs +314 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +42 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +318 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +204 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +30 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +195 -0
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.cjs +257 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.d.ts +45 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.js +257 -0
- package/dist/arrow/gpu/arrow-gpu-table-adapters.js.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +230 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +71 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +215 -0
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -0
- package/dist/arrow/gpu/arrow-input-schema.cjs +36 -0
- package/dist/arrow/gpu/arrow-input-schema.d.ts +41 -0
- package/dist/arrow/gpu/arrow-input-schema.d.ts.map +1 -0
- package/dist/arrow/gpu/arrow-input-schema.js +17 -0
- package/dist/arrow/gpu/arrow-input-schema.js.map +1 -0
- package/dist/arrow/index.cjs +90 -0
- package/dist/arrow/index.cjs.map +6 -0
- package/dist/arrow/index.d.ts +9 -0
- package/dist/arrow/index.d.ts.map +1 -0
- package/dist/arrow/index.js +12 -0
- package/dist/arrow/index.js.map +1 -0
- package/dist/arrow/internal.cjs +30 -0
- package/dist/arrow/internal.cjs.map +6 -0
- package/dist/arrow/internal.d.ts +19 -0
- package/dist/arrow/internal.d.ts.map +1 -0
- package/dist/arrow/internal.js +7 -0
- package/dist/arrow/internal.js.map +1 -0
- package/dist/dist.dev.js +283 -12
- package/dist/dist.min.js +29 -29
- package/dist/geospatial/geospatial-utils.cjs +12 -11
- package/dist/geospatial/geospatial-utils.d.ts +1 -1
- package/dist/geospatial/geospatial-utils.d.ts.map +1 -1
- package/dist/geospatial/geospatial-utils.js +3 -2
- package/dist/geospatial/geospatial-utils.js.map +1 -1
- package/dist/geospatial/index.cjs.map +2 -2
- package/dist/gpu-a5/index.cjs.map +1 -1
- package/dist/gpu-dggs/benchmarks.cjs.map +1 -1
- package/dist/gpu-dggs/gpu-dggs-cell-projection.cjs +2 -2
- package/dist/gpu-dggs/gpu-dggs-cell-projection.js +1 -1
- package/dist/gpu-dggs/gpu-dggs-cell-projection.js.map +1 -1
- package/dist/gpu-dggs/index.cjs.map +1 -1
- package/dist/gpu-h3/index.cjs.map +1 -1
- package/dist/gpu-project/benchmarks.cjs.map +2 -2
- package/dist/gpu-project/crs.cjs.map +2 -2
- package/dist/gpu-project/index.cjs.map +2 -2
- package/dist/gpu-project/projection-program.cjs +2 -2
- package/dist/gpu-project/projection-program.d.ts +1 -1
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -1
- package/dist/gpu-project/projection-program.js.map +1 -1
- package/dist/gpu-sql/lu-sql.d.ts +1 -1
- package/dist/gpu-sql/lu-sql.js +1 -1
- package/dist/gpu-tables/engine/gpu-table-shader-bindings.d.ts +1 -1
- package/dist/gpu-tables/engine/gpu-table-shader-bindings.d.ts.map +1 -1
- package/dist/gpu-vector-search/index.cjs.map +1 -1
- package/dist/utils/assemble-compute-kernel.cjs +2 -2
- package/dist/utils/assemble-compute-kernel.d.ts +2 -1
- package/dist/utils/assemble-compute-kernel.d.ts.map +1 -1
- package/dist/utils/assemble-compute-kernel.js +2 -2
- package/dist/utils/assemble-compute-kernel.js.map +1 -1
- package/package.json +19 -7
- package/src/arrow/dggs/dggs-gpu-polygons.ts +820 -0
- package/src/arrow/geoarrow/arrow-geoarrow-adapter.ts +519 -0
- package/src/arrow/geoarrow/arrow-geoarrow-conversion.ts +415 -0
- package/src/arrow/geoarrow/arrow-polygon-tessellation.ts +369 -0
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +474 -0
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +294 -0
- package/src/arrow/gpu/arrow-gpu-table-adapters.ts +378 -0
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +324 -0
- package/src/arrow/gpu/arrow-input-schema.ts +98 -0
- package/src/arrow/index.ts +79 -0
- package/src/arrow/internal.ts +23 -0
- package/src/geospatial/geospatial-utils.ts +3 -7
- package/src/gpu-dggs/gpu-dggs-cell-projection.ts +1 -1
- package/src/gpu-project/projection-program.ts +1 -1
- package/src/gpu-sql/lu-sql.ts +1 -1
- package/src/gpu-tables/engine/gpu-table-shader-bindings.ts +1 -1
- package/src/utils/assemble-compute-kernel.ts +3 -7
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {type Device} from '@luma.gl/core';
|
|
6
|
+
import {GPUVector} from '@luma.gl/gpgpu/gpu-data';
|
|
7
|
+
import {GPURecordBatch, GPUTable, type GPUField} from '@luma.gl/graph/gpu-tables';
|
|
8
|
+
import {RecordBatch, Table} from 'apache-arrow';
|
|
9
|
+
import {getArrowFieldByPath} from '@luma.gl/gpgpu/_internal/arrow';
|
|
10
|
+
import {getArrowVectorByPath} from '@luma.gl/gpgpu/arrow';
|
|
11
|
+
import {getArrowTemporalVectorInfo, TEMPORAL_ORIGIN_METADATA_KEY} from '@luma.gl/gpgpu/arrow';
|
|
12
|
+
import {
|
|
13
|
+
ArrowGPUConversionCost,
|
|
14
|
+
ArrowGPUConversionOptions,
|
|
15
|
+
ArrowGPUConversionPlan,
|
|
16
|
+
PreparedArrowGPUVector,
|
|
17
|
+
planArrowGPUConversion,
|
|
18
|
+
convertArrowToGPUVector
|
|
19
|
+
} from '@luma.gl/gpgpu/arrow';
|
|
20
|
+
|
|
21
|
+
/** One named source-to-target mapping in an Arrow table conversion schema. */
|
|
22
|
+
export type ArrowGPUTableConversionColumn = ArrowGPUConversionOptions & {
|
|
23
|
+
/** Prepared GPU column name. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Source Arrow field path. Defaults to `name`. */
|
|
26
|
+
source?: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Schema-driven selection and lowering contract for one Arrow table. */
|
|
30
|
+
export type ArrowGPUTableConversionSchema = {
|
|
31
|
+
/** Ordered selected output columns. */
|
|
32
|
+
columns: readonly ArrowGPUTableConversionColumn[];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Plan for every selected column in one Arrow table. */
|
|
36
|
+
export type ArrowGPUTableConversionPlan = {
|
|
37
|
+
/** Ordered column plans with resolved source paths. */
|
|
38
|
+
columns: readonly {
|
|
39
|
+
name: string;
|
|
40
|
+
source: string;
|
|
41
|
+
plan: ArrowGPUConversionPlan;
|
|
42
|
+
}[];
|
|
43
|
+
/** Source rows shared by every selected column. */
|
|
44
|
+
length: number;
|
|
45
|
+
/** Aggregate cost across selected columns. */
|
|
46
|
+
cost: ArrowGPUConversionCost;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Prepared generic GPU table plus its inspectable conversion plan. */
|
|
50
|
+
export type PreparedArrowGPUTable = {
|
|
51
|
+
/** Prepared generic GPU table. */
|
|
52
|
+
table: GPUTable;
|
|
53
|
+
/** Prepared vectors keyed by output column name. */
|
|
54
|
+
vectors: Readonly<Record<string, GPUVector>>;
|
|
55
|
+
/** Plan used to prepare the table. */
|
|
56
|
+
plan: ArrowGPUTableConversionPlan;
|
|
57
|
+
/** Releases table-owned GPU data exactly once. */
|
|
58
|
+
destroy: () => void;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Iterable Arrow record-batch source accepted by streaming conversion. */
|
|
62
|
+
export type ArrowRecordBatchConversionSource = Iterable<RecordBatch> | AsyncIterable<RecordBatch>;
|
|
63
|
+
|
|
64
|
+
/** One independently owned GPU record batch produced from an Arrow stream. */
|
|
65
|
+
export type PreparedArrowGPURecordBatch = {
|
|
66
|
+
/** Prepared batch. */
|
|
67
|
+
batch: GPURecordBatch;
|
|
68
|
+
/** Prepared batch-local vectors keyed by output name. */
|
|
69
|
+
vectors: Readonly<Record<string, GPUVector>>;
|
|
70
|
+
/** Plan used for this batch. */
|
|
71
|
+
plan: ArrowGPUTableConversionPlan;
|
|
72
|
+
/** Releases batch-owned GPU data exactly once. */
|
|
73
|
+
destroy: () => void;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/** Plans every selected column in an Arrow table using one explicit output schema. */
|
|
77
|
+
export function planArrowTableGPUConversion(
|
|
78
|
+
device: Device,
|
|
79
|
+
table: Table,
|
|
80
|
+
schema: ArrowGPUTableConversionSchema
|
|
81
|
+
): ArrowGPUTableConversionPlan {
|
|
82
|
+
validateTableConversionSchema(schema);
|
|
83
|
+
const columns = schema.columns.map(column => {
|
|
84
|
+
const sourcePath = column.source ?? column.name;
|
|
85
|
+
const sourceVector = getArrowVectorByPath(table, sourcePath);
|
|
86
|
+
const sourceField = getArrowFieldByPath(table, sourcePath);
|
|
87
|
+
return {
|
|
88
|
+
name: column.name,
|
|
89
|
+
source: sourcePath,
|
|
90
|
+
plan: planArrowGPUConversion(device, sourceVector, {
|
|
91
|
+
...column,
|
|
92
|
+
name: column.name,
|
|
93
|
+
field: column.field ?? sourceField
|
|
94
|
+
})
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
columns,
|
|
99
|
+
length: table.numRows,
|
|
100
|
+
cost: sumConversionCosts(columns.map(column => column.plan.cost))
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Converts selected Arrow table columns into a batch-preserving generic GPU table. */
|
|
105
|
+
export async function convertArrowTableToGPUTable(
|
|
106
|
+
device: Device,
|
|
107
|
+
table: Table,
|
|
108
|
+
schema: ArrowGPUTableConversionSchema
|
|
109
|
+
): Promise<PreparedArrowGPUTable> {
|
|
110
|
+
const plan = planArrowTableGPUConversion(device, table, schema);
|
|
111
|
+
const preparedColumns: PreparedArrowGPUVector[] = [];
|
|
112
|
+
try {
|
|
113
|
+
for (const column of schema.columns) {
|
|
114
|
+
const sourcePath = column.source ?? column.name;
|
|
115
|
+
const sourceVector = getArrowVectorByPath(table, sourcePath);
|
|
116
|
+
const sourceField = getArrowFieldByPath(table, sourcePath);
|
|
117
|
+
preparedColumns.push(
|
|
118
|
+
await convertArrowToGPUVector(device, sourceVector, {
|
|
119
|
+
...column,
|
|
120
|
+
name: column.name,
|
|
121
|
+
field: column.field ?? sourceField
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
validatePreparedTableColumns(preparedColumns, table.numRows);
|
|
126
|
+
const vectors = Object.fromEntries(
|
|
127
|
+
schema.columns.map((column, index) => [column.name, preparedColumns[index].vector])
|
|
128
|
+
);
|
|
129
|
+
const fields = schema.columns.map((column, index): GPUField => {
|
|
130
|
+
const sourcePath = column.source ?? column.name;
|
|
131
|
+
const sourceField = getArrowFieldByPath(table, sourcePath);
|
|
132
|
+
const preparedField = preparedColumns[index].field;
|
|
133
|
+
return {
|
|
134
|
+
name: column.name,
|
|
135
|
+
format: preparedColumns[index].vector.format,
|
|
136
|
+
nullable: sourceField.nullable,
|
|
137
|
+
metadata: new Map(preparedField?.metadata ?? sourceField.metadata)
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
const gpuBatches = table.batches.map((batch, batchIndex) => {
|
|
141
|
+
const gpuData = Object.fromEntries(
|
|
142
|
+
schema.columns.map((column, columnIndex) => [
|
|
143
|
+
column.name,
|
|
144
|
+
preparedColumns[columnIndex].vector.data[batchIndex]
|
|
145
|
+
])
|
|
146
|
+
);
|
|
147
|
+
return new GPURecordBatch({
|
|
148
|
+
gpuData,
|
|
149
|
+
fields,
|
|
150
|
+
metadata: new Map(batch.schema.metadata),
|
|
151
|
+
numRows: batch.numRows,
|
|
152
|
+
nullCount: batch.nullCount,
|
|
153
|
+
sourceInfo: {
|
|
154
|
+
sourceBatchIndex: batchIndex,
|
|
155
|
+
sourceRowIndexOffset: table.batches
|
|
156
|
+
.slice(0, batchIndex)
|
|
157
|
+
.reduce((rowCount, sourceBatch) => rowCount + sourceBatch.numRows, 0),
|
|
158
|
+
sourceRowCount: batch.numRows
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
const gpuTable = new GPUTable({batches: gpuBatches});
|
|
163
|
+
let destroyed = false;
|
|
164
|
+
return {
|
|
165
|
+
table: gpuTable,
|
|
166
|
+
vectors,
|
|
167
|
+
plan,
|
|
168
|
+
destroy: () => {
|
|
169
|
+
if (destroyed) return;
|
|
170
|
+
destroyed = true;
|
|
171
|
+
gpuTable.destroy();
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
} catch (error) {
|
|
175
|
+
for (const prepared of preparedColumns) prepared.destroy();
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/** Converts one Arrow record batch without combining it with earlier or later batches. */
|
|
181
|
+
export async function convertArrowRecordBatchToGPURecordBatch(
|
|
182
|
+
device: Device,
|
|
183
|
+
recordBatch: RecordBatch,
|
|
184
|
+
schema: ArrowGPUTableConversionSchema,
|
|
185
|
+
options: {sourceBatchIndex?: number; sourceRowIndexOffset?: number} = {}
|
|
186
|
+
): Promise<PreparedArrowGPURecordBatch> {
|
|
187
|
+
const preparedTable = await convertArrowTableToGPUTable(device, new Table([recordBatch]), schema);
|
|
188
|
+
const [batch] = preparedTable.table.detachBatches();
|
|
189
|
+
if (!batch) {
|
|
190
|
+
preparedTable.destroy();
|
|
191
|
+
throw new Error('Arrow record-batch conversion did not produce a GPU batch');
|
|
192
|
+
}
|
|
193
|
+
Object.assign(batch.sourceInfo!, {
|
|
194
|
+
sourceBatchIndex: options.sourceBatchIndex ?? 0,
|
|
195
|
+
sourceRowIndexOffset: options.sourceRowIndexOffset ?? 0,
|
|
196
|
+
sourceRowCount: recordBatch.numRows
|
|
197
|
+
});
|
|
198
|
+
let destroyed = false;
|
|
199
|
+
return {
|
|
200
|
+
batch,
|
|
201
|
+
vectors: preparedTable.vectors,
|
|
202
|
+
plan: preparedTable.plan,
|
|
203
|
+
destroy: () => {
|
|
204
|
+
if (destroyed) return;
|
|
205
|
+
destroyed = true;
|
|
206
|
+
batch.destroy();
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Converts an Arrow record-batch stream incrementally while preserving batch ownership.
|
|
213
|
+
*
|
|
214
|
+
* Temporal columns reuse the first prepared origin in later batches unless the schema supplies an
|
|
215
|
+
* explicit origin. Consumers own each yielded batch and should destroy it after use.
|
|
216
|
+
*/
|
|
217
|
+
export async function* convertArrowRecordBatchesToGPURecordBatches(
|
|
218
|
+
device: Device,
|
|
219
|
+
source: ArrowRecordBatchConversionSource,
|
|
220
|
+
schema: ArrowGPUTableConversionSchema
|
|
221
|
+
): AsyncGenerator<PreparedArrowGPURecordBatch> {
|
|
222
|
+
const temporalOrigins = new Map<string, number | bigint>();
|
|
223
|
+
let sourceBatchIndex = 0;
|
|
224
|
+
let sourceRowIndexOffset = 0;
|
|
225
|
+
for await (const recordBatch of source) {
|
|
226
|
+
const batchSchema: ArrowGPUTableConversionSchema = {
|
|
227
|
+
columns: schema.columns.map(column => {
|
|
228
|
+
const origin = temporalOrigins.get(column.name);
|
|
229
|
+
return origin === undefined || column.temporal?.origin !== undefined
|
|
230
|
+
? column
|
|
231
|
+
: {...column, temporal: {...column.temporal, origin}};
|
|
232
|
+
})
|
|
233
|
+
};
|
|
234
|
+
const prepared = await convertArrowRecordBatchToGPURecordBatch(
|
|
235
|
+
device,
|
|
236
|
+
recordBatch,
|
|
237
|
+
batchSchema,
|
|
238
|
+
{sourceBatchIndex, sourceRowIndexOffset}
|
|
239
|
+
);
|
|
240
|
+
captureStreamingTemporalOrigins(recordBatch, schema, prepared.batch, temporalOrigins);
|
|
241
|
+
yield prepared;
|
|
242
|
+
sourceRowIndexOffset += recordBatch.numRows;
|
|
243
|
+
sourceBatchIndex++;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function validateTableConversionSchema(schema: ArrowGPUTableConversionSchema): void {
|
|
248
|
+
if (schema.columns.length === 0) {
|
|
249
|
+
throw new Error('Arrow GPU table conversion schema requires at least one column');
|
|
250
|
+
}
|
|
251
|
+
const names = new Set<string>();
|
|
252
|
+
for (const column of schema.columns) {
|
|
253
|
+
if (!column.name || names.has(column.name)) {
|
|
254
|
+
throw new Error(`Arrow GPU table conversion requires unique non-empty column names`);
|
|
255
|
+
}
|
|
256
|
+
names.add(column.name);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function validatePreparedTableColumns(
|
|
261
|
+
preparedColumns: readonly PreparedArrowGPUVector[],
|
|
262
|
+
rowCount: number
|
|
263
|
+
): void {
|
|
264
|
+
const first = preparedColumns[0];
|
|
265
|
+
if (!first) throw new Error('Arrow GPU table conversion produced no columns');
|
|
266
|
+
const chunkCount = first.vector.data.length;
|
|
267
|
+
const chunkLengths = first.vector.data.map(data => data.length);
|
|
268
|
+
for (const prepared of preparedColumns) {
|
|
269
|
+
if (prepared.vector.length !== rowCount) {
|
|
270
|
+
throw new Error('Arrow GPU table conversion requires source-aligned row counts');
|
|
271
|
+
}
|
|
272
|
+
if (
|
|
273
|
+
prepared.vector.data.length !== chunkCount ||
|
|
274
|
+
prepared.vector.data.some((data, index) => data.length !== chunkLengths[index])
|
|
275
|
+
) {
|
|
276
|
+
throw new Error('Arrow GPU table conversion requires preserved, aligned chunk boundaries');
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function captureStreamingTemporalOrigins(
|
|
282
|
+
recordBatch: RecordBatch,
|
|
283
|
+
schema: ArrowGPUTableConversionSchema,
|
|
284
|
+
gpuBatch: GPURecordBatch,
|
|
285
|
+
temporalOrigins: Map<string, number | bigint>
|
|
286
|
+
): void {
|
|
287
|
+
for (const column of schema.columns) {
|
|
288
|
+
if (column.temporal?.origin !== undefined || temporalOrigins.has(column.name)) continue;
|
|
289
|
+
const sourcePath = column.source ?? column.name;
|
|
290
|
+
const sourceVector = getArrowVectorByPath(recordBatch, sourcePath);
|
|
291
|
+
const sourceField = getArrowFieldByPath(recordBatch, sourcePath);
|
|
292
|
+
const temporalInfo = getArrowTemporalVectorInfo(sourceVector, column.field ?? sourceField);
|
|
293
|
+
if (!temporalInfo) continue;
|
|
294
|
+
const outputField = gpuBatch.schema.fields.find(field => field.name === column.name);
|
|
295
|
+
const origin = outputField?.metadata?.get(TEMPORAL_ORIGIN_METADATA_KEY);
|
|
296
|
+
if (origin !== undefined) {
|
|
297
|
+
temporalOrigins.set(
|
|
298
|
+
column.name,
|
|
299
|
+
temporalInfo.bitWidth === 64 ? BigInt(origin) : Number(origin)
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function sumConversionCosts(costs: readonly ArrowGPUConversionCost[]): ArrowGPUConversionCost {
|
|
306
|
+
return costs.reduce<ArrowGPUConversionCost>(
|
|
307
|
+
(sum, cost) => ({
|
|
308
|
+
sourceByteLength: sum.sourceByteLength + cost.sourceByteLength,
|
|
309
|
+
targetByteLength: sum.targetByteLength + cost.targetByteLength,
|
|
310
|
+
uploadCount: sum.uploadCount + cost.uploadCount,
|
|
311
|
+
cpuPassCount: sum.cpuPassCount + cost.cpuPassCount,
|
|
312
|
+
gpuPassCount: sum.gpuPassCount + cost.gpuPassCount,
|
|
313
|
+
allocatesGPUStorage: sum.allocatesGPUStorage || cost.allocatesGPUStorage
|
|
314
|
+
}),
|
|
315
|
+
{
|
|
316
|
+
sourceByteLength: 0,
|
|
317
|
+
targetByteLength: 0,
|
|
318
|
+
uploadCount: 0,
|
|
319
|
+
cpuPassCount: 0,
|
|
320
|
+
gpuPassCount: 0,
|
|
321
|
+
allocatesGPUStorage: false
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import type {Device} from '@luma.gl/core';
|
|
6
|
+
import {
|
|
7
|
+
validateGPUInputVectors,
|
|
8
|
+
type GPUInputSchema,
|
|
9
|
+
type GPUInputVectors
|
|
10
|
+
} from '@luma.gl/graph/gpu-tables';
|
|
11
|
+
import type {RecordBatch, Table} from 'apache-arrow';
|
|
12
|
+
|
|
13
|
+
/** Arrow table-like source accepted by generic Arrow input schemas. */
|
|
14
|
+
export type ArrowInputSourceData = Table | RecordBatch;
|
|
15
|
+
|
|
16
|
+
/** Source data and selectors passed to an Arrow input schema resolver. */
|
|
17
|
+
export type ArrowInputResolveProps<
|
|
18
|
+
SelectorsT = Record<string, unknown>,
|
|
19
|
+
SourceDataT extends ArrowInputSourceData = ArrowInputSourceData
|
|
20
|
+
> = {
|
|
21
|
+
/** Optional Arrow table or record batch containing source columns. */
|
|
22
|
+
data?: SourceDataT | null;
|
|
23
|
+
/** Optional adapter-owned source column selectors. */
|
|
24
|
+
selectors?: SelectorsT;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Arrow-owned adapter contract for preparing one GPU input schema.
|
|
29
|
+
*
|
|
30
|
+
* `GPUInputSchema` stays Arrow-free and validates the final prepared vectors.
|
|
31
|
+
* `ArrowInputSchema` owns source-column resolution and conversion policy, including
|
|
32
|
+
* multi-column normalization and generation of internal GPU inputs.
|
|
33
|
+
*/
|
|
34
|
+
export type ArrowInputSchema<
|
|
35
|
+
SourceVectorsT,
|
|
36
|
+
PreparedInputT,
|
|
37
|
+
SelectorsT = Record<string, unknown>,
|
|
38
|
+
ConversionOptionsT = void,
|
|
39
|
+
SourceDataT extends ArrowInputSourceData = ArrowInputSourceData
|
|
40
|
+
> = {
|
|
41
|
+
/** Error label used when final prepared vectors fail GPU input validation. */
|
|
42
|
+
name: string;
|
|
43
|
+
/** Arrow-free final GPU vector contract accepted by the consumer. */
|
|
44
|
+
gpuInputSchema: GPUInputSchema;
|
|
45
|
+
/** Resolves raw Arrow columns or direct vectors before conversion. */
|
|
46
|
+
resolveSourceVectors: (props: ArrowInputResolveProps<SelectorsT, SourceDataT>) => SourceVectorsT;
|
|
47
|
+
/** Converts resolved Arrow vectors and generates any internal GPU inputs. */
|
|
48
|
+
convertToGPUVectors: (
|
|
49
|
+
device: Device,
|
|
50
|
+
sourceVectors: SourceVectorsT,
|
|
51
|
+
options?: ConversionOptionsT
|
|
52
|
+
) => PreparedInputT | Promise<PreparedInputT>;
|
|
53
|
+
/** Extracts final GPU vectors from the converter's prepared result for validation. */
|
|
54
|
+
getGPUInputVectors: (preparedInput: PreparedInputT) => GPUInputVectors;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/** Options for resolving, converting, and validating one Arrow input schema. */
|
|
58
|
+
export type PrepareArrowInputProps<
|
|
59
|
+
SelectorsT = Record<string, unknown>,
|
|
60
|
+
ConversionOptionsT = void,
|
|
61
|
+
SourceDataT extends ArrowInputSourceData = ArrowInputSourceData
|
|
62
|
+
> = ArrowInputResolveProps<SelectorsT, SourceDataT> & {
|
|
63
|
+
/** Adapter-owned conversion options forwarded after source resolution. */
|
|
64
|
+
options?: ConversionOptionsT;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Resolves Arrow source columns, converts them to GPU inputs, and validates the final vectors.
|
|
69
|
+
*/
|
|
70
|
+
export async function prepareArrowInput<
|
|
71
|
+
SourceVectorsT,
|
|
72
|
+
PreparedInputT,
|
|
73
|
+
SelectorsT = Record<string, unknown>,
|
|
74
|
+
ConversionOptionsT = void,
|
|
75
|
+
SourceDataT extends ArrowInputSourceData = ArrowInputSourceData
|
|
76
|
+
>(
|
|
77
|
+
device: Device,
|
|
78
|
+
schema: ArrowInputSchema<
|
|
79
|
+
SourceVectorsT,
|
|
80
|
+
PreparedInputT,
|
|
81
|
+
SelectorsT,
|
|
82
|
+
ConversionOptionsT,
|
|
83
|
+
SourceDataT
|
|
84
|
+
>,
|
|
85
|
+
props: PrepareArrowInputProps<SelectorsT, ConversionOptionsT, SourceDataT>
|
|
86
|
+
): Promise<PreparedInputT> {
|
|
87
|
+
const sourceVectors = schema.resolveSourceVectors({
|
|
88
|
+
data: props.data,
|
|
89
|
+
selectors: props.selectors
|
|
90
|
+
});
|
|
91
|
+
const preparedInput = await schema.convertToGPUVectors(device, sourceVectors, props.options);
|
|
92
|
+
validateGPUInputVectors(
|
|
93
|
+
schema.name,
|
|
94
|
+
schema.gpuInputSchema,
|
|
95
|
+
schema.getGPUInputVectors(preparedInput)
|
|
96
|
+
);
|
|
97
|
+
return preparedInput;
|
|
98
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
prepareArrowInput,
|
|
7
|
+
type ArrowInputResolveProps,
|
|
8
|
+
type ArrowInputSchema,
|
|
9
|
+
type ArrowInputSourceData,
|
|
10
|
+
type PrepareArrowInputProps
|
|
11
|
+
} from './gpu/arrow-input-schema';
|
|
12
|
+
export {
|
|
13
|
+
makeGPUAnalyticsTableFromArrowTable,
|
|
14
|
+
type GPUAnalyticsDictionary,
|
|
15
|
+
type GPUAnalyticsTableFromArrowTableProps,
|
|
16
|
+
type GPUAnalyticsTableFromArrowTableResult,
|
|
17
|
+
type GPUAnalyticsTypeMapForArrow
|
|
18
|
+
} from './gpu/arrow-gpu-analytics-adapters';
|
|
19
|
+
export {
|
|
20
|
+
makeArrowTableFromGPUAnalyticsTable,
|
|
21
|
+
type ArrowTableFromGPUAnalyticsTableProps
|
|
22
|
+
} from './gpu/arrow-gpu-analytics-readback';
|
|
23
|
+
export {
|
|
24
|
+
convertArrowRecordBatchToGPURecordBatch,
|
|
25
|
+
convertArrowRecordBatchesToGPURecordBatches,
|
|
26
|
+
convertArrowTableToGPUTable,
|
|
27
|
+
planArrowTableGPUConversion,
|
|
28
|
+
type ArrowRecordBatchConversionSource,
|
|
29
|
+
type ArrowGPUTableConversionColumn,
|
|
30
|
+
type ArrowGPUTableConversionPlan,
|
|
31
|
+
type ArrowGPUTableConversionSchema,
|
|
32
|
+
type PreparedArrowGPURecordBatch,
|
|
33
|
+
type PreparedArrowGPUTable
|
|
34
|
+
} from './gpu/arrow-gpu-table-conversion';
|
|
35
|
+
export {
|
|
36
|
+
makeGPURecordBatchFromArrowRecordBatch,
|
|
37
|
+
makeGPUTableFromArrowTable,
|
|
38
|
+
type ArrowGPUValidityColumn,
|
|
39
|
+
type GPURecordBatchFromArrowRecordBatchProps,
|
|
40
|
+
type GPUTableFromArrowTableProps
|
|
41
|
+
} from './gpu/arrow-gpu-table-adapters';
|
|
42
|
+
export {
|
|
43
|
+
convertGeoArrowTableToDenseUnion,
|
|
44
|
+
convertGeoArrowTableToInterleaved,
|
|
45
|
+
convertGeoArrowTableToInterleavedAsync,
|
|
46
|
+
convertGeoArrowVectorToDenseUnion,
|
|
47
|
+
convertGeoArrowVectorToInterleaved,
|
|
48
|
+
type GeoArrowDenseUnionTableOptions,
|
|
49
|
+
type GeoArrowDenseUnionVectorOptions,
|
|
50
|
+
type GeoArrowInterleaveOptions,
|
|
51
|
+
type GeoArrowNativeEncoding,
|
|
52
|
+
type GeoArrowSerializedEncoding
|
|
53
|
+
} from './geoarrow/arrow-geoarrow-conversion';
|
|
54
|
+
export {
|
|
55
|
+
inferGeoArrowCoordinateLayoutFromArrowType,
|
|
56
|
+
inferGeoArrowDimensionFromArrowType,
|
|
57
|
+
inferGeoArrowEncodingFromArrowType,
|
|
58
|
+
makeArrowVectorFromGeoArrowColumn,
|
|
59
|
+
makeGeoArrowColumnFromArrowVector,
|
|
60
|
+
iterateGeoArrowBatchesFromArrowVector,
|
|
61
|
+
getGeoArrowRowViewFromArrowVector,
|
|
62
|
+
type MakeGeoArrowColumnFromArrowVectorOptions
|
|
63
|
+
} from './geoarrow/arrow-geoarrow-adapter';
|
|
64
|
+
export {
|
|
65
|
+
getDggsUint64Words,
|
|
66
|
+
packDggsA5CellKey,
|
|
67
|
+
packDggsGeohashKey,
|
|
68
|
+
packDggsH3CellKey,
|
|
69
|
+
packDggsQuadkeyKey,
|
|
70
|
+
packDggsS2CellKey,
|
|
71
|
+
convertDggsCellIdsToGPUKeys,
|
|
72
|
+
convertDggsCellKeysToGPUPaths,
|
|
73
|
+
type DggsCellEncoding,
|
|
74
|
+
type DggsCellKeyGPUVectorOptions,
|
|
75
|
+
type DggsCellPathCoordinateFormat,
|
|
76
|
+
type DggsCellPathGPUVectorOptions,
|
|
77
|
+
type PreparedDggsCellKeyGPUVector,
|
|
78
|
+
type PreparedDggsCellPathGPUVector
|
|
79
|
+
} from './dggs/dggs-gpu-polygons';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
// Shared adapter implementation details; use the public /arrow entry for applications.
|
|
6
|
+
export {tesselateAsync} from './geoarrow/arrow-polygon-tessellation';
|
|
7
|
+
export {tessellateArrowPolygons} from './geoarrow/arrow-polygon-tessellation';
|
|
8
|
+
export type {ArrowPolygonSourceVectors} from './geoarrow/arrow-polygon-tessellation';
|
|
9
|
+
export type {ArrowPolygonTessellationOptions} from './geoarrow/arrow-polygon-tessellation';
|
|
10
|
+
export type {ArrowPolygonTessellationResult} from './geoarrow/arrow-polygon-tessellation';
|
|
11
|
+
export type {ArrowGeoArrowGeometryType} from './geoarrow/arrow-polygon-tessellation';
|
|
12
|
+
export type {ArrowMultiPolygonType} from './geoarrow/arrow-polygon-tessellation';
|
|
13
|
+
export type {ArrowMultiPolygonVertexColorType} from './geoarrow/arrow-polygon-tessellation';
|
|
14
|
+
export type {ArrowPolygonColorType} from './geoarrow/arrow-polygon-tessellation';
|
|
15
|
+
export type {ArrowPolygonCoordinateType} from './geoarrow/arrow-polygon-tessellation';
|
|
16
|
+
export type {ArrowPolygonInputCoordinateType} from './geoarrow/arrow-polygon-tessellation';
|
|
17
|
+
export type {ArrowPolygonInputType} from './geoarrow/arrow-polygon-tessellation';
|
|
18
|
+
export type {ArrowPolygonRowColorType} from './geoarrow/arrow-polygon-tessellation';
|
|
19
|
+
export type {ArrowSeparatedPolygonCoordinateType} from './geoarrow/arrow-polygon-tessellation';
|
|
20
|
+
export type {ArrowPolygonType} from './geoarrow/arrow-polygon-tessellation';
|
|
21
|
+
export type {ArrowPolygonVertexColorType} from './geoarrow/arrow-polygon-tessellation';
|
|
22
|
+
export type {ArrowTessellatedPolygonType} from './geoarrow/arrow-polygon-tessellation';
|
|
23
|
+
export type {ArrowTessellatedPolygonVertexColorType} from './geoarrow/arrow-polygon-tessellation';
|
|
@@ -7,12 +7,8 @@ import {UniformStore, type Binding, type Buffer, type Device} from '@luma.gl/cor
|
|
|
7
7
|
import {assembleComputeKernel} from '../utils/assemble-compute-kernel';
|
|
8
8
|
import {Kernel, getPlatformInfo} from '@luma.gl/gpgpu';
|
|
9
9
|
import {DynamicBuffer} from '@luma.gl/core/dynamic';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
ShaderAssembler,
|
|
13
|
-
type ShaderModule,
|
|
14
|
-
type WGSLShaderAssembler
|
|
15
|
-
} from '@luma.gl/shadertools';
|
|
10
|
+
import {fp64arithmetic, type ShaderModule} from '@luma.gl/shaders';
|
|
11
|
+
import {WGSLShaderAssembler} from '@luma.gl/shaders/wgsl';
|
|
16
12
|
import type {GPUVectorFormat} from '@luma.gl/gpgpu/gpu-data';
|
|
17
13
|
import {
|
|
18
14
|
GPUCommandGraph,
|
|
@@ -455,7 +451,7 @@ export function addGeospatialPass<Parameters>(
|
|
|
455
451
|
// Classic arithmetic reads the fp64arithmetic uniforms. The entry point uses them
|
|
456
452
|
// statically, so the automatic pipeline layout always includes the uniform binding.
|
|
457
453
|
const source = classic ? addFP64UniformUse(props.source) : props.source;
|
|
458
|
-
const shaderAssembler =
|
|
454
|
+
const shaderAssembler = new WGSLShaderAssembler();
|
|
459
455
|
const kernel = new Kernel(
|
|
460
456
|
device,
|
|
461
457
|
assembleComputeKernel(device, {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Binding} from '@luma.gl/core';
|
|
6
6
|
import {Kernel} from '@luma.gl/gpgpu';
|
|
7
|
-
import {dggs} from '@luma.gl/
|
|
7
|
+
import {dggs} from '@luma.gl/shaders';
|
|
8
8
|
import {GPUCommandGraph, type GraphDataView} from '../gpu-core/gpu-command-graph';
|
|
9
9
|
import {
|
|
10
10
|
getViewBinding,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuProj.
|
|
5
5
|
|
|
6
|
-
import {fp64arithmetic, type ShaderModule} from '@luma.gl/
|
|
6
|
+
import {fp64arithmetic, type ShaderModule} from '@luma.gl/shaders';
|
|
7
7
|
import {
|
|
8
8
|
GEOSPATIAL_INTEGER_FP64_ARITHMETIC_MODULE,
|
|
9
9
|
getClassicFP64Defines
|
package/src/gpu-sql/lu-sql.ts
CHANGED
|
@@ -91,7 +91,7 @@ type LuSQLDynamicQuery = LuSQLCompiledPlan & {
|
|
|
91
91
|
* Dependency-free SQL frontend over explicitly registered, already GPU-resident dataframes.
|
|
92
92
|
*
|
|
93
93
|
* Parsing and planning never upload data, submit work, or read GPU buffers. Arrow upload/output
|
|
94
|
-
* remain explicit `@luma.gl/arrow` operations around the shared GPU table execution core.
|
|
94
|
+
* remain explicit `@luma.gl/graph/arrow` operations around the shared GPU table execution core.
|
|
95
95
|
*/
|
|
96
96
|
export class LuSQLContext {
|
|
97
97
|
private readonly tables: Readonly<Record<string, LuDataFrame>>;
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type TypedArray
|
|
14
14
|
} from '@luma.gl/core';
|
|
15
15
|
import {DynamicBuffer} from '@luma.gl/core/dynamic';
|
|
16
|
-
import type {ShaderModule} from '@luma.gl/
|
|
16
|
+
import type {ShaderModule} from '@luma.gl/shaders';
|
|
17
17
|
import {
|
|
18
18
|
getGPUInputAttributeNames,
|
|
19
19
|
validateGPUInputVectors,
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import type {Device} from '@luma.gl/core';
|
|
6
6
|
import {getPlatformInfo, type KernelProps} from '@luma.gl/gpgpu';
|
|
7
|
-
import {
|
|
7
|
+
import {WGSLShaderAssembler} from '@luma.gl/shaders/wgsl';
|
|
8
|
+
import {type ShaderModule} from '@luma.gl/shaders';
|
|
8
9
|
|
|
9
10
|
/** Assemble module-based compute source before creating the executable kernel. */
|
|
10
11
|
export function assembleComputeKernel(
|
|
@@ -15,12 +16,7 @@ export function assembleComputeKernel(
|
|
|
15
16
|
shaderAssembler?: WGSLShaderAssembler;
|
|
16
17
|
}
|
|
17
18
|
): KernelProps {
|
|
18
|
-
const {
|
|
19
|
-
modules,
|
|
20
|
-
defines,
|
|
21
|
-
shaderAssembler = ShaderAssembler.getDefaultShaderAssembler('wgsl'),
|
|
22
|
-
...kernelProps
|
|
23
|
-
} = props;
|
|
19
|
+
const {modules, defines, shaderAssembler = new WGSLShaderAssembler(), ...kernelProps} = props;
|
|
24
20
|
const assembled = shaderAssembler.assembleWGSLShader({
|
|
25
21
|
platformInfo: getPlatformInfo(device),
|
|
26
22
|
source: props.source,
|