@luma.gl/graph 10.0.0-beta.2 → 10.0.0-beta.4
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 +82 -23
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts +16 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js +98 -24
- package/dist/arrow/gpu/arrow-gpu-table-conversion.js.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.cjs +7 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts +2 -0
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.d.ts.map +1 -1
- package/dist/arrow/gpu/arrow-gpu-vector-conversion.js +14 -0
- package/dist/arrow/gpu/arrow-gpu-vector-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/arrow/vectors/arrow-temporal-gpu-vector.cjs +1 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js +2 -2
- package/dist/arrow/vectors/arrow-temporal-gpu-vector.js.map +1 -1
- package/dist/dist.dev.js +62 -27
- package/dist/dist.min.js +48 -47
- 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-budget-controller.cjs +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts +4 -0
- package/dist/gpu-core/gpu-command-graph-budget-controller.d.ts.map +1 -1
- package/dist/gpu-core/gpu-command-graph-budget-controller.js +10 -2
- package/dist/gpu-core/gpu-command-graph-budget-controller.js.map +1 -1
- 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/gpu-group-aggregation.cjs +45 -21
- package/dist/gpu-core/gpu-group-aggregation.d.ts +4 -0
- package/dist/gpu-core/gpu-group-aggregation.d.ts.map +1 -1
- package/dist/gpu-core/gpu-group-aggregation.js +58 -24
- package/dist/gpu-core/gpu-group-aggregation.js.map +1 -1
- 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 +8 -4
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts +2 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-aggregation-compiler.js +10 -4
- 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 +156 -124
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts +12 -2
- package/dist/gpu-dataframe/gpu-global-sort-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js +160 -128
- package/dist/gpu-dataframe/gpu-global-sort-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.cjs +366 -53
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts +26 -4
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js +378 -47
- package/dist/gpu-dataframe/gpu-group-aggregation-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.cjs +20 -9
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts +15 -2
- package/dist/gpu-dataframe/gpu-group-by-query.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-group-by-query.js +22 -8
- package/dist/gpu-dataframe/gpu-group-by-query.js.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.cjs +61 -8
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts +10 -2
- package/dist/gpu-dataframe/gpu-join-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-join-compiler.js +60 -7
- package/dist/gpu-dataframe/gpu-join-compiler.js.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.cjs +61 -11
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts +5 -1
- package/dist/gpu-dataframe/gpu-query-compiler.d.ts.map +1 -1
- package/dist/gpu-dataframe/gpu-query-compiler.js +61 -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-graph/index.cjs.map +1 -1
- package/dist/gpu-graph-algorithms/benchmarks.cjs.map +2 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.cjs +182 -62
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts +29 -2
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js +200 -64
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.js.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.cjs +135 -9
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts +55 -8
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.d.ts.map +1 -1
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js +145 -14
- package/dist/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.js.map +1 -1
- package/dist/gpu-graph-algorithms/index.cjs.map +3 -3
- package/dist/gpu-physics/articulation-tree-shader.cjs +177 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts +3 -0
- package/dist/gpu-physics/articulation-tree-shader.d.ts.map +1 -0
- package/dist/gpu-physics/articulation-tree-shader.js +159 -0
- package/dist/gpu-physics/articulation-tree-shader.js.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.cjs +203 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts +81 -0
- package/dist/gpu-physics/gpu-articulation-tree.d.ts.map +1 -0
- package/dist/gpu-physics/gpu-articulation-tree.js +205 -0
- package/dist/gpu-physics/gpu-articulation-tree.js.map +1 -0
- 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 +323 -68
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts +59 -2
- package/dist/gpu-physics/gpu-rigid-body-world.d.ts.map +1 -1
- package/dist/gpu-physics/gpu-rigid-body-world.js +400 -75
- package/dist/gpu-physics/gpu-rigid-body-world.js.map +1 -1
- package/dist/gpu-physics/index.cjs +3 -0
- package/dist/gpu-physics/index.cjs.map +3 -3
- package/dist/gpu-physics/index.d.ts +3 -1
- package/dist/gpu-physics/index.d.ts.map +1 -1
- package/dist/gpu-physics/index.js +1 -0
- 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 +2 -0
- 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/graph.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-simple-graph/index.cjs.map +2 -2
- package/dist/gpu-sql/gpu-sql.cjs +345 -81
- package/dist/gpu-sql/gpu-sql.d.ts +42 -2
- package/dist/gpu-sql/gpu-sql.d.ts.map +1 -1
- package/dist/gpu-sql/gpu-sql.js +393 -90
- 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/index.cjs.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 +8 -8
- 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 +130 -31
- package/src/arrow/gpu/arrow-gpu-vector-conversion.ts +19 -0
- package/src/arrow/index.ts +1 -0
- package/src/arrow/vectors/arrow-temporal-gpu-vector.ts +2 -2
- package/src/gpu-core/gpu-bvh-bounds.ts +84 -0
- package/src/gpu-core/gpu-command-graph-budget-controller.ts +22 -2
- package/src/gpu-core/gpu-command-graph-submission-pacer.ts +102 -0
- package/src/gpu-core/gpu-group-aggregation.ts +68 -30
- 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 +15 -4
- package/src/gpu-dataframe/gpu-global-aggregation-query.ts +12 -3
- package/src/gpu-dataframe/gpu-global-sort-compiler.ts +231 -156
- package/src/gpu-dataframe/gpu-group-aggregation-compiler.ts +645 -61
- package/src/gpu-dataframe/gpu-group-by-query.ts +51 -14
- package/src/gpu-dataframe/gpu-join-compiler.ts +87 -6
- package/src/gpu-dataframe/gpu-query-compiler.ts +100 -18
- package/src/gpu-dataframe/index.ts +1 -1
- package/src/gpu-graph-algorithms/README.md +4 -2
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path-internals.ts +248 -66
- package/src/gpu-graph-algorithms/gpu-graph-single-source-shortest-path.ts +218 -20
- package/src/gpu-physics/articulation-tree-shader.ts +169 -0
- package/src/gpu-physics/gpu-articulation-tree.ts +279 -0
- 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 +510 -93
- package/src/gpu-physics/index.ts +16 -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 +11 -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 +629 -124
- package/src/gpu-sql/index.ts +1 -1
- package/src/utils/float32.ts +16 -0
|
@@ -6,22 +6,46 @@
|
|
|
6
6
|
import {Buffer, type Device} from '@luma.gl/core';
|
|
7
7
|
import {GPUData, GPUVector} from '@luma.gl/graph/gpu-data';
|
|
8
8
|
import {GPURecordBatch, GPUTable, type GPUField, type GPUTypeMap} from '@luma.gl/graph/gpu-tables';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
import {
|
|
10
|
+
GraphVectorView,
|
|
11
|
+
type GPUCommandGraph,
|
|
12
|
+
type GraphDataView,
|
|
13
|
+
type GraphBufferUse
|
|
14
|
+
} from '@luma.gl/graph/gpu-core';
|
|
15
|
+
import {
|
|
16
|
+
GPUGroupAggregation,
|
|
17
|
+
GPUGather,
|
|
18
|
+
GPUReduction,
|
|
19
|
+
GPUScan,
|
|
20
|
+
GPUSort,
|
|
21
|
+
createTransientView
|
|
22
|
+
} from '@luma.gl/graph/gpu-core';
|
|
23
|
+
import {GPUMask, GPUVisibilityWorkflow} from '@luma.gl/graph/gpu-core';
|
|
24
|
+
import {
|
|
25
|
+
createTransientVectorView,
|
|
26
|
+
getViewElementOffset,
|
|
27
|
+
validatePackedUint32View
|
|
28
|
+
} from '@luma.gl/graph/gpu-core';
|
|
13
29
|
import {
|
|
14
30
|
LU_ANALYTICS_WORKGROUP_SIZE,
|
|
31
|
+
type GPUAnalyticsScalarFormat,
|
|
15
32
|
addGPUAnalyticsComputePass,
|
|
16
33
|
getGPUAnalyticsInvocationIndexSource,
|
|
34
|
+
getGPUAnalyticsSelectionMask,
|
|
17
35
|
validateGPUAnalyticsOutputLength
|
|
18
36
|
} from './gpu-analytics-compiler-utils';
|
|
19
|
-
import
|
|
37
|
+
import {
|
|
38
|
+
GPUDataFrame,
|
|
39
|
+
type GPUDataFrameDictionaries,
|
|
40
|
+
type GPUDataFrameValidity
|
|
41
|
+
} from './gpu-data-frame';
|
|
20
42
|
import type {GPUDataFrameDerivedColumn} from './gpu-data-frame-query';
|
|
21
43
|
import type {GPUExpression} from './gpu-expression';
|
|
22
44
|
import type {GPUDataFrameAggregationDefinition} from './gpu-group-by-query';
|
|
23
45
|
import {
|
|
46
|
+
addGPUDataFrameResultPredicate,
|
|
24
47
|
CompiledGPUDataFrameQuery,
|
|
48
|
+
projectGPUDataFrameQueryResult,
|
|
25
49
|
compileGPUDataFrameQuery,
|
|
26
50
|
type CompiledGPUDataFrameQueryProps,
|
|
27
51
|
type GPUDataFrameQueryExtensionContext,
|
|
@@ -29,6 +53,10 @@ import {
|
|
|
29
53
|
type GPUDataFrameQueryParameters
|
|
30
54
|
} from './gpu-query-compiler';
|
|
31
55
|
|
|
56
|
+
import {addGPUGlobalOrdering, type GPUGlobalSortKey} from './gpu-global-sort-compiler';
|
|
57
|
+
|
|
58
|
+
import {prepareGPUJoinAggregation, type GPUAggregateJoin} from './gpu-join-compiler';
|
|
59
|
+
|
|
32
60
|
const UINT32_BYTE_LENGTH = Uint32Array.BYTES_PER_ELEMENT;
|
|
33
61
|
const MAXIMUM_UINT32 = 0xffffffff;
|
|
34
62
|
|
|
@@ -42,16 +70,83 @@ type GPUGroupedMetricState = {
|
|
|
42
70
|
export class CompiledGPUDataFrameGroupedAggregation<
|
|
43
71
|
T extends GPUTypeMap = GPUTypeMap
|
|
44
72
|
> extends CompiledGPUDataFrameQuery<T> {
|
|
45
|
-
/**
|
|
73
|
+
/** Result table capacity. Observed grouping publishes the actual count in selectedCounts. */
|
|
46
74
|
readonly groupCount: number;
|
|
47
75
|
|
|
76
|
+
/** Group row indices in global ORDER BY order, when requested. */
|
|
77
|
+
readonly globalRowIndices?: GPUVector<'uint32'>;
|
|
78
|
+
/** Number of groups left after applying the page, when ordered. */
|
|
79
|
+
readonly globalSelectedCount?: GPUVector<'uint32'>;
|
|
80
|
+
|
|
48
81
|
/** @internal */
|
|
49
|
-
constructor(
|
|
82
|
+
constructor(
|
|
83
|
+
props: CompiledGPUDataFrameQueryProps<T>,
|
|
84
|
+
groupCount: number,
|
|
85
|
+
ordering?: ReturnType<typeof addGPUGlobalOrdering>
|
|
86
|
+
) {
|
|
50
87
|
super(props);
|
|
51
88
|
this.groupCount = groupCount;
|
|
89
|
+
this.globalRowIndices = ordering?.globalRowIndices;
|
|
90
|
+
this.globalSelectedCount = ordering?.globalSelectedCount;
|
|
52
91
|
}
|
|
53
92
|
}
|
|
54
93
|
|
|
94
|
+
/** Output names and order for grouped SQL projections. @internal */
|
|
95
|
+
export type GPUGroupedOutputProjection = Readonly<{
|
|
96
|
+
/** Name of the grouped key in the output schema. */
|
|
97
|
+
key: string;
|
|
98
|
+
/** Output names in SELECT order. */
|
|
99
|
+
columns: readonly string[];
|
|
100
|
+
}>;
|
|
101
|
+
|
|
102
|
+
/** Ordered source keys and their corresponding output fields. */
|
|
103
|
+
type GPUGroupingKeys = readonly Readonly<{source: string; output?: string}>[];
|
|
104
|
+
|
|
105
|
+
/** Adds observed numeric and composite grouping bounded by the source row count. @internal */
|
|
106
|
+
export function compileGPUDataFrameObservedAggregation(
|
|
107
|
+
source: GPUDataFrame,
|
|
108
|
+
predicates: readonly GPUExpression<boolean, string>[],
|
|
109
|
+
selectedColumns: readonly string[],
|
|
110
|
+
derivedColumns: readonly GPUDataFrameDerivedColumn[],
|
|
111
|
+
keys: GPUGroupingKeys,
|
|
112
|
+
definitions: readonly GPUDataFrameAggregationDefinition[],
|
|
113
|
+
graph: GPUCommandGraph<GPUDataFrameQueryParameters>,
|
|
114
|
+
columns: readonly string[],
|
|
115
|
+
ordering?: readonly GPUGlobalSortKey[],
|
|
116
|
+
having?: GPUExpression<boolean, string>,
|
|
117
|
+
join?: GPUAggregateJoin,
|
|
118
|
+
maxMeanScratchBytes?: number
|
|
119
|
+
): CompiledGPUDataFrameGroupedAggregation {
|
|
120
|
+
if (source.numRows > 0) validateGPUGroupingCapacity(source, source.numRows, graph);
|
|
121
|
+
validateGPUGroupingSourceColumns(
|
|
122
|
+
source,
|
|
123
|
+
keys.map(key => key.source),
|
|
124
|
+
definitions
|
|
125
|
+
);
|
|
126
|
+
return compileGPUDataFrameQuery<
|
|
127
|
+
GPUTypeMap,
|
|
128
|
+
GPUTypeMap,
|
|
129
|
+
GPUTypeMap,
|
|
130
|
+
CompiledGPUDataFrameGroupedAggregation
|
|
131
|
+
>(source, predicates, selectedColumns, graph, derivedColumns, {
|
|
132
|
+
prepare: context => {
|
|
133
|
+
const prepare = (input: typeof context) =>
|
|
134
|
+
addGPUGroupedAggregationToGraph(
|
|
135
|
+
input,
|
|
136
|
+
keys,
|
|
137
|
+
source.numRows,
|
|
138
|
+
definitions,
|
|
139
|
+
columns,
|
|
140
|
+
true,
|
|
141
|
+
ordering,
|
|
142
|
+
having,
|
|
143
|
+
maxMeanScratchBytes
|
|
144
|
+
);
|
|
145
|
+
return join ? prepareGPUJoinAggregation(source, context, join, prepare) : prepare(context);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
55
150
|
/** Adds dense categorical aggregation to source-row work before the shared graph is frozen. */
|
|
56
151
|
export function compileGPUDataFrameGroupedAggregation<
|
|
57
152
|
Source extends GPUTypeMap,
|
|
@@ -65,30 +160,50 @@ export function compileGPUDataFrameGroupedAggregation<
|
|
|
65
160
|
key: keyof Selection & string,
|
|
66
161
|
groupCount: number,
|
|
67
162
|
definitions: readonly GPUDataFrameAggregationDefinition[],
|
|
68
|
-
graph: GPUCommandGraph<GPUDataFrameQueryParameters
|
|
163
|
+
graph: GPUCommandGraph<GPUDataFrameQueryParameters>,
|
|
164
|
+
projection?: GPUGroupedOutputProjection,
|
|
165
|
+
ordering?: readonly GPUGlobalSortKey<keyof Result & string>[],
|
|
166
|
+
having?: GPUExpression<boolean, string>,
|
|
167
|
+
join?: GPUAggregateJoin,
|
|
168
|
+
maxMeanScratchBytes?: number
|
|
69
169
|
): CompiledGPUDataFrameGroupedAggregation<Result> {
|
|
70
170
|
validateGPUGroupingCapacity(source, groupCount, graph);
|
|
71
|
-
validateGPUGroupingSourceColumns(source, key, definitions);
|
|
171
|
+
validateGPUGroupingSourceColumns(source, [key], definitions);
|
|
72
172
|
return compileGPUDataFrameQuery<
|
|
73
173
|
Source,
|
|
74
174
|
Selection,
|
|
75
175
|
Result,
|
|
76
176
|
CompiledGPUDataFrameGroupedAggregation<Result>
|
|
77
177
|
>(source, predicates, selectedColumns, graph, derivedColumns, {
|
|
78
|
-
prepare: context =>
|
|
79
|
-
|
|
178
|
+
prepare: context => {
|
|
179
|
+
const prepare = (input: typeof context) =>
|
|
180
|
+
addGPUGroupedAggregationToGraph<Selection, Result>(
|
|
181
|
+
input,
|
|
182
|
+
[{source: key, output: projection?.key ?? key}],
|
|
183
|
+
groupCount,
|
|
184
|
+
definitions,
|
|
185
|
+
projection?.columns,
|
|
186
|
+
false,
|
|
187
|
+
ordering,
|
|
188
|
+
having,
|
|
189
|
+
maxMeanScratchBytes
|
|
190
|
+
);
|
|
191
|
+
return join ? prepareGPUJoinAggregation(source, context, join, prepare) : prepare(context);
|
|
192
|
+
}
|
|
80
193
|
});
|
|
81
194
|
}
|
|
82
195
|
|
|
83
196
|
/** Rejects unsupported constants and explicitly unknown source nullability before GPU allocation. */
|
|
84
197
|
function validateGPUGroupingSourceColumns<Source extends GPUTypeMap>(
|
|
85
198
|
source: GPUDataFrame<Source>,
|
|
86
|
-
|
|
199
|
+
keys: readonly string[],
|
|
87
200
|
definitions: readonly GPUDataFrameAggregationDefinition[]
|
|
88
201
|
): void {
|
|
89
202
|
const columnNames = new Set([
|
|
90
|
-
|
|
91
|
-
...definitions.flatMap(definition =>
|
|
203
|
+
...keys,
|
|
204
|
+
...definitions.flatMap(definition =>
|
|
205
|
+
definition.operation !== 'count' && definition.column ? [definition.column] : []
|
|
206
|
+
)
|
|
92
207
|
]);
|
|
93
208
|
for (const name of columnNames) {
|
|
94
209
|
if (source.table.gpuConstants[name]) {
|
|
@@ -126,40 +241,104 @@ function validateGPUGroupingCapacity<Source extends GPUTypeMap>(
|
|
|
126
241
|
/** Creates grouped buffers, null-aware masks, and one cross-batch primitive per requested metric. */
|
|
127
242
|
function addGPUGroupedAggregationToGraph<Selection extends GPUTypeMap, Result extends GPUTypeMap>(
|
|
128
243
|
context: GPUDataFrameQueryExtensionContext<Selection>,
|
|
129
|
-
|
|
244
|
+
groupingKeys: GPUGroupingKeys,
|
|
130
245
|
groupCount: number,
|
|
131
|
-
definitions: readonly GPUDataFrameAggregationDefinition[]
|
|
246
|
+
definitions: readonly GPUDataFrameAggregationDefinition[],
|
|
247
|
+
columns?: readonly string[],
|
|
248
|
+
observed = false,
|
|
249
|
+
orderBy?: readonly GPUGlobalSortKey<keyof Result & string>[],
|
|
250
|
+
having?: GPUExpression<boolean, string>,
|
|
251
|
+
maxMeanScratchBytes?: number
|
|
132
252
|
): GPUDataFrameQueryExtensionResult<Result, CompiledGPUDataFrameGroupedAggregation<Result>> {
|
|
133
253
|
const graph = context.graph;
|
|
134
254
|
const prefix = `${context.queryId}-group`;
|
|
135
255
|
const ownedVectors: GPUVector[] = [];
|
|
136
256
|
let resultTable: GPUTable<Result> | undefined;
|
|
257
|
+
let projection: GPUDataFrame<Result> | undefined;
|
|
137
258
|
|
|
138
259
|
try {
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
260
|
+
const inputs = groupingKeys.map(({source}, index) =>
|
|
261
|
+
graph.importGPUVector(
|
|
262
|
+
`${prefix}-key-${index}`,
|
|
263
|
+
getGPUGroupingVector(
|
|
264
|
+
context,
|
|
265
|
+
source,
|
|
266
|
+
observed ? getGPUGroupingFormat(context.table, source) : 'uint32'
|
|
267
|
+
)
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
const outputVectors = new Map<string, GPUVector<GPUAnalyticsScalarFormat>>();
|
|
271
|
+
const outputs = groupingKeys.map(({output}, index) => {
|
|
272
|
+
if (output === undefined) return undefined;
|
|
273
|
+
const vector = createGPUGroupedOutputVector(
|
|
274
|
+
graph.device,
|
|
275
|
+
`${prefix}-output-key-${index}`,
|
|
276
|
+
groupCount,
|
|
277
|
+
inputs[index].format
|
|
278
|
+
);
|
|
279
|
+
ownedVectors.push(vector);
|
|
280
|
+
outputVectors.set(output, vector);
|
|
281
|
+
return graph.importGPUVector(`${prefix}-output-key-view-${index}`, vector).data[0];
|
|
282
|
+
});
|
|
283
|
+
const keyValidity = observed
|
|
284
|
+
? undefined
|
|
285
|
+
: getGPUGroupingValidity(context, groupingKeys[0].source, inputs[0]);
|
|
142
286
|
const baseMask = keyValidity
|
|
143
287
|
? combineGPUGroupingMasks(graph, `${prefix}-key-validity`, context.selectionMask, keyValidity)
|
|
144
288
|
: context.selectionMask;
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
289
|
+
const validity: Record<string, GPUVector<'uint32'>> = {};
|
|
290
|
+
const nullableKeys = observed
|
|
291
|
+
? groupingKeys.map(({source, output}, index) => {
|
|
292
|
+
const field = context.table.schema.fields.find(field => field.name === source);
|
|
293
|
+
if (!field?.nullable) return undefined;
|
|
294
|
+
const input = getGPUGroupingValidity(context, source, inputs[index]);
|
|
295
|
+
if (output === undefined) return {input};
|
|
296
|
+
const mask = createGPUGroupedOutputVector(
|
|
297
|
+
graph.device,
|
|
298
|
+
prefix + '-key-mask-' + index,
|
|
299
|
+
groupCount,
|
|
300
|
+
'uint32'
|
|
301
|
+
);
|
|
302
|
+
ownedVectors.push(mask);
|
|
303
|
+
validity[output] = mask;
|
|
304
|
+
return {
|
|
305
|
+
input,
|
|
306
|
+
output: graph.importGPUVector(prefix + '-key-mask-view-' + index, mask).data[0]
|
|
307
|
+
};
|
|
308
|
+
})
|
|
309
|
+
: [];
|
|
310
|
+
let rowSelection = observed
|
|
311
|
+
? addGPUObservedGroups(context, prefix, inputs, outputs, nullableKeys, ownedVectors)
|
|
312
|
+
: undefined;
|
|
313
|
+
const keys = rowSelection?.keys ?? (inputs[0] as GraphVectorView<'uint32'>);
|
|
314
|
+
if (!observed)
|
|
315
|
+
addGPUGroupIdentityPass(
|
|
316
|
+
graph,
|
|
317
|
+
`${prefix}-output-key-identity`,
|
|
318
|
+
outputs[0] as GraphDataView<'uint32'>
|
|
319
|
+
);
|
|
157
320
|
|
|
158
321
|
const metricStates = new Map<string, GPUGroupedMetricState>();
|
|
159
|
-
const validity: Record<string, GPUVector<'uint32'>> = {};
|
|
160
322
|
|
|
161
323
|
for (const [definitionIndex, definition] of definitions.entries()) {
|
|
162
324
|
const metricId = `${prefix}-metric-${definitionIndex}`;
|
|
325
|
+
if (groupCount === 0) {
|
|
326
|
+
const format = definition.operation === 'count' ? 'uint32' : 'float32';
|
|
327
|
+
const output = createGPUGroupedOutputVector(graph.device, metricId, 0, format);
|
|
328
|
+
ownedVectors.push(output);
|
|
329
|
+
outputVectors.set(definition.name, output as GPUVector<'uint32'> | GPUVector<'float32'>);
|
|
330
|
+
if (definition.operation !== 'count') {
|
|
331
|
+
const mask = createGPUGroupedOutputVector(
|
|
332
|
+
graph.device,
|
|
333
|
+
`${metricId}-validity`,
|
|
334
|
+
0,
|
|
335
|
+
'uint32'
|
|
336
|
+
);
|
|
337
|
+
ownedVectors.push(mask);
|
|
338
|
+
validity[definition.name] = mask;
|
|
339
|
+
}
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
163
342
|
if (definition.operation === 'count') {
|
|
164
343
|
const output = createGPUGroupedOutputVector(graph.device, metricId, groupCount, 'uint32');
|
|
165
344
|
ownedVectors.push(output);
|
|
@@ -168,7 +347,9 @@ function addGPUGroupedAggregationToGraph<Selection extends GPUTypeMap, Result ex
|
|
|
168
347
|
new GPUGroupAggregation({
|
|
169
348
|
id: metricId,
|
|
170
349
|
keys,
|
|
171
|
-
mask:
|
|
350
|
+
mask: definition.column
|
|
351
|
+
? getGPUAnalyticsSelectionMask(context, definition.column, metricId, baseMask)
|
|
352
|
+
: baseMask,
|
|
172
353
|
output: graph.importGPUVector(`${metricId}-output`, output).data[0],
|
|
173
354
|
operation: 'count'
|
|
174
355
|
})
|
|
@@ -205,31 +386,174 @@ function addGPUGroupedAggregationToGraph<Selection extends GPUTypeMap, Result ex
|
|
|
205
386
|
values: state.values,
|
|
206
387
|
mask: state.mask,
|
|
207
388
|
output: graph.importGPUVector(`${metricId}-output`, output).data[0],
|
|
208
|
-
operation: definition.operation
|
|
389
|
+
operation: definition.operation,
|
|
390
|
+
maxMeanScratchBytes
|
|
209
391
|
})
|
|
210
392
|
);
|
|
211
393
|
}
|
|
212
394
|
|
|
213
395
|
resultTable = createGPUGroupedResultTable<Selection, Result>(
|
|
214
396
|
context.table,
|
|
215
|
-
|
|
397
|
+
groupingKeys,
|
|
216
398
|
definitions,
|
|
217
|
-
outputVectors
|
|
399
|
+
outputVectors,
|
|
400
|
+
columns && [
|
|
401
|
+
...columns,
|
|
402
|
+
...definitions
|
|
403
|
+
.filter(definition => !columns.includes(definition.name))
|
|
404
|
+
.map(definition => definition.name)
|
|
405
|
+
],
|
|
406
|
+
observed
|
|
218
407
|
);
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
408
|
+
const dictionaries = Object.freeze(
|
|
409
|
+
Object.fromEntries(
|
|
410
|
+
groupingKeys.flatMap(({source, output}) => {
|
|
411
|
+
if (output === undefined) return [];
|
|
412
|
+
const dictionary = context.dictionaries[source as keyof Selection & string];
|
|
413
|
+
return dictionary ? [[output, dictionary]] : [];
|
|
414
|
+
})
|
|
415
|
+
)
|
|
416
|
+
) as Readonly<GPUDataFrameDictionaries<Result>>;
|
|
417
|
+
|
|
418
|
+
if ((orderBy || having) && !rowSelection) {
|
|
419
|
+
const mask = createGPUGroupedOutputVector(
|
|
420
|
+
graph.device,
|
|
421
|
+
prefix + '-dense-mask',
|
|
422
|
+
groupCount,
|
|
423
|
+
'uint32'
|
|
424
|
+
);
|
|
425
|
+
const rows = createGPUGroupedOutputVector(
|
|
426
|
+
graph.device,
|
|
427
|
+
prefix + '-dense-rows',
|
|
428
|
+
groupCount,
|
|
429
|
+
'uint32'
|
|
430
|
+
);
|
|
431
|
+
const count = createGPUGroupedOutputVector(
|
|
432
|
+
graph.device,
|
|
433
|
+
prefix + '-dense-count',
|
|
434
|
+
1,
|
|
435
|
+
'uint32'
|
|
436
|
+
);
|
|
437
|
+
ownedVectors.push(mask, rows, count);
|
|
438
|
+
addGPUGroupingPass(
|
|
439
|
+
graph,
|
|
440
|
+
prefix + '-dense-selection',
|
|
441
|
+
groupCount,
|
|
442
|
+
{},
|
|
443
|
+
{
|
|
444
|
+
mask: graph.importGPUVector(prefix + '-dense-mask-init', mask).data[0],
|
|
445
|
+
rows: graph.importGPUVector(prefix + '-dense-rows-init', rows).data[0],
|
|
446
|
+
count: graph.importGPUVector(prefix + '-dense-count-init', count).data[0]
|
|
447
|
+
},
|
|
448
|
+
`mask[index] = 1u; rows[index] = index; if (index == 0u) { count[0] = ${groupCount}u; }`
|
|
449
|
+
);
|
|
450
|
+
rowSelection = {keys, mask, rows, count};
|
|
451
|
+
}
|
|
452
|
+
if (having && rowSelection && groupCount > 0) {
|
|
453
|
+
const selectionMask = graph.importGPUVector(prefix + '-having-selection', rowSelection.mask);
|
|
454
|
+
const predicateMask = createTransientVectorView(
|
|
455
|
+
graph,
|
|
456
|
+
prefix + '-having-mask',
|
|
457
|
+
selectionMask
|
|
458
|
+
);
|
|
459
|
+
const groupedFrame = new GPUDataFrame({
|
|
460
|
+
table: resultTable,
|
|
461
|
+
validity: validity as GPUDataFrameValidity<Result>,
|
|
462
|
+
dictionaries,
|
|
463
|
+
ownership: 'borrowed'
|
|
464
|
+
});
|
|
465
|
+
try {
|
|
466
|
+
addGPUDataFrameResultPredicate(
|
|
467
|
+
graph,
|
|
468
|
+
prefix + '-having',
|
|
469
|
+
groupedFrame,
|
|
470
|
+
having,
|
|
471
|
+
predicateMask
|
|
472
|
+
);
|
|
473
|
+
} finally {
|
|
474
|
+
groupedFrame.destroy();
|
|
475
|
+
}
|
|
476
|
+
const mask = createGPUGroupedOutputVector(
|
|
477
|
+
graph.device,
|
|
478
|
+
prefix + '-having-result',
|
|
479
|
+
groupCount,
|
|
480
|
+
'uint32'
|
|
481
|
+
);
|
|
482
|
+
ownedVectors.push(mask);
|
|
483
|
+
graph.add(
|
|
484
|
+
new GPUVisibilityWorkflow({
|
|
485
|
+
id: prefix + '-having-filter',
|
|
486
|
+
predicates: [
|
|
487
|
+
{kind: 'selection', mask: selectionMask.data[0]},
|
|
488
|
+
{kind: 'selection', mask: predicateMask.data[0]}
|
|
489
|
+
],
|
|
490
|
+
outputMask: graph.importGPUVector(prefix + '-having-result-view', mask).data[0],
|
|
491
|
+
output: graph.importGPUVector(prefix + '-having-rows', rowSelection.rows).data[0],
|
|
492
|
+
count: graph.importGPUVector(prefix + '-having-count', rowSelection.count).data[0]
|
|
493
|
+
})
|
|
494
|
+
);
|
|
495
|
+
rowSelection = {...rowSelection, mask};
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const ordering =
|
|
499
|
+
orderBy && rowSelection
|
|
500
|
+
? addGPUGlobalOrdering(
|
|
501
|
+
{
|
|
502
|
+
graph,
|
|
503
|
+
queryId: prefix + '-ordered',
|
|
504
|
+
table: resultTable,
|
|
505
|
+
validity: validity as GPUDataFrameValidity<Result>,
|
|
506
|
+
dictionaries,
|
|
507
|
+
selectionMask: graph.importGPUVector(prefix + '-ordered-mask', rowSelection.mask),
|
|
508
|
+
rowIndices: graph.importGPUVector(prefix + '-ordered-rows', rowSelection.rows),
|
|
509
|
+
selectedCounts: graph.importGPUVector(prefix + '-ordered-count', rowSelection.count)
|
|
510
|
+
},
|
|
511
|
+
orderBy,
|
|
512
|
+
ownedVectors,
|
|
513
|
+
prefix + '-ordered'
|
|
514
|
+
)
|
|
515
|
+
: undefined;
|
|
223
516
|
|
|
517
|
+
const resultValidity = Object.freeze(validity) as Readonly<GPUDataFrameValidity<Result>>;
|
|
518
|
+
if (columns && resultTable.schema.fields.length !== columns.length) {
|
|
519
|
+
projection = projectGPUDataFrameQueryResult(
|
|
520
|
+
{table: resultTable, validity: resultValidity, dictionaries},
|
|
521
|
+
columns as readonly (keyof Result & string)[]
|
|
522
|
+
);
|
|
523
|
+
}
|
|
224
524
|
return {
|
|
225
|
-
table: resultTable,
|
|
226
|
-
validity:
|
|
227
|
-
dictionaries,
|
|
228
|
-
ownedTables: [resultTable],
|
|
525
|
+
table: projection?.table ?? resultTable,
|
|
526
|
+
validity: projection?.validity ?? resultValidity,
|
|
527
|
+
dictionaries: projection?.dictionaries ?? dictionaries,
|
|
528
|
+
ownedTables: projection ? [projection, resultTable] : [resultTable],
|
|
229
529
|
ownedVectors,
|
|
230
|
-
createCompiled: props =>
|
|
530
|
+
createCompiled: props =>
|
|
531
|
+
new CompiledGPUDataFrameGroupedAggregation(
|
|
532
|
+
rowSelection
|
|
533
|
+
? {
|
|
534
|
+
...props,
|
|
535
|
+
rowIndices: rowSelection.rows,
|
|
536
|
+
selectedCounts: rowSelection.count,
|
|
537
|
+
selectionMask: rowSelection.mask,
|
|
538
|
+
ownedVectors: [
|
|
539
|
+
...(props.ownedVectors ?? []).filter(
|
|
540
|
+
vector =>
|
|
541
|
+
vector !== rowSelection.rows &&
|
|
542
|
+
vector !== rowSelection.mask &&
|
|
543
|
+
vector !== rowSelection.count
|
|
544
|
+
),
|
|
545
|
+
props.rowIndices,
|
|
546
|
+
props.selectedCounts,
|
|
547
|
+
props.selectionMask
|
|
548
|
+
]
|
|
549
|
+
}
|
|
550
|
+
: props,
|
|
551
|
+
groupCount,
|
|
552
|
+
ordering
|
|
553
|
+
)
|
|
231
554
|
};
|
|
232
555
|
} catch (error) {
|
|
556
|
+
projection?.destroy();
|
|
233
557
|
resultTable?.destroy();
|
|
234
558
|
for (const vector of ownedVectors) {
|
|
235
559
|
vector.destroy();
|
|
@@ -238,8 +562,260 @@ function addGPUGroupedAggregationToGraph<Selection extends GPUTypeMap, Result ex
|
|
|
238
562
|
}
|
|
239
563
|
}
|
|
240
564
|
|
|
241
|
-
/**
|
|
242
|
-
function
|
|
565
|
+
/** Groups observed rows by stable sorts of each value and its separate validity class. */
|
|
566
|
+
function addGPUObservedGroups(
|
|
567
|
+
context: Pick<GPUDataFrameQueryExtensionContext<GPUTypeMap>, 'graph' | 'selectionMask'>,
|
|
568
|
+
prefix: string,
|
|
569
|
+
inputs: readonly GraphVectorView<GPUAnalyticsScalarFormat>[],
|
|
570
|
+
outputs: readonly (GraphDataView<GPUAnalyticsScalarFormat> | undefined)[],
|
|
571
|
+
nullableKeys: readonly (
|
|
572
|
+
| {input?: GraphVectorView<'uint32'>; output?: GraphDataView<'uint32'>}
|
|
573
|
+
| undefined
|
|
574
|
+
)[],
|
|
575
|
+
ownedVectors: GPUVector[]
|
|
576
|
+
): {
|
|
577
|
+
keys: GraphVectorView<'uint32'>;
|
|
578
|
+
rows: GPUVector<'uint32'>;
|
|
579
|
+
count: GPUVector<'uint32'>;
|
|
580
|
+
mask: GPUVector<'uint32'>;
|
|
581
|
+
} {
|
|
582
|
+
const {graph, selectionMask} = context;
|
|
583
|
+
const length = selectionMask.length;
|
|
584
|
+
const allocate = (name: string, size: number) => {
|
|
585
|
+
const vector = createGPUGroupedOutputVector(graph.device, prefix + name, size, 'uint32');
|
|
586
|
+
ownedVectors.push(vector);
|
|
587
|
+
return vector;
|
|
588
|
+
};
|
|
589
|
+
const rows = allocate('-result-rows', length);
|
|
590
|
+
const mask = allocate('-result-mask', length);
|
|
591
|
+
const count = allocate('-result-count', 1);
|
|
592
|
+
const countView = graph.importGPUVector(prefix + '-count-view', count).data[0];
|
|
593
|
+
if (length === 0) {
|
|
594
|
+
addGPUGroupingPass(graph, prefix + '-empty', 1, {}, {count: countView}, 'count[0] = 0u;');
|
|
595
|
+
return {keys: selectionMask, rows, count, mask};
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
const words = (view: GraphDataView<GPUAnalyticsScalarFormat>) => {
|
|
599
|
+
const packed = graph.createDataView(view.buffer, {
|
|
600
|
+
format: 'uint32',
|
|
601
|
+
length: view.length,
|
|
602
|
+
byteOffset: view.byteOffset,
|
|
603
|
+
byteStride: view.byteStride
|
|
604
|
+
});
|
|
605
|
+
validatePackedUint32View(packed, prefix + '-key');
|
|
606
|
+
return packed;
|
|
607
|
+
};
|
|
608
|
+
const scratch = (name: string) => createTransientView(graph, prefix + name, 'uint32', length);
|
|
609
|
+
const staged = inputs.map((input, index) => ({
|
|
610
|
+
input,
|
|
611
|
+
values: scratch('-values-' + index),
|
|
612
|
+
classes: scratch('-classes-' + index)
|
|
613
|
+
}));
|
|
614
|
+
const orders = [scratch('-order-a'), scratch('-order-b')];
|
|
615
|
+
const gathered = scratch('-gathered');
|
|
616
|
+
const sortedValues = scratch('-sorted-values');
|
|
617
|
+
const heads = scratch('-heads');
|
|
618
|
+
const ranks = scratch('-ranks');
|
|
619
|
+
const groupIds = scratch('-group-ids');
|
|
620
|
+
|
|
621
|
+
let offset = 0;
|
|
622
|
+
for (const [batchIndex, selection] of selectionMask.data.entries()) {
|
|
623
|
+
if (selection.length > 0) {
|
|
624
|
+
for (const [index, {input, values, classes}] of staged.entries()) {
|
|
625
|
+
const validity = nullableKeys[index]?.input?.data[batchIndex];
|
|
626
|
+
addGPUGroupingPass(
|
|
627
|
+
graph,
|
|
628
|
+
prefix + '-stage-' + batchIndex + '-' + index,
|
|
629
|
+
selection.length,
|
|
630
|
+
{
|
|
631
|
+
input: words(input.data[batchIndex]),
|
|
632
|
+
...(index === 0 ? {selection} : {}),
|
|
633
|
+
...(validity ? {validity} : {})
|
|
634
|
+
},
|
|
635
|
+
{values, classes, ...(index === 0 ? {ordinals: orders[0]} : {})},
|
|
636
|
+
`
|
|
637
|
+
let row = ${offset}u + index;
|
|
638
|
+
let raw = input[index];
|
|
639
|
+
let valid = ${validity ? 'validity[index] != 0u' : 'true'};
|
|
640
|
+
let category = ${index === 0 ? 'select(2u, u32(!valid), selection[index] != 0u)' : 'u32(!valid)'};
|
|
641
|
+
${
|
|
642
|
+
input.format === 'float32'
|
|
643
|
+
? `
|
|
644
|
+
let magnitude = raw & 0x7fffffffu;
|
|
645
|
+
let canonical = select(select(raw, 0u, magnitude == 0u), 0x7fc00000u, magnitude > 0x7f800000u);
|
|
646
|
+
`
|
|
647
|
+
: 'let canonical = raw;'
|
|
648
|
+
}
|
|
649
|
+
values[row] = select(0u, canonical, valid);
|
|
650
|
+
classes[row] = category;
|
|
651
|
+
${index === 0 ? 'ordinals[row] = row;' : ''}
|
|
652
|
+
`
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
offset += selection.length;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
let orderIndex = 0;
|
|
660
|
+
for (let index = staged.length - 1; index >= 0; index--) {
|
|
661
|
+
const {values, classes} = staged[index];
|
|
662
|
+
const sortKeys = index === 0 || nullableKeys[index] ? [values, classes] : [values];
|
|
663
|
+
for (const [passIndex, source] of sortKeys.entries()) {
|
|
664
|
+
const id = prefix + '-order-' + index + '-' + passIndex;
|
|
665
|
+
graph.add(
|
|
666
|
+
new GPUGather({id: id + '-gather', source, indices: orders[orderIndex], output: gathered})
|
|
667
|
+
);
|
|
668
|
+
graph.add(
|
|
669
|
+
new GPUSort({
|
|
670
|
+
id,
|
|
671
|
+
keys: gathered,
|
|
672
|
+
values: orders[orderIndex],
|
|
673
|
+
outputKeys: sortedValues,
|
|
674
|
+
outputValues: orders[1 - orderIndex]
|
|
675
|
+
})
|
|
676
|
+
);
|
|
677
|
+
orderIndex = 1 - orderIndex;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
const order = orders[orderIndex];
|
|
681
|
+
const first = staged[0];
|
|
682
|
+
for (const [index, {values, classes}] of staged.entries()) {
|
|
683
|
+
const firstKey = index === 0;
|
|
684
|
+
addGPUGroupingPass(
|
|
685
|
+
graph,
|
|
686
|
+
prefix + '-heads-' + index,
|
|
687
|
+
length,
|
|
688
|
+
{order, values, classes, ...(firstKey ? {} : {firstClasses: first.classes})},
|
|
689
|
+
{heads},
|
|
690
|
+
`
|
|
691
|
+
let row = order[index];
|
|
692
|
+
let previous = order[max(index, 1u) - 1u];
|
|
693
|
+
let changed = classes[row] != classes[previous] || values[row] != values[previous];
|
|
694
|
+
let selected = ${firstKey ? 'classes' : 'firstClasses'}[row] != 2u;
|
|
695
|
+
heads[index] = u32(selected && (${firstKey ? 'index == 0u' : 'heads[index] != 0u'} || changed));
|
|
696
|
+
`
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
graph.add(
|
|
700
|
+
new GPUScan({id: prefix + '-scan-heads', input: heads, output: ranks, mode: 'inclusive'})
|
|
701
|
+
);
|
|
702
|
+
graph.add(
|
|
703
|
+
new GPUReduction({
|
|
704
|
+
id: prefix + '-count-heads',
|
|
705
|
+
input: heads,
|
|
706
|
+
output: countView,
|
|
707
|
+
operation: 'sum'
|
|
708
|
+
})
|
|
709
|
+
);
|
|
710
|
+
addGPUGroupingPass(
|
|
711
|
+
graph,
|
|
712
|
+
prefix + '-scatter-ids',
|
|
713
|
+
length,
|
|
714
|
+
{order, classes: first.classes, ranks},
|
|
715
|
+
{groupIds},
|
|
716
|
+
`
|
|
717
|
+
let row = order[index];
|
|
718
|
+
groupIds[row] = select(0u, ranks[index] - 1u, classes[row] != 2u);
|
|
719
|
+
`
|
|
720
|
+
);
|
|
721
|
+
for (const [index, {values, classes}] of staged.entries()) {
|
|
722
|
+
const output = outputs[index];
|
|
723
|
+
if (!output) continue;
|
|
724
|
+
const validity = nullableKeys[index]?.output;
|
|
725
|
+
addGPUGroupingPass(
|
|
726
|
+
graph,
|
|
727
|
+
prefix + '-publish-key-' + index,
|
|
728
|
+
length,
|
|
729
|
+
{order, heads, ranks, values, ...(validity ? {classes} : {})},
|
|
730
|
+
{output: words(output), ...(validity ? {validity} : {})},
|
|
731
|
+
`
|
|
732
|
+
if (heads[index] != 0u) {
|
|
733
|
+
let row = order[index];
|
|
734
|
+
let group = ranks[index] - 1u;
|
|
735
|
+
output[group] = values[row];
|
|
736
|
+
${validity ? 'validity[group] = u32(classes[row] == 0u);' : ''}
|
|
737
|
+
}
|
|
738
|
+
`
|
|
739
|
+
);
|
|
740
|
+
}
|
|
741
|
+
addGPUGroupingPass(
|
|
742
|
+
graph,
|
|
743
|
+
prefix + '-result-selection',
|
|
744
|
+
length,
|
|
745
|
+
{count: countView},
|
|
746
|
+
{
|
|
747
|
+
rows: graph.importGPUVector(prefix + '-rows-view', rows).data[0],
|
|
748
|
+
mask: graph.importGPUVector(prefix + '-mask-view', mask).data[0]
|
|
749
|
+
},
|
|
750
|
+
'rows[index] = index; mask[index] = u32(index < count[0]);'
|
|
751
|
+
);
|
|
752
|
+
|
|
753
|
+
let byteOffset = 0;
|
|
754
|
+
const data = selectionMask.data.map(chunk => {
|
|
755
|
+
const view = graph.createDataView(groupIds.buffer, {
|
|
756
|
+
format: 'uint32',
|
|
757
|
+
length: chunk.length,
|
|
758
|
+
byteOffset
|
|
759
|
+
});
|
|
760
|
+
byteOffset += chunk.length * UINT32_BYTE_LENGTH;
|
|
761
|
+
return view;
|
|
762
|
+
});
|
|
763
|
+
const keys = new GraphVectorView({...selectionMask, id: prefix + '-ids', data});
|
|
764
|
+
return {keys, rows, count, mask};
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** Binds packed uint32 views and accounts for source chunk offsets in grouping shaders. */
|
|
768
|
+
function addGPUGroupingPass(
|
|
769
|
+
graph: GPUCommandGraph<GPUDataFrameQueryParameters>,
|
|
770
|
+
id: string,
|
|
771
|
+
length: number,
|
|
772
|
+
reads: Record<string, GraphDataView<'uint32'>>,
|
|
773
|
+
writes: Record<string, GraphDataView<'uint32'>>,
|
|
774
|
+
body: string
|
|
775
|
+
): void {
|
|
776
|
+
const bindings = {...reads, ...writes};
|
|
777
|
+
const resources: GraphBufferUse[] = [];
|
|
778
|
+
const declarations = Object.entries(bindings).map(([name, view], binding) => {
|
|
779
|
+
const write = Object.hasOwn(writes, name);
|
|
780
|
+
resources.push({buffer: view, usage: write ? 'storage-write' : 'storage-read'});
|
|
781
|
+
body = body.replaceAll(name + '[', name + '[' + getViewElementOffset(view) + 'u + ');
|
|
782
|
+
return `@group(0) @binding(${binding}) var<storage, ${write ? 'read_write' : 'read'}> ${name}: array<u32>;`;
|
|
783
|
+
});
|
|
784
|
+
addGPUAnalyticsComputePass(graph, {
|
|
785
|
+
id,
|
|
786
|
+
bindings,
|
|
787
|
+
resources,
|
|
788
|
+
length,
|
|
789
|
+
source: /* wgsl */ `
|
|
790
|
+
${declarations.join('\n')}
|
|
791
|
+
@compute @workgroup_size(${LU_ANALYTICS_WORKGROUP_SIZE})
|
|
792
|
+
fn main(@builtin(local_invocation_index) localInvocationIndex: u32,
|
|
793
|
+
@builtin(workgroup_id) workgroupId: vec3<u32>) {
|
|
794
|
+
${getGPUAnalyticsInvocationIndexSource(graph, length)}
|
|
795
|
+
if (index >= ${length}u) { return; }
|
|
796
|
+
${body}
|
|
797
|
+
}
|
|
798
|
+
`
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/** Resolves the scalar storage format of an observed key. */
|
|
803
|
+
function getGPUGroupingFormat<T extends GPUTypeMap>(
|
|
804
|
+
table: GPUTable<T>,
|
|
805
|
+
name: string
|
|
806
|
+
): GPUAnalyticsScalarFormat {
|
|
807
|
+
const format = table.schema.fields.find(field => field.name === name)?.format;
|
|
808
|
+
if (format !== 'uint32' && format !== 'sint32' && format !== 'float32') {
|
|
809
|
+
throw new Error('GPUDataFrame grouping requires 32-bit numeric keys');
|
|
810
|
+
}
|
|
811
|
+
return format;
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/** Resolves one batch-aligned grouped input, including empty sources. */
|
|
815
|
+
function getGPUGroupingVector<
|
|
816
|
+
Selection extends GPUTypeMap,
|
|
817
|
+
Format extends GPUAnalyticsScalarFormat
|
|
818
|
+
>(
|
|
243
819
|
context: GPUDataFrameQueryExtensionContext<Selection>,
|
|
244
820
|
name: string,
|
|
245
821
|
format: Format
|
|
@@ -340,7 +916,7 @@ function createGPUGroupedMetricState<Selection extends GPUTypeMap>(
|
|
|
340
916
|
}
|
|
341
917
|
|
|
342
918
|
/** Creates one owned dense, renderer-compatible result vector with one physical GPU chunk. */
|
|
343
|
-
function createGPUGroupedOutputVector<Format extends
|
|
919
|
+
function createGPUGroupedOutputVector<Format extends GPUAnalyticsScalarFormat>(
|
|
344
920
|
device: Device,
|
|
345
921
|
name: string,
|
|
346
922
|
length: number,
|
|
@@ -363,21 +939,26 @@ function createGPUGroupedOutputVector<Format extends 'uint32' | 'float32'>(
|
|
|
363
939
|
/** Produces one explicit dense categorical batch with independently borrowed output wrappers. */
|
|
364
940
|
function createGPUGroupedResultTable<Source extends GPUTypeMap, Result extends GPUTypeMap>(
|
|
365
941
|
source: GPUTable<Source>,
|
|
366
|
-
|
|
942
|
+
keys: GPUGroupingKeys,
|
|
367
943
|
definitions: readonly GPUDataFrameAggregationDefinition[],
|
|
368
|
-
vectors: ReadonlyMap<string, GPUVector<
|
|
944
|
+
vectors: ReadonlyMap<string, GPUVector<GPUAnalyticsScalarFormat>>,
|
|
945
|
+
columns?: readonly string[],
|
|
946
|
+
observed = false
|
|
369
947
|
): GPUTable<Result> {
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
948
|
+
const outputFields: GPUField[] = [
|
|
949
|
+
...keys.flatMap(({source: name, output}) => {
|
|
950
|
+
if (output === undefined) return [];
|
|
951
|
+
const field = source.schema.fields.find(candidate => candidate.name === name);
|
|
952
|
+
if (!field) throw new Error('GPUDataFrame grouped result requires an existing key field');
|
|
953
|
+
return [
|
|
954
|
+
{
|
|
955
|
+
name: output,
|
|
956
|
+
format: observed ? getGPUGroupingFormat(source, name) : 'uint32',
|
|
957
|
+
nullable: observed && field.nullable === true,
|
|
958
|
+
metadata: new Map(field.metadata)
|
|
959
|
+
}
|
|
960
|
+
];
|
|
961
|
+
}),
|
|
381
962
|
...definitions.map(definition => ({
|
|
382
963
|
name: definition.name,
|
|
383
964
|
format: definition.operation === 'count' ? ('uint32' as const) : ('float32' as const),
|
|
@@ -385,6 +966,9 @@ function createGPUGroupedResultTable<Source extends GPUTypeMap, Result extends G
|
|
|
385
966
|
metadata: new Map<string, string>()
|
|
386
967
|
}))
|
|
387
968
|
];
|
|
969
|
+
const fields = columns
|
|
970
|
+
? columns.map(name => outputFields.find(field => field.name === name)!)
|
|
971
|
+
: outputFields;
|
|
388
972
|
const gpuData: Record<string, GPUData> = {};
|
|
389
973
|
for (const field of fields) {
|
|
390
974
|
const sourceData = vectors.get(field.name)?.data[0];
|