@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
package/dist/gpu-sql/gpu-sql.js
CHANGED
|
@@ -5,8 +5,13 @@
|
|
|
5
5
|
import { parseSQLSelectStatement } from '@math.gl/sql/parser';
|
|
6
6
|
import { GPUDataFrame } from "../gpu-dataframe/gpu-data-frame.js";
|
|
7
7
|
import { GPUDataFrameQuery } from "../gpu-dataframe/gpu-data-frame-query.js";
|
|
8
|
+
import { compileGPUDataFrameGroupedAggregation, compileGPUDataFrameObservedAggregation } from "../gpu-dataframe/gpu-group-aggregation-compiler.js";
|
|
9
|
+
import { normalizeGPUDataFrameAggregations } from "../gpu-dataframe/gpu-group-by-query.js";
|
|
10
|
+
import { compileGPUDataFrameGlobalSort } from "../gpu-dataframe/gpu-global-sort-compiler.js";
|
|
8
11
|
import { GPUExpression, column, isGPUScalarFunction, parameter } from "../gpu-dataframe/gpu-expression.js";
|
|
9
12
|
import { lowerPortableExpression } from "../gpu-dataframe/portable-expression.js";
|
|
13
|
+
import { compileGPUDataFrameAggregation } from "../gpu-dataframe/gpu-global-aggregation-compiler.js";
|
|
14
|
+
import { compileGPUDataFrameJoin } from "../gpu-dataframe/gpu-join-compiler.js";
|
|
10
15
|
/**
|
|
11
16
|
* SQL frontend over explicitly registered, already GPU-resident dataframes.
|
|
12
17
|
*
|
|
@@ -32,7 +37,7 @@ export class GPUSQLContext {
|
|
|
32
37
|
/** Parses and validates one immutable SELECT plan without touching registered GPU sources. */
|
|
33
38
|
query(source, options = {}) {
|
|
34
39
|
const statement = parseGPUSQLStatement(source);
|
|
35
|
-
return new GPUSQLQuery(source, buildGPUSQLPlan(this.tables, statement, options.parameters ?? {}));
|
|
40
|
+
return new GPUSQLQuery(source, buildGPUSQLPlan(this.tables, statement, options.parameters ?? {}, options.maxMeanScratchBytes));
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
/** Immutable SQL plan lowered directly into existing reusable GPU dataframe command graphs. */
|
|
@@ -46,12 +51,16 @@ export class GPUSQLQuery {
|
|
|
46
51
|
this.plan = plan;
|
|
47
52
|
Object.freeze(this);
|
|
48
53
|
}
|
|
54
|
+
/** Returns a frozen plan description without allocating GPU resources. */
|
|
55
|
+
explain() {
|
|
56
|
+
return this.plan.explanation;
|
|
57
|
+
}
|
|
49
58
|
/** Compiles existing dataframe operations into the caller-owned GPU command graph. */
|
|
50
59
|
compile(graph) {
|
|
51
|
-
return this.plan.compile(graph);
|
|
60
|
+
return this.plan.plan.compile(graph);
|
|
52
61
|
}
|
|
53
62
|
}
|
|
54
|
-
function buildGPUSQLPlan(tables, statement, parameters) {
|
|
63
|
+
function buildGPUSQLPlan(tables, statement, parameters, maxMeanScratchBytes) {
|
|
55
64
|
const frame = tables[statement.table.toLowerCase()];
|
|
56
65
|
if (!frame)
|
|
57
66
|
throw new Error(`GPUSQL table "${statement.table}" is not registered`);
|
|
@@ -61,40 +70,267 @@ function buildGPUSQLPlan(tables, statement, parameters) {
|
|
|
61
70
|
if (statement.predicate) {
|
|
62
71
|
query = query.filter(new GPUExpression(lowerSQLExpression(statement.predicate, parameters, resolve)));
|
|
63
72
|
}
|
|
73
|
+
/** Captures the route chosen by the same branch that supplies the executable plan. */
|
|
74
|
+
const describe = (plan, execution, columns, workingColumns = columns, keyCount = 0) => ({
|
|
75
|
+
plan,
|
|
76
|
+
explanation: Object.freeze({
|
|
77
|
+
table: statement.table,
|
|
78
|
+
filtered: Boolean(statement.predicate),
|
|
79
|
+
...(statement.having ? { having: true } : {}),
|
|
80
|
+
execution,
|
|
81
|
+
columns: Object.freeze([...columns]),
|
|
82
|
+
workingColumns: Object.freeze([...workingColumns]),
|
|
83
|
+
keyCount,
|
|
84
|
+
...(statement.join
|
|
85
|
+
? { join: Object.freeze({ table: statement.join.table, type: statement.join.type }) }
|
|
86
|
+
: {}),
|
|
87
|
+
...(statement.limit !== undefined || statement.offset !== undefined
|
|
88
|
+
? { page: Object.freeze({ offset: statement.offset ?? 0, limit: statement.limit }) }
|
|
89
|
+
: {})
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
/** Binds a single equality join for row-returning and aggregate plans. */
|
|
93
|
+
const bindJoin = (join) => {
|
|
94
|
+
const right = tables[join.table.toLowerCase()];
|
|
95
|
+
if (!right)
|
|
96
|
+
throw new Error(`GPUSQL table "${join.table}" is not registered`);
|
|
97
|
+
const rightQualifier = join.alias ?? join.table;
|
|
98
|
+
const { left: firstOperand, right: secondOperand } = join;
|
|
99
|
+
const matchesLeft = (reference) => matchesGPUSQLColumn(reference, qualifier, frame.columnNames);
|
|
100
|
+
const matchesRight = (reference) => matchesGPUSQLColumn(reference, rightQualifier, right.columnNames);
|
|
101
|
+
const forward = matchesLeft(firstOperand) && matchesRight(secondOperand);
|
|
102
|
+
const reversed = matchesLeft(secondOperand) && matchesRight(firstOperand);
|
|
103
|
+
if (forward && reversed) {
|
|
104
|
+
throw new Error('GPUSQL JOIN key references are ambiguous; qualify the columns');
|
|
105
|
+
}
|
|
106
|
+
const leftKey = resolve(reversed ? secondOperand : firstOperand);
|
|
107
|
+
const rightKey = resolveGPUSQLColumn(reversed ? firstOperand : secondOperand, rightQualifier, right.columnNames);
|
|
108
|
+
return { right, leftKey, rightKey };
|
|
109
|
+
};
|
|
110
|
+
const joinMethods = {
|
|
111
|
+
left: 'leftJoin',
|
|
112
|
+
semi: 'semiJoin',
|
|
113
|
+
anti: 'antiJoin',
|
|
114
|
+
inner: 'innerJoin'
|
|
115
|
+
};
|
|
64
116
|
const aggregates = statement.items.filter(item => item.aggregate);
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
117
|
+
if (statement.having && !statement.groupBy) {
|
|
118
|
+
throw new Error('GPUSQL HAVING requires GROUP BY');
|
|
119
|
+
}
|
|
120
|
+
if (aggregates.length > 0 || statement.having || (statement.groupBy && statement.orderBy)) {
|
|
121
|
+
if (!statement.groupBy &&
|
|
122
|
+
(statement.orderBy || statement.limit !== undefined || statement.offset !== undefined)) {
|
|
123
|
+
throw new Error('GPUSQL aggregate queries without GROUP BY do not yet support ordering or pagination');
|
|
71
124
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
125
|
+
let aggregateJoin;
|
|
126
|
+
if (statement.join) {
|
|
127
|
+
const { right, leftKey, rightKey } = bindJoin(statement.join);
|
|
128
|
+
const type = statement.join.type;
|
|
129
|
+
const join = query[joinMethods[type]](right, { leftOn: leftKey, rightOn: rightKey });
|
|
130
|
+
aggregateJoin = { right, type, options: join.options };
|
|
131
|
+
}
|
|
132
|
+
const definitions = Object.create(null);
|
|
133
|
+
const reservedNames = new Set(frame.columnNames);
|
|
134
|
+
const outputNames = new Map();
|
|
135
|
+
const aggregateOutputs = new Map();
|
|
136
|
+
let inputIndex = 0;
|
|
137
|
+
/** Registers an aggregate and materializes its computed input when needed. */
|
|
138
|
+
const registerAggregate = (operation, input, alias) => {
|
|
139
|
+
let inputColumn = input?.kind === 'column' ? input.name : undefined;
|
|
140
|
+
if (input && input.kind !== 'column') {
|
|
141
|
+
if (!alias)
|
|
142
|
+
throw new Error('GPUSQL computed aggregate inputs require an explicit AS alias');
|
|
143
|
+
do {
|
|
144
|
+
inputColumn = '__sqlAggregateInput' + inputIndex++;
|
|
145
|
+
} while (reservedNames.has(inputColumn));
|
|
146
|
+
reservedNames.add(inputColumn);
|
|
147
|
+
query = query.withColumn(inputColumn, new GPUExpression(input));
|
|
148
|
+
}
|
|
149
|
+
const name = alias ?? `${operation}_${inputColumn ?? 'all'}`;
|
|
150
|
+
if (Object.hasOwn(definitions, name)) {
|
|
77
151
|
throw new Error(`GPUSQL aggregate alias "${name}" is duplicated`);
|
|
152
|
+
}
|
|
153
|
+
aggregateOutputs.set(JSON.stringify([operation, input ?? null]), name);
|
|
78
154
|
definitions[name] =
|
|
79
|
-
|
|
80
|
-
?
|
|
81
|
-
|
|
155
|
+
operation === 'count'
|
|
156
|
+
? inputColumn === undefined
|
|
157
|
+
? 'count'
|
|
158
|
+
: { count: inputColumn }
|
|
159
|
+
: { [operation]: inputColumn };
|
|
160
|
+
return name;
|
|
161
|
+
};
|
|
162
|
+
for (const item of aggregates) {
|
|
163
|
+
const input = item.aggregateInput && lowerSQLExpression(item.aggregateInput, parameters, resolve);
|
|
164
|
+
outputNames.set(item, registerAggregate(item.aggregate, input, item.alias));
|
|
82
165
|
}
|
|
83
|
-
if (statement.groupBy) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
166
|
+
if (statement.groupBy !== undefined) {
|
|
167
|
+
if (maxMeanScratchBytes !== undefined &&
|
|
168
|
+
(!Number.isSafeInteger(maxMeanScratchBytes) || maxMeanScratchBytes < 4)) {
|
|
169
|
+
throw new Error('GPUSQL mean scratch budget requires at least four bytes');
|
|
170
|
+
}
|
|
171
|
+
const keyItems = statement.items.filter(item => !item.aggregate);
|
|
172
|
+
const occupied = new Set(Object.keys(definitions));
|
|
173
|
+
const selectedKeys = new Map();
|
|
174
|
+
const keyByItem = new Map();
|
|
175
|
+
/** Reuses a source field or creates an internal column for a computed group key. */
|
|
176
|
+
const materializeKey = (expression) => {
|
|
177
|
+
if (expression.kind === 'column')
|
|
178
|
+
return expression.name;
|
|
179
|
+
let source;
|
|
180
|
+
do {
|
|
181
|
+
source = '__sqlGroupKey' + inputIndex++;
|
|
182
|
+
} while (reservedNames.has(source));
|
|
183
|
+
reservedNames.add(source);
|
|
184
|
+
query = query.withColumn(source, new GPUExpression(expression));
|
|
185
|
+
return source;
|
|
186
|
+
};
|
|
187
|
+
for (const item of keyItems) {
|
|
188
|
+
if (!item.expression) {
|
|
189
|
+
throw new Error('GPUSQL grouped SELECT requires explicit key expressions');
|
|
190
|
+
}
|
|
191
|
+
const expression = lowerSQLExpression(item.expression, parameters, resolve);
|
|
192
|
+
const output = item.alias ?? (expression.kind === 'column' ? expression.name : undefined);
|
|
193
|
+
if (!output)
|
|
194
|
+
throw new Error('GPUSQL computed group keys require an explicit AS alias');
|
|
195
|
+
if (occupied.has(output)) {
|
|
196
|
+
throw new Error('GPUSQL output column "' + output + '" is duplicated');
|
|
197
|
+
}
|
|
198
|
+
const signature = JSON.stringify(expression);
|
|
199
|
+
if (selectedKeys.has(signature)) {
|
|
200
|
+
throw new Error('GPUSQL grouped queries must select each GROUP BY key exactly once');
|
|
201
|
+
}
|
|
202
|
+
const key = { source: materializeKey(expression), output };
|
|
203
|
+
selectedKeys.set(signature, key);
|
|
204
|
+
keyByItem.set(item, key);
|
|
205
|
+
occupied.add(output);
|
|
206
|
+
outputNames.set(item, output);
|
|
207
|
+
}
|
|
208
|
+
const hiddenKeys = new Map();
|
|
209
|
+
const keys = statement.groupBy.map(reference => {
|
|
210
|
+
if (reference.type === 'Literal' && typeof reference.value === 'number') {
|
|
211
|
+
const item = getGPUSQLProjectionItem(statement.items, reference.value, 'GROUP BY');
|
|
212
|
+
const key = keyByItem.get(item);
|
|
213
|
+
if (!key)
|
|
214
|
+
throw new Error('GPUSQL GROUP BY position must reference a group key directly');
|
|
215
|
+
return key;
|
|
216
|
+
}
|
|
217
|
+
if (reference.type === 'Identifier' &&
|
|
218
|
+
!('gpuSQLParameter' in reference) &&
|
|
219
|
+
!frame.columnNames.includes(reference.name)) {
|
|
220
|
+
const alias = keyItems.find(item => item.alias === reference.name);
|
|
221
|
+
if (alias)
|
|
222
|
+
return keyByItem.get(alias);
|
|
223
|
+
}
|
|
224
|
+
const expression = lowerSQLExpression(reference, parameters, resolve);
|
|
225
|
+
const signature = JSON.stringify(expression);
|
|
226
|
+
const existing = selectedKeys.get(signature) ?? hiddenKeys.get(signature);
|
|
227
|
+
if (existing)
|
|
228
|
+
return existing;
|
|
229
|
+
const key = { source: materializeKey(expression) };
|
|
230
|
+
hiddenKeys.set(signature, key);
|
|
231
|
+
return key;
|
|
232
|
+
});
|
|
233
|
+
const uniqueKeys = new Set(keys);
|
|
234
|
+
if (uniqueKeys.size !== keys.length) {
|
|
235
|
+
throw new Error('GPUSQL GROUP BY keys must be distinct');
|
|
236
|
+
}
|
|
237
|
+
if ([...selectedKeys.values()].some(key => !uniqueKeys.has(key))) {
|
|
238
|
+
throw new Error('GPUSQL grouped queries must group by every non-aggregate SELECT expression');
|
|
239
|
+
}
|
|
240
|
+
const columns = statement.items.map(item => outputNames.get(item));
|
|
241
|
+
if (!statement.orderBy && (statement.limit !== undefined || statement.offset !== undefined)) {
|
|
242
|
+
throw new Error('GPUSQL LIMIT or OFFSET currently requires ORDER BY');
|
|
243
|
+
}
|
|
244
|
+
/** Resolves or registers an aggregate used by a post-group clause. */
|
|
245
|
+
const bindAggregateCall = (call) => {
|
|
246
|
+
const name = call.callee.type === 'Identifier' ? String(call.callee['name']).toLowerCase() : '';
|
|
247
|
+
const operation = name === 'avg' ? 'mean' : name;
|
|
248
|
+
if (operation !== 'count' &&
|
|
249
|
+
operation !== 'sum' &&
|
|
250
|
+
operation !== 'min' &&
|
|
251
|
+
operation !== 'max' &&
|
|
252
|
+
operation !== 'mean')
|
|
253
|
+
return undefined;
|
|
254
|
+
if (call.arguments.length !== 1)
|
|
255
|
+
throw new Error('GPUSQL aggregates require one argument');
|
|
256
|
+
const argument = call.arguments[0];
|
|
257
|
+
const wildcard = argument.type === 'Identifier' && argument['sqlWildcard'] === true;
|
|
258
|
+
if (wildcard && operation !== 'count') {
|
|
259
|
+
throw new Error('GPUSQL only permits COUNT(*) as a wildcard aggregation');
|
|
260
|
+
}
|
|
261
|
+
const input = wildcard ? undefined : lowerSQLExpression(argument, parameters, resolve);
|
|
262
|
+
const output = aggregateOutputs.get(JSON.stringify([operation, input ?? null]));
|
|
263
|
+
if (output !== undefined)
|
|
264
|
+
return column(output).node;
|
|
265
|
+
let hiddenName;
|
|
266
|
+
do {
|
|
267
|
+
hiddenName = '__sqlPostGroupAggregate' + inputIndex++;
|
|
268
|
+
} while (occupied.has(hiddenName));
|
|
269
|
+
occupied.add(hiddenName);
|
|
270
|
+
return column(registerAggregate(operation, input, hiddenName)).node;
|
|
271
|
+
};
|
|
272
|
+
const having = statement.having
|
|
273
|
+
? new GPUExpression(lowerSQLExpression(statement.having, parameters, reference => resolveGPUSQLColumn(reference, '', columns), bindAggregateCall))
|
|
274
|
+
: undefined;
|
|
275
|
+
const ordering = statement.orderBy?.map(({ expression, direction, nulls }, index) => {
|
|
276
|
+
const column = expression.type === 'Literal' && typeof expression.value === 'number'
|
|
277
|
+
? getGPUSQLProjectionItem(columns, expression.value, 'ORDER BY')
|
|
278
|
+
: expression.type === 'Identifier' && !('gpuSQLParameter' in expression)
|
|
279
|
+
? expression.name
|
|
280
|
+
: undefined;
|
|
281
|
+
const aggregate = expression.type === 'CallExpression' ? bindAggregateCall(expression) : undefined;
|
|
282
|
+
const sortColumn = aggregate?.kind === 'column' ? aggregate.name : column;
|
|
283
|
+
if (sortColumn === undefined || (!aggregate && !columns.includes(sortColumn))) {
|
|
284
|
+
throw new Error('GPUSQL grouped ORDER BY requires a SELECT output name, position, or aggregate call');
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
column: sortColumn,
|
|
288
|
+
options: {
|
|
289
|
+
direction,
|
|
290
|
+
nulls: nulls ?? 'last',
|
|
291
|
+
nans: 'last',
|
|
292
|
+
algorithm: 'auto',
|
|
293
|
+
...(index === 0 ? { limit: statement.limit, offset: statement.offset } : {})
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
const { predicates, selectedColumns, derivedColumns } = query;
|
|
298
|
+
if (Object.keys(definitions).length === 0) {
|
|
299
|
+
throw new Error('GPUSQL GROUP BY requires at least one aggregation');
|
|
300
|
+
}
|
|
301
|
+
const normalized = normalizeGPUDataFrameAggregations({ ...query, source: frame }, keys[0].output, definitions);
|
|
302
|
+
if (keys.length > 1 || keys[0].output === undefined || !frame.dictionaries[keys[0].source]) {
|
|
303
|
+
for (const { source } of keys) {
|
|
304
|
+
const format = frame.schema.fields.find(field => field.name === source)?.format;
|
|
305
|
+
if (!derivedColumns.some(column => column.name === source) &&
|
|
306
|
+
format !== 'uint32' &&
|
|
307
|
+
format !== 'sint32' &&
|
|
308
|
+
format !== 'float32') {
|
|
309
|
+
throw new Error('GPUSQL GROUP BY requires 32-bit numeric or dictionary keys');
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
return describe({
|
|
313
|
+
compile: graph => compileGPUDataFrameObservedAggregation(frame, predicates, selectedColumns, derivedColumns, keys, normalized, graph, columns, ordering, having, aggregateJoin, maxMeanScratchBytes)
|
|
314
|
+
}, 'observed-grouping', columns, selectedColumns, keys.length);
|
|
89
315
|
}
|
|
90
|
-
|
|
316
|
+
const [key] = keys;
|
|
317
|
+
const { groupCount } = query.groupBy(key.source);
|
|
318
|
+
return describe({
|
|
319
|
+
compile: graph => compileGPUDataFrameGroupedAggregation(frame, predicates, selectedColumns, derivedColumns, key.source, groupCount, normalized, graph, { key: key.output, columns }, ordering, having, aggregateJoin, maxMeanScratchBytes)
|
|
320
|
+
}, 'dense-grouping', columns, selectedColumns, 1);
|
|
91
321
|
}
|
|
92
322
|
if (aggregates.length !== statement.items.length) {
|
|
93
323
|
throw new Error('GPUSQL global aggregates cannot mix ordinary source columns');
|
|
94
324
|
}
|
|
95
|
-
|
|
325
|
+
const aggregate = query.aggregate(definitions);
|
|
326
|
+
const { predicates, selectedColumns, derivedColumns } = query;
|
|
327
|
+
return describe(aggregateJoin
|
|
328
|
+
? {
|
|
329
|
+
compile: graph => compileGPUDataFrameAggregation(frame, predicates, selectedColumns, derivedColumns, aggregate.definitions, graph, aggregateJoin)
|
|
330
|
+
}
|
|
331
|
+
: aggregate, 'global-aggregation', statement.items.map(item => outputNames.get(item)), query.selectedColumns);
|
|
96
332
|
}
|
|
97
|
-
if (statement.groupBy)
|
|
333
|
+
if (statement.groupBy !== undefined)
|
|
98
334
|
throw new Error('GPUSQL GROUP BY requires at least one aggregation');
|
|
99
335
|
const selected = [];
|
|
100
336
|
for (const item of statement.items) {
|
|
@@ -122,59 +358,72 @@ function buildGPUSQLPlan(tables, statement, parameters) {
|
|
|
122
358
|
if (statement.orderBy || statement.limit !== undefined || statement.offset !== undefined) {
|
|
123
359
|
throw new Error('GPUSQL joined results do not yet support ORDER BY or pagination');
|
|
124
360
|
}
|
|
125
|
-
const right =
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
const
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
throw new Error('GPUSQL joins require the left join key to remain selected');
|
|
138
|
-
}
|
|
139
|
-
query = query.select(selected);
|
|
140
|
-
const options = { leftOn: leftKey, rightOn: rightKey };
|
|
141
|
-
switch (statement.join.type) {
|
|
142
|
-
case 'left':
|
|
143
|
-
return query.leftJoin(right, options);
|
|
144
|
-
case 'semi':
|
|
145
|
-
return query.semiJoin(right, options);
|
|
146
|
-
case 'anti':
|
|
147
|
-
return query.antiJoin(right, options);
|
|
148
|
-
default:
|
|
149
|
-
return query.innerJoin(right, options);
|
|
150
|
-
}
|
|
361
|
+
const { right, leftKey, rightKey } = bindJoin(statement.join);
|
|
362
|
+
const keyIsSelected = selected.includes(leftKey);
|
|
363
|
+
const workingColumns = keyIsSelected ? selected : [...selected, leftKey];
|
|
364
|
+
const workingQuery = query.select(workingColumns);
|
|
365
|
+
const joinType = statement.join.type;
|
|
366
|
+
const join = workingQuery[joinMethods[joinType]](right, { leftOn: leftKey, rightOn: rightKey });
|
|
367
|
+
if (keyIsSelected)
|
|
368
|
+
return describe(join, 'unique-right-join', selected, workingColumns, 1);
|
|
369
|
+
const { predicates, derivedColumns } = workingQuery;
|
|
370
|
+
return describe({
|
|
371
|
+
compile: graph => compileGPUDataFrameJoin(frame, predicates, workingColumns, derivedColumns, right, join.options, joinType, graph, selected)
|
|
372
|
+
}, 'unique-right-join', selected, workingColumns, 1);
|
|
151
373
|
}
|
|
152
374
|
if (statement.orderBy) {
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
375
|
+
const workingColumns = new Set(selected);
|
|
376
|
+
const resolvedKeys = statement.orderBy.map(({ expression, direction, nulls }) => {
|
|
377
|
+
let orderColumn;
|
|
378
|
+
if (expression.type === 'Literal' && typeof expression.value === 'number') {
|
|
379
|
+
orderColumn = getGPUSQLProjectionItem(selected, expression.value, 'ORDER BY');
|
|
380
|
+
}
|
|
381
|
+
else if (expression.type === 'Identifier' &&
|
|
382
|
+
!('gpuSQLParameter' in expression) &&
|
|
383
|
+
selected.includes(expression.name)) {
|
|
384
|
+
orderColumn = expression.name;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
const sortExpression = lowerSQLExpression(expression, parameters, resolve);
|
|
388
|
+
if (sortExpression.kind === 'column') {
|
|
389
|
+
orderColumn = sortExpression.name;
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
orderColumn = '__sqlOrderKey';
|
|
393
|
+
while (frame.columnNames.includes(orderColumn) || workingColumns.has(orderColumn)) {
|
|
394
|
+
orderColumn += '_';
|
|
395
|
+
}
|
|
396
|
+
query = query.withColumn(orderColumn, new GPUExpression(sortExpression));
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
workingColumns.add(orderColumn);
|
|
400
|
+
return { column: orderColumn, direction, nulls };
|
|
163
401
|
});
|
|
164
|
-
|
|
402
|
+
const columns = [...workingColumns];
|
|
403
|
+
const workingQuery = query.select(columns);
|
|
404
|
+
const plans = resolvedKeys.map(({ column, direction, nulls }) => ({
|
|
405
|
+
column,
|
|
406
|
+
plan: workingQuery.sortByGlobal(column, { direction, nulls })
|
|
407
|
+
}));
|
|
408
|
+
const [{ column, plan: sort }, ...secondary] = plans;
|
|
409
|
+
const page = statement.limit === undefined && statement.offset === undefined
|
|
165
410
|
? sort
|
|
166
411
|
: sort.page(statement.offset ?? 0, statement.limit);
|
|
412
|
+
const projection = columns.length > selected.length ? selected : undefined;
|
|
413
|
+
if (!projection && secondary.length === 0)
|
|
414
|
+
return describe(page, 'global-sort', selected, columns, plans.length);
|
|
415
|
+
const { predicates, derivedColumns } = workingQuery;
|
|
416
|
+
const additionalKeys = secondary.map(key => ({
|
|
417
|
+
column: key.column,
|
|
418
|
+
options: key.plan.options
|
|
419
|
+
}));
|
|
420
|
+
return describe({
|
|
421
|
+
compile: graph => compileGPUDataFrameGlobalSort(frame, predicates, columns, derivedColumns, column, page.options, graph, projection, additionalKeys)
|
|
422
|
+
}, 'global-sort', selected, columns, plans.length);
|
|
167
423
|
}
|
|
168
424
|
if (statement.limit !== undefined || statement.offset !== undefined)
|
|
169
425
|
throw new Error('GPUSQL LIMIT or OFFSET currently requires ORDER BY');
|
|
170
|
-
return query.select(selected);
|
|
171
|
-
}
|
|
172
|
-
/** Resolves the only non-aggregate item in a grouped projection. */
|
|
173
|
-
function resolveGPUSQLProjectionName(item, resolve) {
|
|
174
|
-
if (item.expression?.type !== 'Identifier' && item.expression?.type !== 'MemberExpression') {
|
|
175
|
-
throw new Error('GPUSQL grouped source expressions must reference the group key directly');
|
|
176
|
-
}
|
|
177
|
-
return resolve(readGPUSQLColumn(item.expression));
|
|
426
|
+
return describe(query.select(selected), 'projection', selected);
|
|
178
427
|
}
|
|
179
428
|
/** Formats the source spelling for diagnostics. */
|
|
180
429
|
function formatGPUSQLColumn({ name, qualifier }) {
|
|
@@ -197,22 +446,59 @@ function resolveGPUSQLColumn(reference, qualifier, columns) {
|
|
|
197
446
|
}
|
|
198
447
|
return reference.name;
|
|
199
448
|
}
|
|
449
|
+
/** Isolates the top-level HAVING clause until the shared SELECT parser exposes it. */
|
|
450
|
+
function splitGPUSQLHaving(source) {
|
|
451
|
+
const tokens = /"(?:""|[^"])*"|'(?:''|[^'])*'|:[A-Za-z_]\w*|[A-Za-z_]\w*|[();]|--[^\r\n]*|\/\*/g;
|
|
452
|
+
let depth = 0;
|
|
453
|
+
let start = -1;
|
|
454
|
+
let predicateStart = -1;
|
|
455
|
+
let end = source.length;
|
|
456
|
+
let tailStarted = false;
|
|
457
|
+
for (const token of source.matchAll(tokens)) {
|
|
458
|
+
if (token[0].startsWith('--'))
|
|
459
|
+
continue;
|
|
460
|
+
if (token[0] === '/*') {
|
|
461
|
+
throw new Error('GPUSQL does not support SQL comments');
|
|
462
|
+
}
|
|
463
|
+
if (token[0] === '(')
|
|
464
|
+
depth++;
|
|
465
|
+
if (token[0] === ')')
|
|
466
|
+
depth--;
|
|
467
|
+
if (depth !== 0)
|
|
468
|
+
continue;
|
|
469
|
+
const keyword = token[0].toUpperCase();
|
|
470
|
+
if (start !== -1 && ['ORDER', 'LIMIT', 'OFFSET', ';'].includes(keyword)) {
|
|
471
|
+
end = token.index;
|
|
472
|
+
break;
|
|
473
|
+
}
|
|
474
|
+
if (start === -1 && ['ORDER', 'LIMIT', 'OFFSET', ';'].includes(keyword))
|
|
475
|
+
tailStarted = true;
|
|
476
|
+
if (start === -1 && keyword === 'HAVING') {
|
|
477
|
+
if (tailStarted)
|
|
478
|
+
throw new Error('GPUSQL HAVING must precede ORDER BY and pagination');
|
|
479
|
+
start = token.index;
|
|
480
|
+
predicateStart = start + token[0].length;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return start === -1
|
|
484
|
+
? { select: source }
|
|
485
|
+
: {
|
|
486
|
+
select: source.slice(0, start) + ' ' + source.slice(end),
|
|
487
|
+
having: source.slice(predicateStart, end)
|
|
488
|
+
};
|
|
489
|
+
}
|
|
200
490
|
/** Parses the SQL subset supported by the GPU relational planner. */
|
|
201
491
|
function parseGPUSQLStatement(source) {
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
492
|
+
const { select, having } = splitGPUSQLHaving(source);
|
|
493
|
+
const options = {
|
|
494
|
+
parseParameter: (name) => ({ type: 'Identifier', name, gpuSQLParameter: true })
|
|
495
|
+
};
|
|
496
|
+
const statement = parseSQLSelectStatement(select, options);
|
|
205
497
|
if (statement.offset !== undefined && statement.offset > 0xffffffff) {
|
|
206
498
|
throw new Error('GPUSQL OFFSET must fit an unsigned 32-bit row count');
|
|
207
499
|
}
|
|
208
500
|
if (statement.joins.length > 1)
|
|
209
501
|
throw new Error('GPUSQL currently supports one JOIN');
|
|
210
|
-
if ((statement.groupBy?.length ?? 0) > 1) {
|
|
211
|
-
throw new Error('GPUSQL currently supports one GROUP BY column');
|
|
212
|
-
}
|
|
213
|
-
if ((statement.orderBy?.length ?? 0) > 1) {
|
|
214
|
-
throw new Error('GPUSQL currently supports one ORDER BY column');
|
|
215
|
-
}
|
|
216
502
|
if (statement.limit !== undefined && statement.limit > 0xffffffff) {
|
|
217
503
|
throw new Error('GPUSQL LIMIT must fit an unsigned 32-bit row count');
|
|
218
504
|
}
|
|
@@ -231,12 +517,12 @@ function parseGPUSQLStatement(source) {
|
|
|
231
517
|
}
|
|
232
518
|
const argument = expression.arguments[0];
|
|
233
519
|
const wildcard = argument.type === 'Identifier' && argument['sqlWildcard'] === true;
|
|
234
|
-
if (
|
|
520
|
+
if (wildcard && aggregate !== 'count') {
|
|
235
521
|
throw new Error('GPUSQL only permits COUNT(*) as a wildcard aggregation');
|
|
236
522
|
}
|
|
237
523
|
return {
|
|
238
524
|
aggregate,
|
|
239
|
-
...(wildcard ? {} : {
|
|
525
|
+
...(wildcard ? {} : { aggregateInput: argument }),
|
|
240
526
|
alias
|
|
241
527
|
};
|
|
242
528
|
}
|
|
@@ -265,23 +551,37 @@ function parseGPUSQLStatement(source) {
|
|
|
265
551
|
right: readGPUSQLColumn(join.on.right)
|
|
266
552
|
};
|
|
267
553
|
}
|
|
268
|
-
const sort = statement.orderBy?.[0];
|
|
269
554
|
return {
|
|
270
555
|
items,
|
|
271
556
|
table: statement.from.name,
|
|
272
557
|
alias: statement.from.alias,
|
|
273
558
|
join: loweredJoin,
|
|
274
559
|
predicate: statement.where,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
560
|
+
having: having === undefined
|
|
561
|
+
? undefined
|
|
562
|
+
: parseSQLSelectStatement('SELECT (' + having + '\n) FROM __gpu_having', options).select[0]
|
|
563
|
+
.expression,
|
|
564
|
+
groupBy: statement.groupBy?.length
|
|
565
|
+
? statement.groupBy.map(expression => expression)
|
|
566
|
+
: undefined,
|
|
567
|
+
orderBy: statement.orderBy?.length
|
|
568
|
+
? statement.orderBy.map(sort => ({
|
|
569
|
+
expression: sort.expression,
|
|
570
|
+
direction: sort.direction === 'desc' ? 'descending' : 'ascending',
|
|
571
|
+
nulls: sort.nulls
|
|
572
|
+
}))
|
|
573
|
+
: undefined,
|
|
281
574
|
offset: statement.offset,
|
|
282
575
|
limit: statement.limit
|
|
283
576
|
};
|
|
284
577
|
}
|
|
578
|
+
/** Resolves a one-based projection position with a clause-specific diagnostic. */
|
|
579
|
+
function getGPUSQLProjectionItem(projection, position, clause) {
|
|
580
|
+
if (!Number.isSafeInteger(position) || position < 1 || position > projection.length) {
|
|
581
|
+
throw new Error('GPUSQL ' + clause + ' position must be a one-based SELECT column number');
|
|
582
|
+
}
|
|
583
|
+
return projection[position - 1];
|
|
584
|
+
}
|
|
285
585
|
/** Reads a source column name or a two-part qualified column reference. */
|
|
286
586
|
function readGPUSQLColumn(node) {
|
|
287
587
|
const expression = node;
|
|
@@ -300,7 +600,7 @@ function readGPUSQLColumn(node) {
|
|
|
300
600
|
}
|
|
301
601
|
throw new Error('GPUSQL expected a table or column identifier');
|
|
302
602
|
}
|
|
303
|
-
function lowerSQLExpression(node, parameters, resolve) {
|
|
603
|
+
function lowerSQLExpression(node, parameters, resolve, resolveCall) {
|
|
304
604
|
const expression = node;
|
|
305
605
|
try {
|
|
306
606
|
return lowerPortableExpression(expression, leaf => {
|
|
@@ -315,6 +615,9 @@ function lowerSQLExpression(node, parameters, resolve) {
|
|
|
315
615
|
return column(resolve(readGPUSQLColumn(leaf))).node;
|
|
316
616
|
}
|
|
317
617
|
if (leaf.type === 'CallExpression' && leaf.callee.type === 'Identifier') {
|
|
618
|
+
const replacement = resolveCall?.(leaf);
|
|
619
|
+
if (replacement)
|
|
620
|
+
return replacement;
|
|
318
621
|
const name = leaf.callee['name'];
|
|
319
622
|
const functionName = typeof name === 'string' && leaf['sqlFunction'] === true ? name.toLowerCase() : name;
|
|
320
623
|
if (name !== 'isNull' &&
|