@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,294 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Buffer} from '@luma.gl/core';
|
|
6
|
+
import type {GPUData, GPUVector} from '@luma.gl/gpgpu/gpu-data';
|
|
7
|
+
import type {GPUTable, GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
8
|
+
import {
|
|
9
|
+
Dictionary,
|
|
10
|
+
Field,
|
|
11
|
+
Float32,
|
|
12
|
+
Int32,
|
|
13
|
+
RecordBatch,
|
|
14
|
+
Schema,
|
|
15
|
+
Struct,
|
|
16
|
+
Table,
|
|
17
|
+
Uint32,
|
|
18
|
+
Utf8,
|
|
19
|
+
makeData,
|
|
20
|
+
vectorFromArray,
|
|
21
|
+
type Data,
|
|
22
|
+
type DataType
|
|
23
|
+
} from 'apache-arrow';
|
|
24
|
+
import type {GPUAnalyticsDictionary} from './arrow-gpu-analytics-adapters';
|
|
25
|
+
|
|
26
|
+
/** Explicit GPU analytics materialization controls; no readback occurs before invocation. */
|
|
27
|
+
export type ArrowTableFromGPUAnalyticsTableProps<T extends GPUTypeMap = GPUTypeMap> = {
|
|
28
|
+
/** GPU-resident source or result table; original record batches remain individually addressable. */
|
|
29
|
+
table: GPUTable<T>;
|
|
30
|
+
/** Nullable source/result masks, aligned with the corresponding GPU table batches. */
|
|
31
|
+
validity?: Readonly<Partial<Record<keyof T & string, GPUVector<'uint32'>>>>;
|
|
32
|
+
/** Adapter-owned UTF-8 category labels and ordering metadata. */
|
|
33
|
+
dictionaries?: Readonly<
|
|
34
|
+
Partial<Record<keyof T & string, GPUAnalyticsDictionary | readonly string[]>>
|
|
35
|
+
>;
|
|
36
|
+
/** Stable compacted source-row identities, one chunk for every original source batch. */
|
|
37
|
+
rowIndices?: GPUVector<'uint32'>;
|
|
38
|
+
/** One published row count per original source batch; requires `rowIndices`. */
|
|
39
|
+
selectedCounts?: GPUVector<'uint32'>;
|
|
40
|
+
/** Explicit globally ordered source identities; materializes one reordered output batch. */
|
|
41
|
+
globalRowIndices?: GPUVector<'uint32'>;
|
|
42
|
+
/** One GPU-resident global selected count; requires `globalRowIndices`. */
|
|
43
|
+
globalSelectedCount?: GPUVector<'uint32'>;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type ArrowAnalyticsRow = {batchIndex: number; rowIndex: number};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Explicitly reads a GPU analytical table into Arrow without adding Arrow to generic GPU packages.
|
|
50
|
+
*
|
|
51
|
+
* Ordinary materialization preserves every source batch, including empty chunks. Optional
|
|
52
|
+
* dataframe selection identities retain those batch boundaries, while explicitly requested global
|
|
53
|
+
* identities produce one intentionally reordered Arrow result batch.
|
|
54
|
+
*/
|
|
55
|
+
export async function makeArrowTableFromGPUAnalyticsTable<T extends GPUTypeMap>(
|
|
56
|
+
props: ArrowTableFromGPUAnalyticsTableProps<T>
|
|
57
|
+
): Promise<Table> {
|
|
58
|
+
validateArrowGPUAnalyticsReadback(props);
|
|
59
|
+
const fields = props.table.schema.fields.map((field, fieldIndex) => {
|
|
60
|
+
const dictionary = props.dictionaries?.[field.name];
|
|
61
|
+
const type = dictionary
|
|
62
|
+
? makeArrowAnalyticsDictionaryType(props.table, field.name, dictionary, fieldIndex)
|
|
63
|
+
: makeArrowAnalyticsScalarType(field.format);
|
|
64
|
+
return new Field(field.name, type, field.nullable, new Map(field.metadata));
|
|
65
|
+
});
|
|
66
|
+
const schema = new Schema(fields, new Map(props.table.schema.metadata));
|
|
67
|
+
const rowGroups = await resolveArrowAnalyticsRows(props);
|
|
68
|
+
const batches = await Promise.all(
|
|
69
|
+
rowGroups.map(async rows => {
|
|
70
|
+
const children = await Promise.all(
|
|
71
|
+
fields.map((field, fieldIndex) => makeArrowAnalyticsColumn(props, field, fieldIndex, rows))
|
|
72
|
+
);
|
|
73
|
+
return new RecordBatch(
|
|
74
|
+
schema,
|
|
75
|
+
makeData({type: new Struct(schema.fields), length: rows.length, children})
|
|
76
|
+
);
|
|
77
|
+
})
|
|
78
|
+
);
|
|
79
|
+
return new Table(schema, batches);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Rejects ambiguous ordering contracts and malformed chunk metadata before any GPU readback. */
|
|
83
|
+
function validateArrowGPUAnalyticsReadback<T extends GPUTypeMap>(
|
|
84
|
+
props: ArrowTableFromGPUAnalyticsTableProps<T>
|
|
85
|
+
): void {
|
|
86
|
+
const local = Boolean(props.rowIndices || props.selectedCounts);
|
|
87
|
+
const global = Boolean(props.globalRowIndices || props.globalSelectedCount);
|
|
88
|
+
if (local && global) {
|
|
89
|
+
throw new Error('Arrow analytics output cannot combine per-batch and global row ordering');
|
|
90
|
+
}
|
|
91
|
+
if (Boolean(props.rowIndices) !== Boolean(props.selectedCounts)) {
|
|
92
|
+
throw new Error('Arrow analytics selected rows require both row indices and selected counts');
|
|
93
|
+
}
|
|
94
|
+
if (Boolean(props.globalRowIndices) !== Boolean(props.globalSelectedCount)) {
|
|
95
|
+
throw new Error('Arrow analytics global rows require both global indices and selected count');
|
|
96
|
+
}
|
|
97
|
+
if (
|
|
98
|
+
local &&
|
|
99
|
+
(props.rowIndices!.data.length !== props.table.batches.length ||
|
|
100
|
+
props.selectedCounts!.data.length !== props.table.batches.length)
|
|
101
|
+
) {
|
|
102
|
+
throw new Error('Arrow analytics selected rows must preserve source batch topology');
|
|
103
|
+
}
|
|
104
|
+
if (
|
|
105
|
+
global &&
|
|
106
|
+
(props.globalRowIndices!.data.length !== 1 || props.globalSelectedCount!.length !== 1)
|
|
107
|
+
) {
|
|
108
|
+
throw new Error('Arrow analytics global ordering requires one index chunk and one count');
|
|
109
|
+
}
|
|
110
|
+
for (const field of props.table.schema.fields) {
|
|
111
|
+
const validity = props.validity?.[field.name];
|
|
112
|
+
if (field.nullable && props.table.batches.length > 0 && !validity) {
|
|
113
|
+
throw new Error(`Arrow analytics nullable column "${field.name}" requires GPU validity`);
|
|
114
|
+
}
|
|
115
|
+
if (
|
|
116
|
+
validity &&
|
|
117
|
+
(validity.data.length !== props.table.batches.length ||
|
|
118
|
+
validity.data.some((chunk, index) => chunk.length !== props.table.batches[index].numRows))
|
|
119
|
+
) {
|
|
120
|
+
throw new Error(`Arrow analytics validity for "${field.name}" must match source batches`);
|
|
121
|
+
}
|
|
122
|
+
makeArrowAnalyticsScalarType(field.format);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** Resolves explicit selected/global identities without implicitly concatenating source columns. */
|
|
127
|
+
async function resolveArrowAnalyticsRows<T extends GPUTypeMap>(
|
|
128
|
+
props: ArrowTableFromGPUAnalyticsTableProps<T>
|
|
129
|
+
): Promise<ArrowAnalyticsRow[][]> {
|
|
130
|
+
if (props.globalRowIndices && props.globalSelectedCount) {
|
|
131
|
+
const [count] = await readArrowAnalyticsWords(props.globalSelectedCount.data[0]);
|
|
132
|
+
if (count > props.globalRowIndices.data[0].length) {
|
|
133
|
+
throw new Error('Arrow analytics global selected count exceeds the available row identities');
|
|
134
|
+
}
|
|
135
|
+
const sourceRows = await readArrowAnalyticsWords(props.globalRowIndices.data[0], count);
|
|
136
|
+
return [
|
|
137
|
+
Array.from(sourceRows, sourceRow => resolveArrowAnalyticsSourceRow(props.table, sourceRow))
|
|
138
|
+
];
|
|
139
|
+
}
|
|
140
|
+
return Promise.all(
|
|
141
|
+
props.table.batches.map(async (batch, batchIndex) => {
|
|
142
|
+
if (!props.rowIndices || !props.selectedCounts) {
|
|
143
|
+
return Array.from({length: batch.numRows}, (_, rowIndex) => ({batchIndex, rowIndex}));
|
|
144
|
+
}
|
|
145
|
+
const [count] = await readArrowAnalyticsWords(props.selectedCounts.data[batchIndex]);
|
|
146
|
+
const identities = props.rowIndices.data[batchIndex];
|
|
147
|
+
if (count > identities.length || count > batch.numRows) {
|
|
148
|
+
throw new Error('Arrow analytics selected count exceeds its original source batch');
|
|
149
|
+
}
|
|
150
|
+
const sourceRows = await readArrowAnalyticsWords(identities, count);
|
|
151
|
+
const sourceOffset = getArrowAnalyticsBatchOffset(props.table, batchIndex);
|
|
152
|
+
return Array.from(sourceRows, sourceRow => {
|
|
153
|
+
const rowIndex = sourceRow - sourceOffset;
|
|
154
|
+
if (rowIndex < 0 || rowIndex >= batch.numRows) {
|
|
155
|
+
throw new Error('Arrow analytics selected row does not belong to its source batch');
|
|
156
|
+
}
|
|
157
|
+
return {batchIndex, rowIndex};
|
|
158
|
+
});
|
|
159
|
+
})
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function resolveArrowAnalyticsSourceRow<T extends GPUTypeMap>(
|
|
164
|
+
table: GPUTable<T>,
|
|
165
|
+
sourceRow: number
|
|
166
|
+
): ArrowAnalyticsRow {
|
|
167
|
+
for (const [batchIndex, batch] of table.batches.entries()) {
|
|
168
|
+
const firstRow = getArrowAnalyticsBatchOffset(table, batchIndex);
|
|
169
|
+
if (sourceRow >= firstRow && sourceRow < firstRow + batch.numRows) {
|
|
170
|
+
return {batchIndex, rowIndex: sourceRow - firstRow};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
throw new Error('Arrow analytics global row does not belong to any original source batch');
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function getArrowAnalyticsBatchOffset<T extends GPUTypeMap>(
|
|
177
|
+
table: GPUTable<T>,
|
|
178
|
+
batchIndex: number
|
|
179
|
+
): number {
|
|
180
|
+
const explicitOffset = table.batches[batchIndex].sourceInfo?.sourceRowIndexOffset;
|
|
181
|
+
if (explicitOffset !== undefined) return explicitOffset;
|
|
182
|
+
return table.batches.slice(0, batchIndex).reduce((total, batch) => total + batch.numRows, 0);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
async function makeArrowAnalyticsColumn<T extends GPUTypeMap>(
|
|
186
|
+
props: ArrowTableFromGPUAnalyticsTableProps<T>,
|
|
187
|
+
field: Field,
|
|
188
|
+
fieldIndex: number,
|
|
189
|
+
rows: readonly ArrowAnalyticsRow[]
|
|
190
|
+
): Promise<Data> {
|
|
191
|
+
const format = props.table.schema.fields[fieldIndex].format;
|
|
192
|
+
const sourceValues = new Map<number, Float32Array | Int32Array | Uint32Array>();
|
|
193
|
+
const sourceValidity = new Map<number, Uint32Array>();
|
|
194
|
+
await Promise.all(
|
|
195
|
+
Array.from(new Set(rows.map(row => row.batchIndex))).map(async batchIndex => {
|
|
196
|
+
const data = props.table.batches[batchIndex].gpuData[field.name];
|
|
197
|
+
const bytes = await readArrowAnalyticsBytes(data);
|
|
198
|
+
const Constructor =
|
|
199
|
+
format === 'float32' ? Float32Array : format === 'sint32' ? Int32Array : Uint32Array;
|
|
200
|
+
sourceValues.set(
|
|
201
|
+
batchIndex,
|
|
202
|
+
new Constructor(bytes.buffer as ArrayBuffer, bytes.byteOffset, data.length)
|
|
203
|
+
);
|
|
204
|
+
const validity = props.validity?.[field.name]?.data[batchIndex];
|
|
205
|
+
if (validity) sourceValidity.set(batchIndex, await readArrowAnalyticsWords(validity));
|
|
206
|
+
})
|
|
207
|
+
);
|
|
208
|
+
const Constructor =
|
|
209
|
+
format === 'float32' ? Float32Array : format === 'sint32' ? Int32Array : Uint32Array;
|
|
210
|
+
const values = new Constructor(rows.length);
|
|
211
|
+
const nullBitmap = new Uint8Array(Math.ceil(rows.length / 8));
|
|
212
|
+
let nullCount = 0;
|
|
213
|
+
for (const [outputIndex, row] of rows.entries()) {
|
|
214
|
+
values[outputIndex] = sourceValues.get(row.batchIndex)![row.rowIndex];
|
|
215
|
+
const valid = sourceValidity.get(row.batchIndex)?.[row.rowIndex] !== 0;
|
|
216
|
+
if (valid) {
|
|
217
|
+
nullBitmap[outputIndex >> 3] |= 1 << (outputIndex & 7);
|
|
218
|
+
} else {
|
|
219
|
+
nullCount++;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (field.type instanceof Dictionary) {
|
|
223
|
+
const metadata = props.dictionaries?.[field.name];
|
|
224
|
+
if (!metadata) throw new Error(`Arrow analytics dictionary "${field.name}" is missing`);
|
|
225
|
+
const labels: readonly string[] = isArrowAnalyticsDictionary(metadata)
|
|
226
|
+
? metadata.values
|
|
227
|
+
: (metadata as readonly string[]);
|
|
228
|
+
return makeData({
|
|
229
|
+
type: field.type,
|
|
230
|
+
length: rows.length,
|
|
231
|
+
data: values as Int32Array | Uint32Array,
|
|
232
|
+
dictionary: vectorFromArray(labels, new Utf8()),
|
|
233
|
+
nullBitmap,
|
|
234
|
+
nullCount
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
return makeData({type: field.type, length: rows.length, data: values, nullBitmap, nullCount});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function makeArrowAnalyticsDictionaryType<T extends GPUTypeMap>(
|
|
241
|
+
table: GPUTable<T>,
|
|
242
|
+
name: keyof T & string,
|
|
243
|
+
metadata: GPUAnalyticsDictionary | readonly string[],
|
|
244
|
+
fieldIndex: number
|
|
245
|
+
): Dictionary<Utf8, Int32 | Uint32> {
|
|
246
|
+
const existingType = table.gpuVectors[name]?.dataType;
|
|
247
|
+
if (existingType instanceof Dictionary) return existingType as Dictionary<Utf8, Int32 | Uint32>;
|
|
248
|
+
const format = table.schema.fields[fieldIndex].format;
|
|
249
|
+
if (format !== 'sint32' && format !== 'uint32') {
|
|
250
|
+
throw new Error(`Arrow analytics dictionary "${name}" requires 32-bit integer indices`);
|
|
251
|
+
}
|
|
252
|
+
return new Dictionary(
|
|
253
|
+
new Utf8(),
|
|
254
|
+
format === 'sint32' ? new Int32() : new Uint32(),
|
|
255
|
+
fieldIndex,
|
|
256
|
+
isArrowAnalyticsDictionary(metadata) ? metadata.ordered : false
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function isArrowAnalyticsDictionary(
|
|
261
|
+
value: GPUAnalyticsDictionary | readonly string[]
|
|
262
|
+
): value is GPUAnalyticsDictionary {
|
|
263
|
+
return !Array.isArray(value);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function makeArrowAnalyticsScalarType(format: string | undefined): DataType {
|
|
267
|
+
switch (format) {
|
|
268
|
+
case 'float32':
|
|
269
|
+
return new Float32();
|
|
270
|
+
case 'sint32':
|
|
271
|
+
return new Int32();
|
|
272
|
+
case 'uint32':
|
|
273
|
+
return new Uint32();
|
|
274
|
+
default:
|
|
275
|
+
throw new Error(`Arrow analytics output does not support GPU format "${format}"`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function readArrowAnalyticsWords(
|
|
280
|
+
data: GPUData<'uint32'>,
|
|
281
|
+
length = data.length
|
|
282
|
+
): Promise<Uint32Array> {
|
|
283
|
+
const bytes = await readArrowAnalyticsBytes(data, length);
|
|
284
|
+
return new Uint32Array(bytes.buffer, bytes.byteOffset, length);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async function readArrowAnalyticsBytes(data: GPUData, length = data.length): Promise<Uint8Array> {
|
|
288
|
+
if (data.byteStride !== 4 || data.rowByteLength !== 4 || data.byteOffset % 4 !== 0) {
|
|
289
|
+
throw new Error('Arrow analytics output requires packed 32-bit GPU scalar data');
|
|
290
|
+
}
|
|
291
|
+
if (length === 0) return new Uint8Array(0);
|
|
292
|
+
const buffer = data.buffer instanceof Buffer ? data.buffer : data.buffer.buffer;
|
|
293
|
+
return buffer.readAsync(data.byteOffset, length * Uint32Array.BYTES_PER_ELEMENT);
|
|
294
|
+
}
|
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
// luma.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {Device, type BufferLayout, type ShaderLayout} from '@luma.gl/core';
|
|
6
|
+
import {GPUData, type GPUVectorBufferProps, type GPUVectorFormat} from '@luma.gl/gpgpu/gpu-data';
|
|
7
|
+
import {
|
|
8
|
+
GPURecordBatch,
|
|
9
|
+
GPUTable,
|
|
10
|
+
type GPURecordBatchSourceInfo,
|
|
11
|
+
type GPUField
|
|
12
|
+
} from '@luma.gl/graph/gpu-tables';
|
|
13
|
+
import {
|
|
14
|
+
Data,
|
|
15
|
+
DataType,
|
|
16
|
+
Field,
|
|
17
|
+
FixedSizeList,
|
|
18
|
+
RecordBatch,
|
|
19
|
+
Table,
|
|
20
|
+
Uint32,
|
|
21
|
+
Vector,
|
|
22
|
+
makeData
|
|
23
|
+
} from 'apache-arrow';
|
|
24
|
+
import {getArrowFieldByPath} from '@luma.gl/gpgpu/_internal/arrow';
|
|
25
|
+
import {getArrowVectorByPath} from '@luma.gl/gpgpu/arrow';
|
|
26
|
+
import {getArrowBufferLayout, type ArrowVertexFormatOptions} from '@luma.gl/gpgpu/arrow';
|
|
27
|
+
import {getArrowFixedSizeListRowValidity} from '@luma.gl/gpgpu/_internal/arrow';
|
|
28
|
+
import {
|
|
29
|
+
isInstanceArrowType,
|
|
30
|
+
isVariableLengthAttributeArrowType
|
|
31
|
+
} from '@luma.gl/gpgpu/_internal/arrow';
|
|
32
|
+
import {type NumericArrowType} from '@luma.gl/gpgpu/arrow';
|
|
33
|
+
import {getArrowMatrixVectorInfo} from '@luma.gl/gpgpu/arrow';
|
|
34
|
+
import {
|
|
35
|
+
ArrowGPUDataProps,
|
|
36
|
+
getSignedArrowDataType,
|
|
37
|
+
isArrowUtf8DictionaryType,
|
|
38
|
+
isStorageFixedSizeListArrowType,
|
|
39
|
+
getGPUVectorFormatForArrowType,
|
|
40
|
+
isCanonicalFloat32ArrowMatrixInfo
|
|
41
|
+
} from '@luma.gl/gpgpu/_internal/arrow';
|
|
42
|
+
import {makeGPUDataFromArrowData} from '@luma.gl/gpgpu/arrow';
|
|
43
|
+
|
|
44
|
+
/** Caller-selected row-validity storage sibling for one fixed-size-list Arrow column. */
|
|
45
|
+
export type ArrowGPUValidityColumn =
|
|
46
|
+
| string
|
|
47
|
+
| {
|
|
48
|
+
/** Name of the uint32 GPU table column that receives nonzero-valid row flags. */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Meaningful leading child coordinates; nullable trailing padding is ignored. */
|
|
51
|
+
dimensions?: number;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/** Props for uploading one Arrow record batch into a generic GPU record batch. */
|
|
55
|
+
export type GPURecordBatchFromArrowRecordBatchProps = ArrowVertexFormatOptions & {
|
|
56
|
+
/** Shader layout that selects which Arrow columns should be uploaded. */
|
|
57
|
+
shaderLayout: ShaderLayout;
|
|
58
|
+
/** Maps shader attribute names to Arrow column paths. */
|
|
59
|
+
arrowPaths?: Record<string, string>;
|
|
60
|
+
/** Buffer props applied to Arrow-backed GPU vectors. */
|
|
61
|
+
bufferProps?: GPUVectorBufferProps;
|
|
62
|
+
/** Storage-selected columns that should use fixed-size-list format even for short rows. */
|
|
63
|
+
fixedSizeListColumns?: readonly string[];
|
|
64
|
+
/** Optional source-row identity retained for picking and diagnostics. */
|
|
65
|
+
sourceInfo?: GPURecordBatchSourceInfo;
|
|
66
|
+
/** Explicitly materialized uint32 row-validity siblings keyed by selected column name. */
|
|
67
|
+
validityColumns?: Record<string, ArrowGPUValidityColumn>;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** Props for uploading one Arrow table into a generic GPU table. */
|
|
71
|
+
export type GPUTableFromArrowTableProps = ArrowVertexFormatOptions & {
|
|
72
|
+
/** Shader layout that selects which Arrow columns should be uploaded. */
|
|
73
|
+
shaderLayout: ShaderLayout;
|
|
74
|
+
/** Maps shader attribute names to Arrow column paths. */
|
|
75
|
+
arrowPaths?: Record<string, string>;
|
|
76
|
+
/** Buffer props applied to Arrow-backed GPU vectors. */
|
|
77
|
+
bufferProps?: GPUVectorBufferProps;
|
|
78
|
+
/** Storage-selected columns that should use fixed-size-list format even for short rows. */
|
|
79
|
+
fixedSizeListColumns?: readonly string[];
|
|
80
|
+
/** Explicitly materialized uint32 row-validity siblings keyed by selected column name. */
|
|
81
|
+
validityColumns?: Record<string, ArrowGPUValidityColumn>;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
/** Uploads one Arrow record batch into a generic GPU record batch. */
|
|
85
|
+
export function makeGPURecordBatchFromArrowRecordBatch(
|
|
86
|
+
device: Device,
|
|
87
|
+
recordBatch: RecordBatch,
|
|
88
|
+
options: GPURecordBatchFromArrowRecordBatchProps
|
|
89
|
+
): GPURecordBatch {
|
|
90
|
+
const table = new Table([recordBatch]);
|
|
91
|
+
const bufferLayout = getArrowBufferLayout(options.shaderLayout, {
|
|
92
|
+
arrowTable: table,
|
|
93
|
+
arrowPaths: options.arrowPaths,
|
|
94
|
+
allowWebGLOnlyFormats: options.allowWebGLOnlyFormats
|
|
95
|
+
});
|
|
96
|
+
const fields: GPUField[] = [];
|
|
97
|
+
const gpuData: Record<string, GPUData> = {};
|
|
98
|
+
const selectedNames = new Set<string>();
|
|
99
|
+
|
|
100
|
+
for (const layout of bufferLayout) {
|
|
101
|
+
if (options.fixedSizeListColumns?.includes(layout.name)) {
|
|
102
|
+
throw new Error('Arrow fixed-size-list GPU columns require a storage shader binding');
|
|
103
|
+
}
|
|
104
|
+
const arrowPath = options.arrowPaths?.[layout.name] || layout.name;
|
|
105
|
+
const vector = getArrowVectorByPath(table, arrowPath);
|
|
106
|
+
const sourceField = getArrowFieldByPath(table, arrowPath);
|
|
107
|
+
gpuData[layout.name] = makeGPUDataFromArrowRecordBatchVector(device, vector as Vector, {
|
|
108
|
+
...options.bufferProps,
|
|
109
|
+
format: layout.format
|
|
110
|
+
});
|
|
111
|
+
fields.push({
|
|
112
|
+
name: layout.name,
|
|
113
|
+
format: gpuData[layout.name].format,
|
|
114
|
+
nullable: sourceField.nullable,
|
|
115
|
+
metadata: new Map(sourceField.metadata)
|
|
116
|
+
});
|
|
117
|
+
selectedNames.add(layout.name);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
for (const storageBinding of getArrowStorageBindings(options.shaderLayout)) {
|
|
121
|
+
if (selectedNames.has(storageBinding.name)) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`GPURecordBatch shader input "${storageBinding.name}" cannot be both an attribute and a storage binding`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const arrowPath = options.arrowPaths?.[storageBinding.name] || storageBinding.name;
|
|
127
|
+
const vector = tryGetArrowVectorByPath(table, arrowPath);
|
|
128
|
+
const sourceField = tryGetArrowFieldByPath(table, arrowPath);
|
|
129
|
+
if (!vector || !sourceField) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
gpuData[storageBinding.name] = makeGPUDataFromArrowRecordBatchVector(device, vector as Vector, {
|
|
133
|
+
...options.bufferProps,
|
|
134
|
+
...(options.fixedSizeListColumns?.includes(storageBinding.name)
|
|
135
|
+
? {format: getFixedSizeListGPUVectorFormatForArrowType(vector.type)}
|
|
136
|
+
: {})
|
|
137
|
+
});
|
|
138
|
+
fields.push({
|
|
139
|
+
name: storageBinding.name,
|
|
140
|
+
format: gpuData[storageBinding.name].format,
|
|
141
|
+
nullable: sourceField.nullable,
|
|
142
|
+
metadata: new Map(sourceField.metadata)
|
|
143
|
+
});
|
|
144
|
+
selectedNames.add(storageBinding.name);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
for (const columnName of options.fixedSizeListColumns ?? []) {
|
|
148
|
+
if (!selectedNames.has(columnName)) {
|
|
149
|
+
throw new Error('Arrow fixed-size-list GPU columns require a selected storage binding');
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for (const [sourceName, validityColumn] of Object.entries(options.validityColumns ?? {})) {
|
|
154
|
+
const validityName = typeof validityColumn === 'string' ? validityColumn : validityColumn.name;
|
|
155
|
+
if (!selectedNames.has(sourceName) || selectedNames.has(validityName)) {
|
|
156
|
+
throw new Error('Arrow GPU validity columns require a selected source and unique output');
|
|
157
|
+
}
|
|
158
|
+
const arrowPath = options.arrowPaths?.[sourceName] || sourceName;
|
|
159
|
+
const vector = getArrowVectorByPath(table, arrowPath);
|
|
160
|
+
if (!DataType.isFixedSizeList(vector.type)) {
|
|
161
|
+
throw new Error('Arrow GPU validity columns require FixedSizeList source data');
|
|
162
|
+
}
|
|
163
|
+
const dimensions =
|
|
164
|
+
typeof validityColumn === 'string'
|
|
165
|
+
? vector.type.listSize
|
|
166
|
+
: (validityColumn.dimensions ?? vector.type.listSize);
|
|
167
|
+
const [data, ...remainingData] = vector.data;
|
|
168
|
+
if (!data || remainingData.length > 0) {
|
|
169
|
+
throw new Error('Arrow RecordBatch columns require exactly one Arrow Data chunk');
|
|
170
|
+
}
|
|
171
|
+
const validity =
|
|
172
|
+
getArrowFixedSizeListRowValidity(data as Data<FixedSizeList<NumericArrowType>>, dimensions) ??
|
|
173
|
+
new Uint32Array(data.length).fill(1);
|
|
174
|
+
const validityData = makeData({type: new Uint32(), length: validity.length, data: validity});
|
|
175
|
+
gpuData[validityName] = makeGPUDataFromArrowData(device, validityData, {
|
|
176
|
+
...options.bufferProps,
|
|
177
|
+
format: 'uint32'
|
|
178
|
+
});
|
|
179
|
+
fields.push({name: validityName, format: 'uint32', nullable: false, metadata: new Map()});
|
|
180
|
+
selectedNames.add(validityName);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return new GPURecordBatch({
|
|
184
|
+
gpuData,
|
|
185
|
+
bufferLayout,
|
|
186
|
+
fields,
|
|
187
|
+
numRows: recordBatch.numRows,
|
|
188
|
+
metadata: new Map(recordBatch.schema.metadata),
|
|
189
|
+
sourceInfo: options.sourceInfo,
|
|
190
|
+
nullCount: recordBatch.nullCount
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function makeGPUDataFromArrowRecordBatchVector(
|
|
195
|
+
device: Device,
|
|
196
|
+
vector: Vector,
|
|
197
|
+
props: ArrowGPUDataProps = {}
|
|
198
|
+
): GPUData {
|
|
199
|
+
const arrowType = vector.type;
|
|
200
|
+
const matrixInfo = getArrowMatrixVectorInfo(vector);
|
|
201
|
+
const isCanonicalFloat32Matrix = matrixInfo && isCanonicalFloat32ArrowMatrixInfo(matrixInfo);
|
|
202
|
+
const requiresChunkedUpload =
|
|
203
|
+
DataType.isUtf8(arrowType) ||
|
|
204
|
+
isArrowUtf8DictionaryType(arrowType) ||
|
|
205
|
+
isVariableLengthAttributeArrowType(arrowType);
|
|
206
|
+
if (matrixInfo && !isCanonicalFloat32Matrix) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
'GPUVector matrix columns require canonical Float32 column-major wgsl-storage values; use convertArrowMatrixToGPUVector() first'
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (
|
|
212
|
+
!isInstanceArrowType(arrowType) &&
|
|
213
|
+
!isStorageFixedSizeListArrowType(arrowType) &&
|
|
214
|
+
!isCanonicalFloat32Matrix &&
|
|
215
|
+
!requiresChunkedUpload
|
|
216
|
+
) {
|
|
217
|
+
throw new Error(`GPUVector does not support Arrow type ${arrowType}`);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const [data, ...remainingData] = vector.data;
|
|
221
|
+
if (!data || remainingData.length > 0) {
|
|
222
|
+
throw new Error('Arrow RecordBatch columns require exactly one Arrow Data chunk');
|
|
223
|
+
}
|
|
224
|
+
return makeGPUDataFromArrowData(device, data, {
|
|
225
|
+
...props,
|
|
226
|
+
format: props.format ?? (matrixInfo ? 'float32x4' : getGPUVectorFormatForArrowType(arrowType))
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Uploads one Arrow table into a generic GPU table while preserving record-batch boundaries. */
|
|
231
|
+
export function makeGPUTableFromArrowTable(
|
|
232
|
+
device: Device,
|
|
233
|
+
table: Table,
|
|
234
|
+
options: GPUTableFromArrowTableProps
|
|
235
|
+
): GPUTable {
|
|
236
|
+
let sourceRowIndexOffset = 0;
|
|
237
|
+
const batches = table.batches.map((recordBatch, sourceBatchIndex) => {
|
|
238
|
+
const batch = makeGPURecordBatchFromArrowRecordBatch(device, recordBatch, {
|
|
239
|
+
...options,
|
|
240
|
+
sourceInfo: {
|
|
241
|
+
sourceBatchIndex,
|
|
242
|
+
sourceRowIndexOffset,
|
|
243
|
+
sourceRowCount: recordBatch.numRows
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
sourceRowIndexOffset += recordBatch.numRows;
|
|
247
|
+
return batch;
|
|
248
|
+
});
|
|
249
|
+
const firstBatch = batches[0];
|
|
250
|
+
const bufferLayout =
|
|
251
|
+
firstBatch?.bufferLayout ??
|
|
252
|
+
(options.shaderLayout.attributes.length === 0 && table.batches.length === 0
|
|
253
|
+
? []
|
|
254
|
+
: getArrowBufferLayout(options.shaderLayout, {
|
|
255
|
+
arrowTable: table,
|
|
256
|
+
arrowPaths: options.arrowPaths,
|
|
257
|
+
allowWebGLOnlyFormats: options.allowWebGLOnlyFormats
|
|
258
|
+
}));
|
|
259
|
+
const schema = firstBatch?.schema ?? {
|
|
260
|
+
fields: getArrowEmptyTableGPUFields(table, options, bufferLayout),
|
|
261
|
+
metadata: new Map(table.schema.metadata)
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
return batches.length > 0
|
|
265
|
+
? new GPUTable({batches})
|
|
266
|
+
: new GPUTable({
|
|
267
|
+
schema,
|
|
268
|
+
bufferLayout
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function getArrowEmptyTableGPUFields(
|
|
273
|
+
table: Table,
|
|
274
|
+
options: GPUTableFromArrowTableProps,
|
|
275
|
+
bufferLayout: BufferLayout[]
|
|
276
|
+
): GPUField[] {
|
|
277
|
+
const fields: GPUField[] = bufferLayout.map(layout => {
|
|
278
|
+
const arrowPath = options.arrowPaths?.[layout.name] || layout.name;
|
|
279
|
+
const sourceField = getArrowFieldByPath(table, arrowPath);
|
|
280
|
+
return {
|
|
281
|
+
name: layout.name,
|
|
282
|
+
format: layout.format as GPUVectorFormat,
|
|
283
|
+
nullable: sourceField.nullable,
|
|
284
|
+
metadata: new Map(sourceField.metadata)
|
|
285
|
+
};
|
|
286
|
+
});
|
|
287
|
+
const selectedNames = new Set(fields.map(field => field.name));
|
|
288
|
+
|
|
289
|
+
for (const storageBinding of getArrowStorageBindings(options.shaderLayout)) {
|
|
290
|
+
if (selectedNames.has(storageBinding.name)) {
|
|
291
|
+
throw new Error(
|
|
292
|
+
`GPURecordBatch shader input "${storageBinding.name}" cannot be both an attribute and a storage binding`
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
const arrowPath = options.arrowPaths?.[storageBinding.name] || storageBinding.name;
|
|
296
|
+
const sourceField = tryGetArrowFieldByPath(table, arrowPath);
|
|
297
|
+
if (!sourceField) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
fields.push({
|
|
301
|
+
name: storageBinding.name,
|
|
302
|
+
format: options.fixedSizeListColumns?.includes(storageBinding.name)
|
|
303
|
+
? getFixedSizeListGPUVectorFormatForArrowType(sourceField.type)
|
|
304
|
+
: getGPUVectorFormatForArrowType(sourceField.type),
|
|
305
|
+
nullable: sourceField.nullable,
|
|
306
|
+
metadata: new Map(sourceField.metadata)
|
|
307
|
+
});
|
|
308
|
+
selectedNames.add(storageBinding.name);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
for (const columnName of options.fixedSizeListColumns ?? []) {
|
|
312
|
+
if (!selectedNames.has(columnName) || bufferLayout.some(layout => layout.name === columnName)) {
|
|
313
|
+
throw new Error('Arrow fixed-size-list GPU columns require a selected storage binding');
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
for (const [sourceName, validityColumn] of Object.entries(options.validityColumns ?? {})) {
|
|
318
|
+
const validityName = typeof validityColumn === 'string' ? validityColumn : validityColumn.name;
|
|
319
|
+
if (!selectedNames.has(sourceName) || selectedNames.has(validityName)) {
|
|
320
|
+
throw new Error('Arrow GPU validity columns require a selected source and unique output');
|
|
321
|
+
}
|
|
322
|
+
const arrowPath = options.arrowPaths?.[sourceName] || sourceName;
|
|
323
|
+
const sourceField = getArrowFieldByPath(table, arrowPath);
|
|
324
|
+
if (!DataType.isFixedSizeList(sourceField.type)) {
|
|
325
|
+
throw new Error('Arrow GPU validity columns require FixedSizeList source data');
|
|
326
|
+
}
|
|
327
|
+
const dimensions =
|
|
328
|
+
typeof validityColumn === 'string'
|
|
329
|
+
? sourceField.type.listSize
|
|
330
|
+
: (validityColumn.dimensions ?? sourceField.type.listSize);
|
|
331
|
+
if (
|
|
332
|
+
!Number.isSafeInteger(dimensions) ||
|
|
333
|
+
dimensions < 1 ||
|
|
334
|
+
dimensions > sourceField.type.listSize
|
|
335
|
+
) {
|
|
336
|
+
throw new Error('Arrow FixedSizeList validity dimensions must fit within the list width');
|
|
337
|
+
}
|
|
338
|
+
fields.push({name: validityName, format: 'uint32', nullable: false, metadata: new Map()});
|
|
339
|
+
selectedNames.add(validityName);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return fields;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function getArrowStorageBindings(shaderLayout: ShaderLayout): Array<{name: string}> {
|
|
346
|
+
return shaderLayout.bindings.filter(
|
|
347
|
+
binding =>
|
|
348
|
+
(binding.type === 'storage' || binding.type === 'read-only-storage') && !('format' in binding)
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function tryGetArrowVectorByPath(table: Table, path: string): Vector | null {
|
|
353
|
+
try {
|
|
354
|
+
return getArrowVectorByPath(table, path);
|
|
355
|
+
} catch {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function tryGetArrowFieldByPath(table: Table, path: string): Field | null {
|
|
361
|
+
try {
|
|
362
|
+
return getArrowFieldByPath(table, path);
|
|
363
|
+
} catch {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function getFixedSizeListGPUVectorFormatForArrowType(type: DataType): GPUVectorFormat {
|
|
369
|
+
if (
|
|
370
|
+
!DataType.isFixedSizeList(type) ||
|
|
371
|
+
!Number.isSafeInteger(type.listSize) ||
|
|
372
|
+
type.listSize < 1
|
|
373
|
+
) {
|
|
374
|
+
throw new Error('Arrow fixed-size-list GPU columns require valid FixedSizeList source data');
|
|
375
|
+
}
|
|
376
|
+
const signedDataType = getSignedArrowDataType(type.children[0].type);
|
|
377
|
+
return `fixed-size-list<${signedDataType},${type.listSize}>`;
|
|
378
|
+
}
|