@luma.gl/graph 10.0.0-beta.2 → 10.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.cjs +22 -9
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts +11 -2
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js +27 -10
- package/dist/arrow/gpu/arrow-gpu-analytics-adapters.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.cjs +24 -13
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts +9 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js +41 -14
- package/dist/arrow/gpu/arrow-gpu-analytics-readback.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.cjs +24 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +10 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +29 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/index.cjs +2 -0
- package/dist/arrow/index.cjs.map +3 -3
- package/dist/arrow/index.d.ts +1 -1
- package/dist/arrow/index.d.ts.map +1 -1
- package/dist/arrow/index.js +1 -1
- package/dist/arrow/index.js.map +1 -1
- package/dist/gpu-core/gpu-bvh-bounds.cjs +63 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts +32 -0
- package/dist/gpu-core/gpu-bvh-bounds.d.ts.map +1 -0
- package/dist/gpu-core/gpu-bvh-bounds.js +56 -0
- package/dist/gpu-core/gpu-bvh-bounds.js.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.cjs +92 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts +41 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.d.ts.map +1 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js +85 -0
- package/dist/gpu-core/gpu-command-graph-submission-pacer.js.map +1 -0
- package/dist/gpu-core/index.cjs +6 -0
- package/dist/gpu-core/index.cjs.map +3 -3
- package/dist/gpu-core/index.d.ts +4 -0
- package/dist/gpu-core/index.d.ts.map +1 -1
- package/dist/gpu-core/index.js +2 -0
- package/dist/gpu-core/index.js.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.cjs +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js +6 -6
- package/dist/gpu-dataframe/gpu-analytics-compiler-utils.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.cjs +55 -14
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts +13 -2
- package/dist/gpu-dataframe/gpu-data-frame-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame-query.js +58 -17
- package/dist/gpu-dataframe/gpu-data-frame-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.cjs +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.d.ts +10 -0
- package/dist/gpu-dataframe/gpu-data-frame.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-data-frame.js +1 -3
- package/dist/gpu-dataframe/gpu-data-frame.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.cjs +94 -44
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts +8 -5
- package/dist/gpu-dataframe/gpu-expression-shader.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression-shader.js +110 -47
- package/dist/gpu-dataframe/gpu-expression-shader.js.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.cjs +14 -8
- package/dist/gpu-dataframe/gpu-expression.d.ts +12 -1
- package/dist/gpu-dataframe/gpu-expression.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-expression.js +11 -6
- package/dist/gpu-dataframe/gpu-expression.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.cjs +2 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +4 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.cjs +2 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js +6 -2
- package/dist/gpu-dataframe/gpu-global-aggregation-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.cjs +113 -88
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +6 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +111 -85
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +286 -48
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +17 -2
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +290 -39
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +8 -6
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +7 -1
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +9 -5
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +8 -6
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +9 -7
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +37 -11
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +3 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +36 -10
- package/dist/gpu-dataframe/gpu-query-compiler.js.map +1 -1
- package/dist/gpu-dataframe/index.cjs +4 -2
- package/dist/gpu-dataframe/index.cjs.map +3 -3
- package/dist/gpu-dataframe/index.d.ts +1 -1
- package/dist/gpu-dataframe/index.d.ts.map +1 -1
- package/dist/gpu-dataframe/index.js +1 -1
- package/dist/gpu-dataframe/index.js.map +1 -1
- package/dist/gpu-physics/gpu-physics-batch.cjs +11 -10
- package/dist/gpu-physics/gpu-physics-batch.d.ts +1 -0
- package/dist/gpu-physics/gpu-physics-batch.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-batch.js +14 -10
- package/dist/gpu-physics/gpu-physics-batch.js.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.cjs +9 -4
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts +10 -1
- package/dist/gpu-physics/gpu-physics-ensemble.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-physics-ensemble.js +11 -4
- package/dist/gpu-physics/gpu-physics-ensemble.js.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.cjs +261 -68
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +47 -2
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +324 -75
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +2 -1
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.cjs +10 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-cache-shaders.js +15 -6
- package/dist/gpu-physics/rigid-body-cache-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.cjs +15 -2
- package/dist/gpu-physics/rigid-body-capacity.d.ts +3 -1
- package/dist/gpu-physics/rigid-body-capacity.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-capacity.js +21 -2
- package/dist/gpu-physics/rigid-body-capacity.js.map +1 -1
- package/dist/gpu-physics/rigid-body-cast-index.cjs +192 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts +44 -0
- package/dist/gpu-physics/rigid-body-cast-index.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-cast-index.js +194 -0
- package/dist/gpu-physics/rigid-body-cast-index.js.map +1 -0
- package/dist/gpu-physics/rigid-body-ensemble-layout.cjs +4 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-layout.js +5 -2
- package/dist/gpu-physics/rigid-body-ensemble-layout.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.cjs +11 -9
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-reset.js +13 -9
- package/dist/gpu-physics/rigid-body-ensemble-reset.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.cjs +14 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts +5 -0
- package/dist/gpu-physics/rigid-body-ensemble-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js +17 -7
- package/dist/gpu-physics/rigid-body-ensemble-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.cjs +21 -11
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts +2 -2
- package/dist/gpu-physics/rigid-body-ensemble-transaction.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js +28 -12
- package/dist/gpu-physics/rigid-body-ensemble-transaction.js.map +1 -1
- package/dist/gpu-physics/rigid-body-event-compaction.cjs +184 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts +35 -0
- package/dist/gpu-physics/rigid-body-event-compaction.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js +168 -0
- package/dist/gpu-physics/rigid-body-event-compaction.js.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.cjs +51 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts +33 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.d.ts.map +1 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js +34 -0
- package/dist/gpu-physics/rigid-body-event-snapshot.js.map +1 -0
- package/dist/gpu-physics/rigid-body-events.cjs +57 -25
- package/dist/gpu-physics/rigid-body-events.d.ts +2 -1
- package/dist/gpu-physics/rigid-body-events.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-events.js +60 -25
- package/dist/gpu-physics/rigid-body-events.js.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.cjs +8 -3
- package/dist/gpu-physics/rigid-body-joints.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-joints.js +10 -6
- package/dist/gpu-physics/rigid-body-joints.js.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.cjs +159 -16
- package/dist/gpu-physics/rigid-body-queries.d.ts +24 -1
- package/dist/gpu-physics/rigid-body-queries.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-queries.js +166 -14
- package/dist/gpu-physics/rigid-body-queries.js.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.cjs +3 -3
- package/dist/gpu-physics/rigid-body-shaders.d.ts +1 -1
- package/dist/gpu-physics/rigid-body-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-shaders.js +3 -3
- package/dist/gpu-physics/rigid-body-shaders.js.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.cjs +53 -15
- package/dist/gpu-physics/rigid-body-triggers.d.ts +1 -0
- package/dist/gpu-physics/rigid-body-triggers.d.ts.map +1 -1
- package/dist/gpu-physics/rigid-body-triggers.js +55 -15
- package/dist/gpu-physics/rigid-body-triggers.js.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.cjs +48 -20
- package/dist/gpu-physics/sphere-world-shaders.d.ts.map +1 -1
- package/dist/gpu-physics/sphere-world-shaders.js +51 -21
- package/dist/gpu-physics/sphere-world-shaders.js.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 -9
- package/dist/gpu-project/projection-program.d.ts.map +1 -1
- package/dist/gpu-project/projection-program.js +1 -8
- package/dist/gpu-project/projection-program.js.map +1 -1
- package/dist/gpu-sql/gpu-sql.cjs +203 -59
- package/dist/gpu-sql/gpu-sql.d.ts +36 -1
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +225 -62
- package/dist/gpu-sql/gpu-sql.js.map +1 -1
- package/dist/gpu-sql/index.cjs.map +3 -3
- package/dist/gpu-sql/index.d.ts +1 -1
- package/dist/gpu-sql/index.d.ts.map +1 -1
- package/dist/utils/float32.cjs +35 -0
- package/dist/utils/float32.d.ts +3 -0
- package/dist/utils/float32.d.ts.map +1 -0
- package/dist/utils/float32.js +16 -0
- package/dist/utils/float32.js.map +1 -0
- package/package.json +4 -4
- package/src/arrow/gpu/arrow-gpu-analytics-adapters.ts +77 -25
- package/src/arrow/gpu/arrow-gpu-analytics-readback.ts +52 -16
- package/src/arrow/gpu/arrow-gpu-table-conversion.ts +46 -1
- package/src/arrow/index.ts +1 -0
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- package/src/gpu-core/index.ts +5 -0
- package/src/gpu-dataframe/gpu-analytics-compiler-utils.ts +7 -10
- package/src/gpu-dataframe/gpu-data-frame-query.ts +106 -25
- package/src/gpu-dataframe/gpu-data-frame.ts +35 -2
- package/src/gpu-dataframe/gpu-expression-shader.ts +172 -58
- package/src/gpu-dataframe/gpu-expression.ts +62 -9
- package/src/gpu-dataframe/gpu-global-aggregation-compiler.ts +6 -2
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +12 -3
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +151 -93
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +469 -52
- package/src/gpu-dataframe/gpu-group-by-query.ts +24 -10
- package/src/gpu-dataframe/gpu-join-compiler.ts +12 -6
- package/src/gpu-dataframe/gpu-query-compiler.ts +60 -18
- package/src/gpu-dataframe/index.ts +1 -1
- package/src/gpu-physics/gpu-physics-batch.ts +19 -13
- package/src/gpu-physics/gpu-physics-ensemble.ts +20 -4
- package/src/gpu-physics/gpu-rigid-body-world.ts +421 -93
- package/src/gpu-physics/index.ts +9 -0
- package/src/gpu-physics/rigid-body-cache-shaders.ts +18 -6
- package/src/gpu-physics/rigid-body-capacity.ts +25 -4
- package/src/gpu-physics/rigid-body-cast-index.ts +277 -0
- package/src/gpu-physics/rigid-body-ensemble-layout.ts +6 -2
- package/src/gpu-physics/rigid-body-ensemble-reset.ts +21 -9
- package/src/gpu-physics/rigid-body-ensemble-shaders.ts +18 -7
- package/src/gpu-physics/rigid-body-ensemble-transaction.ts +31 -13
- package/src/gpu-physics/rigid-body-event-compaction.ts +252 -0
- package/src/gpu-physics/rigid-body-event-snapshot.ts +76 -0
- package/src/gpu-physics/rigid-body-events.ts +63 -25
- package/src/gpu-physics/rigid-body-joints.ts +9 -11
- package/src/gpu-physics/rigid-body-queries.ts +202 -14
- package/src/gpu-physics/rigid-body-shaders.ts +4 -3
- package/src/gpu-physics/rigid-body-triggers.ts +64 -20
- package/src/gpu-physics/sphere-world-shaders.ts +53 -21
- package/src/gpu-project/projection-program.ts +1 -9
- package/src/gpu-sql/gpu-sql.ts +405 -91
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
package/src/gpu-core/index.ts
CHANGED
|
@@ -439,6 +439,8 @@ export type {
|
|
|
439
439
|
|
|
440
440
|
export {GPUBVH} from './gpu-bvh';
|
|
441
441
|
export type {GPUBVHBoundsView, GPUBVHProps, GPUBVHStorageStats, GPUBVHStrategy} from './gpu-bvh';
|
|
442
|
+
export {packGPUBVHBounds} from './gpu-bvh-bounds';
|
|
443
|
+
export type {GPUBVHBoundsInput, GPUBVHPackedBounds} from './gpu-bvh-bounds';
|
|
442
444
|
export {GPUSegmentedBVH} from './gpu-segmented-bvh';
|
|
443
445
|
export type {GPUBVHSegment, GPUSegmentedBVHProps} from './gpu-segmented-bvh';
|
|
444
446
|
|
|
@@ -729,3 +731,6 @@ export type {
|
|
|
729
731
|
GPUGraphGroupAggregationProps,
|
|
730
732
|
GPUGraphReductionProps
|
|
731
733
|
} from './gpu-semantic-aggregation-operation';
|
|
734
|
+
|
|
735
|
+
export {GPUCommandGraphSubmissionPacer} from './gpu-command-graph-submission-pacer';
|
|
736
|
+
export type {GPUCommandGraphSubmissionPacerProps} from './gpu-command-graph-submission-pacer';
|
|
@@ -126,29 +126,26 @@ function validateGPUAnalyticsVectorLayout(vector: GPUVector, name: string): void
|
|
|
126
126
|
export function getGPUAnalyticsSelectionMask<Selection extends GPUTypeMap>(
|
|
127
127
|
context: GPUDataFrameQueryExtensionContext<Selection>,
|
|
128
128
|
name: string,
|
|
129
|
-
id: string
|
|
129
|
+
id: string,
|
|
130
|
+
baseMask = context.selectionMask
|
|
130
131
|
): GraphVectorView<'uint32'> {
|
|
131
132
|
const field = context.table.schema.fields.find(candidate => candidate.name === name);
|
|
132
133
|
if (!field?.nullable) {
|
|
133
|
-
return
|
|
134
|
+
return baseMask;
|
|
134
135
|
}
|
|
135
136
|
const validity = context.validity[name as keyof Selection & string];
|
|
136
137
|
if (!validity) {
|
|
137
|
-
if (
|
|
138
|
-
return
|
|
138
|
+
if (baseMask.length === 0) {
|
|
139
|
+
return baseMask;
|
|
139
140
|
}
|
|
140
141
|
throw new Error(`GPUDataFrame nullable analytics column "${name}" requires GPU validity`);
|
|
141
142
|
}
|
|
142
143
|
const validityView = context.graph.importGPUVector(`${id}-validity`, validity);
|
|
143
|
-
const output = createTransientVectorView(
|
|
144
|
-
context.graph,
|
|
145
|
-
`${id}-combined-mask`,
|
|
146
|
-
context.selectionMask
|
|
147
|
-
);
|
|
144
|
+
const output = createTransientVectorView(context.graph, `${id}-combined-mask`, baseMask);
|
|
148
145
|
context.graph.add(
|
|
149
146
|
new GPUMask({
|
|
150
147
|
id: `${id}-combine-validity`,
|
|
151
|
-
inputs: [
|
|
148
|
+
inputs: [baseMask, validityView],
|
|
152
149
|
output
|
|
153
150
|
})
|
|
154
151
|
);
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
// SPDX-FileCopyrightText: Copyright (c) vis.gl contributors
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuDF.
|
|
5
5
|
|
|
6
|
+
import type {GPUExpressionNumericValue} from './gpu-expression';
|
|
7
|
+
import {
|
|
8
|
+
getGPUVectorWGSLLayout,
|
|
9
|
+
type GPUVectorWGSLFormat as GPUExpressionNumericFormat
|
|
10
|
+
} from '@luma.gl/graph/gpu-data';
|
|
6
11
|
import type {GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
7
12
|
import type {GPUCommandGraph} from '@luma.gl/graph/gpu-core';
|
|
8
13
|
import type {GPUDataFrame} from './gpu-data-frame';
|
|
9
14
|
import {
|
|
10
15
|
getGPUExpressionColumnNames,
|
|
11
|
-
getGPUExpressionResultFormats,
|
|
12
16
|
GPUExpression,
|
|
13
17
|
isBooleanExpressionNode,
|
|
14
18
|
isGPUScalarFunction,
|
|
@@ -43,14 +47,14 @@ import {
|
|
|
43
47
|
} from './gpu-sort-query';
|
|
44
48
|
|
|
45
49
|
/** Portable scalar storage formats supported by computed dataframe columns. */
|
|
46
|
-
export type GPUDataFrameDerivedColumnFormat =
|
|
50
|
+
export type GPUDataFrameDerivedColumnFormat = GPUExpressionNumericFormat;
|
|
47
51
|
|
|
48
52
|
/** Immutable numerical expression materialized only when its dataframe query is compiled. */
|
|
49
53
|
export type GPUDataFrameDerivedColumn = Readonly<{
|
|
50
54
|
/** Logical dataframe field name, distinct from every existing source and derived field. */
|
|
51
55
|
name: string;
|
|
52
56
|
/** Numeric expression referencing currently available source or derived columns. */
|
|
53
|
-
expression: GPUExpression<
|
|
57
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>;
|
|
54
58
|
/** Optional explicit scalar format, which must agree with the referenced input format. */
|
|
55
59
|
format?: GPUDataFrameDerivedColumnFormat;
|
|
56
60
|
}>;
|
|
@@ -96,7 +100,10 @@ export class GPUDataFrameQuery<
|
|
|
96
100
|
selectedColumns: readonly SelectedColumns[],
|
|
97
101
|
derivedColumns: readonly GPUDataFrameDerivedColumn[] = []
|
|
98
102
|
) {
|
|
99
|
-
const logicalColumns =
|
|
103
|
+
const {logicalColumns, resolvedColumns} = resolveDataFrameDerivedColumns(
|
|
104
|
+
source,
|
|
105
|
+
derivedColumns
|
|
106
|
+
);
|
|
100
107
|
assertSelectedQueryColumns(selectedColumns, logicalColumns);
|
|
101
108
|
for (const predicate of predicates) {
|
|
102
109
|
assertDataFrameQueryPredicate(source, predicate, logicalColumns, logicalColumns);
|
|
@@ -105,7 +112,7 @@ export class GPUDataFrameQuery<
|
|
|
105
112
|
this.source = source;
|
|
106
113
|
this.predicates = Object.freeze([...predicates]);
|
|
107
114
|
this.selectedColumns = Object.freeze([...selectedColumns]);
|
|
108
|
-
this.derivedColumns = Object.freeze(
|
|
115
|
+
this.derivedColumns = Object.freeze(resolvedColumns);
|
|
109
116
|
Object.freeze(this);
|
|
110
117
|
}
|
|
111
118
|
|
|
@@ -145,6 +152,17 @@ export class GPUDataFrameQuery<
|
|
|
145
152
|
}
|
|
146
153
|
|
|
147
154
|
/** Adds one selected derived column without allocating GPU storage or retaining source leases. */
|
|
155
|
+
withColumn<
|
|
156
|
+
Name extends string,
|
|
157
|
+
ReferencedColumns extends SelectedColumns,
|
|
158
|
+
Format extends GPUDataFrameDerivedColumnFormat
|
|
159
|
+
>(
|
|
160
|
+
name: Name,
|
|
161
|
+
expression: GPUExpression<GPUExpressionNumericValue, ReferencedColumns> & {
|
|
162
|
+
readonly node: {readonly kind: 'cast'; readonly format: Format};
|
|
163
|
+
},
|
|
164
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
165
|
+
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source>;
|
|
148
166
|
withColumn<
|
|
149
167
|
Name extends string,
|
|
150
168
|
ReferencedColumns extends SelectedColumns,
|
|
@@ -155,6 +173,23 @@ export class GPUDataFrameQuery<
|
|
|
155
173
|
>(
|
|
156
174
|
name: Name,
|
|
157
175
|
expression: GPUExpression<number | null, ReferencedColumns>,
|
|
176
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
177
|
+
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source>;
|
|
178
|
+
withColumn<Name extends string, Format extends GPUDataFrameDerivedColumnFormat>(
|
|
179
|
+
name: Name,
|
|
180
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
181
|
+
options: GPUDataFrameDerivedColumnOptions<Format> & {format: Format}
|
|
182
|
+
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source>;
|
|
183
|
+
withColumn<
|
|
184
|
+
Name extends string,
|
|
185
|
+
ReferencedColumns extends SelectedColumns,
|
|
186
|
+
Format extends GPUDataFrameDerivedColumnFormat = GPUDataFrameDerivedColumnFormatForExpression<
|
|
187
|
+
Logical,
|
|
188
|
+
ReferencedColumns
|
|
189
|
+
>
|
|
190
|
+
>(
|
|
191
|
+
name: Name,
|
|
192
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
158
193
|
options: GPUDataFrameDerivedColumnOptions<Format> = {}
|
|
159
194
|
): GPUDataFrameQuery<Logical & Record<Name, Format>, SelectedColumns | Name, Source> {
|
|
160
195
|
assertDataFrameDerivedColumnName(name);
|
|
@@ -320,10 +355,11 @@ export function assertDataFrameQueryPredicate<T extends GPUTypeMap>(
|
|
|
320
355
|
}
|
|
321
356
|
|
|
322
357
|
/** Validates computed definitions in dependency order and returns all available logical fields. */
|
|
323
|
-
function
|
|
358
|
+
function resolveDataFrameDerivedColumns<T extends GPUTypeMap>(
|
|
324
359
|
source: GPUDataFrame<T>,
|
|
325
360
|
derivedColumns: readonly GPUDataFrameDerivedColumn[]
|
|
326
|
-
)
|
|
361
|
+
) {
|
|
362
|
+
const resolvedColumns: GPUDataFrameDerivedColumn[] = [];
|
|
327
363
|
const logicalColumns = [...source.columnNames];
|
|
328
364
|
const logicalFormats = new Map<string, string | undefined>(
|
|
329
365
|
source.schema.fields.map(
|
|
@@ -338,35 +374,23 @@ function assertDataFrameDerivedColumns<T extends GPUTypeMap>(
|
|
|
338
374
|
}
|
|
339
375
|
assertDataFrameDerivedExpression(derivedColumn.expression, logicalColumns);
|
|
340
376
|
|
|
341
|
-
const
|
|
342
|
-
derivedColumn.expression.node,
|
|
343
|
-
logicalFormats
|
|
344
|
-
);
|
|
345
|
-
if (referencedFormats.size > 1) {
|
|
346
|
-
throw new Error(`GPUDataFrame derived column "${derivedColumn.name}" mixes scalar formats`);
|
|
347
|
-
}
|
|
348
|
-
const inferredFormat = referencedFormats.values().next().value ?? 'float32';
|
|
349
|
-
if (
|
|
350
|
-
inferredFormat !== 'float32' &&
|
|
351
|
-
inferredFormat !== 'sint32' &&
|
|
352
|
-
inferredFormat !== 'uint32'
|
|
353
|
-
) {
|
|
354
|
-
throw new Error(`GPUDataFrame derived column "${derivedColumn.name}" requires scalar inputs`);
|
|
355
|
-
}
|
|
377
|
+
const inferredFormat =
|
|
378
|
+
inferNumericFormat(derivedColumn.expression.node, logicalFormats) ?? 'float32';
|
|
356
379
|
if (derivedColumn.format !== undefined && derivedColumn.format !== inferredFormat) {
|
|
357
380
|
throw new Error(`GPUDataFrame derived column "${derivedColumn.name}" format does not match`);
|
|
358
381
|
}
|
|
359
382
|
|
|
383
|
+
resolvedColumns.push(Object.freeze({...derivedColumn, format: inferredFormat}));
|
|
360
384
|
logicalFormats.set(derivedColumn.name, inferredFormat);
|
|
361
385
|
logicalColumns.push(derivedColumn.name);
|
|
362
386
|
}
|
|
363
387
|
|
|
364
|
-
return logicalColumns;
|
|
388
|
+
return {logicalColumns, resolvedColumns};
|
|
365
389
|
}
|
|
366
390
|
|
|
367
391
|
/** Validates one numerical derived expression against its currently selected logical inputs. */
|
|
368
392
|
function assertDataFrameDerivedExpression(
|
|
369
|
-
expression: GPUExpression<
|
|
393
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
370
394
|
selectedColumns: readonly string[]
|
|
371
395
|
): void {
|
|
372
396
|
if (!(expression instanceof GPUExpression) || !isNumericExpressionNode(expression.node)) {
|
|
@@ -431,7 +455,9 @@ function isNumericExpressionNode(node: GPUExpressionNode): boolean {
|
|
|
431
455
|
isNumericExpressionNode(node.otherwise)
|
|
432
456
|
);
|
|
433
457
|
case 'cast':
|
|
434
|
-
return
|
|
458
|
+
return isNumericExpressionNode(node.operand);
|
|
459
|
+
case 'vector':
|
|
460
|
+
return node.components.every(isNumericExpressionNode);
|
|
435
461
|
case 'column':
|
|
436
462
|
return true;
|
|
437
463
|
case 'literal':
|
|
@@ -452,3 +478,58 @@ function isNumericExpressionNode(node: GPUExpressionNode): boolean {
|
|
|
452
478
|
return false;
|
|
453
479
|
}
|
|
454
480
|
}
|
|
481
|
+
|
|
482
|
+
/** Checks numeric shape and explicit casts before any GPU resources are allocated. */
|
|
483
|
+
function inferNumericFormat(
|
|
484
|
+
node: GPUExpressionNode,
|
|
485
|
+
formats: ReadonlyMap<string, string | undefined>
|
|
486
|
+
): GPUExpressionNumericFormat | undefined {
|
|
487
|
+
switch (node.kind) {
|
|
488
|
+
case 'vector': {
|
|
489
|
+
const layout = getGPUVectorWGSLLayout(node.format);
|
|
490
|
+
if (layout.components === 1 || node.components.length !== layout.components)
|
|
491
|
+
throw new Error('Vector width must match its format');
|
|
492
|
+
for (const component of node.components) {
|
|
493
|
+
if (
|
|
494
|
+
getGPUVectorWGSLLayout(inferNumericFormat(component, formats) ?? 'float32').components !==
|
|
495
|
+
1
|
|
496
|
+
)
|
|
497
|
+
throw new Error('Vector components must be scalar');
|
|
498
|
+
}
|
|
499
|
+
return node.format;
|
|
500
|
+
}
|
|
501
|
+
case 'cast': {
|
|
502
|
+
const source = inferNumericFormat(node.operand, formats) ?? 'float32';
|
|
503
|
+
if (
|
|
504
|
+
getGPUVectorWGSLLayout(source).components !== getGPUVectorWGSLLayout(node.format).components
|
|
505
|
+
)
|
|
506
|
+
throw new Error('Numeric casts must preserve width');
|
|
507
|
+
return node.format;
|
|
508
|
+
}
|
|
509
|
+
case 'column': {
|
|
510
|
+
const format = formats.get(node.name) as GPUExpressionNumericFormat;
|
|
511
|
+
getGPUVectorWGSLLayout(format);
|
|
512
|
+
return format;
|
|
513
|
+
}
|
|
514
|
+
case 'literal':
|
|
515
|
+
case 'parameter':
|
|
516
|
+
if (typeof node.value === 'boolean') throw new Error('Numeric expression required');
|
|
517
|
+
return undefined;
|
|
518
|
+
case 'unary':
|
|
519
|
+
if (isGPUScalarFunction(node.operator))
|
|
520
|
+
return inferNumericFormat(node.operand, formats) ?? 'float32';
|
|
521
|
+
if (node.operator !== 'negate') throw new Error('Numeric expression required');
|
|
522
|
+
return inferNumericFormat(node.operand, formats);
|
|
523
|
+
case 'binary':
|
|
524
|
+
case 'conditional': {
|
|
525
|
+
const left = inferNumericFormat(node.kind === 'binary' ? node.left : node.whenTrue, formats);
|
|
526
|
+
const right = inferNumericFormat(
|
|
527
|
+
node.kind === 'binary' ? node.right : node.otherwise,
|
|
528
|
+
formats
|
|
529
|
+
);
|
|
530
|
+
if (left && right && left !== right)
|
|
531
|
+
throw new Error('GPUDataFrame derived column mixes scalar formats');
|
|
532
|
+
return left ?? right;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// SPDX-FileComment: Independently implemented for WebGPU; inspired by NVIDIA RAPIDS cuDF.
|
|
5
5
|
|
|
6
6
|
import type {BufferLayout} from '@luma.gl/core';
|
|
7
|
+
import type {GPUExpressionNumericValue} from './gpu-expression';
|
|
7
8
|
import {GPUData, GPUVector, type GPUVectorFormat} from '@luma.gl/graph/gpu-data';
|
|
8
9
|
import {
|
|
9
10
|
GPURecordBatch,
|
|
@@ -196,6 +197,17 @@ export class GPUDataFrame<T extends GPUTypeMap = GPUTypeMap> {
|
|
|
196
197
|
}
|
|
197
198
|
|
|
198
199
|
/** Plans one selected numeric derived column without allocating or submitting GPU work. */
|
|
200
|
+
withColumn<
|
|
201
|
+
Name extends string,
|
|
202
|
+
ReferencedColumns extends keyof T & string,
|
|
203
|
+
Format extends GPUDataFrameDerivedColumnFormat
|
|
204
|
+
>(
|
|
205
|
+
name: Name,
|
|
206
|
+
expression: GPUExpression<GPUExpressionNumericValue, ReferencedColumns> & {
|
|
207
|
+
readonly node: {readonly kind: 'cast'; readonly format: Format};
|
|
208
|
+
},
|
|
209
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
210
|
+
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>;
|
|
199
211
|
withColumn<
|
|
200
212
|
Name extends string,
|
|
201
213
|
ReferencedColumns extends keyof T & string,
|
|
@@ -206,11 +218,32 @@ export class GPUDataFrame<T extends GPUTypeMap = GPUTypeMap> {
|
|
|
206
218
|
>(
|
|
207
219
|
name: Name,
|
|
208
220
|
expression: GPUExpression<number | null, ReferencedColumns>,
|
|
221
|
+
options?: GPUDataFrameDerivedColumnOptions<Format>
|
|
222
|
+
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>;
|
|
223
|
+
withColumn<Name extends string, Format extends GPUDataFrameDerivedColumnFormat>(
|
|
224
|
+
name: Name,
|
|
225
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
226
|
+
options: GPUDataFrameDerivedColumnOptions<Format> & {format: Format}
|
|
227
|
+
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>;
|
|
228
|
+
withColumn<
|
|
229
|
+
Name extends string,
|
|
230
|
+
ReferencedColumns extends keyof T & string,
|
|
231
|
+
Format extends GPUDataFrameDerivedColumnFormat = GPUDataFrameDerivedColumnFormatForExpression<
|
|
232
|
+
T,
|
|
233
|
+
ReferencedColumns
|
|
234
|
+
>
|
|
235
|
+
>(
|
|
236
|
+
name: Name,
|
|
237
|
+
expression: GPUExpression<GPUExpressionNumericValue | boolean, string>,
|
|
209
238
|
options: GPUDataFrameDerivedColumnOptions<Format> = {}
|
|
210
239
|
): GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T> {
|
|
211
240
|
this.assertAvailable();
|
|
212
|
-
|
|
213
|
-
|
|
241
|
+
return new GPUDataFrameQuery<T & Record<Name, Format>, (keyof T & string) | Name, T>(
|
|
242
|
+
this,
|
|
243
|
+
[],
|
|
244
|
+
[...this.columnNames, name],
|
|
245
|
+
[Object.freeze({name, expression, ...options})]
|
|
246
|
+
);
|
|
214
247
|
}
|
|
215
248
|
|
|
216
249
|
/** Plans dense unsigned grouping without allocating GPU resources or retaining source leases. */
|