@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.cjs
CHANGED
|
@@ -24,8 +24,13 @@ module.exports = __toCommonJS(gpu_sql_exports);
|
|
|
24
24
|
var import_parser = require("@math.gl/sql/parser");
|
|
25
25
|
var import_gpu_data_frame = require("../gpu-dataframe/gpu-data-frame.cjs");
|
|
26
26
|
var import_gpu_data_frame_query = require("../gpu-dataframe/gpu-data-frame-query.cjs");
|
|
27
|
+
var import_gpu_group_aggregation_compiler = require("../gpu-dataframe/gpu-group-aggregation-compiler.cjs");
|
|
28
|
+
var import_gpu_group_by_query = require("../gpu-dataframe/gpu-group-by-query.cjs");
|
|
29
|
+
var import_gpu_global_sort_compiler = require("../gpu-dataframe/gpu-global-sort-compiler.cjs");
|
|
27
30
|
var import_gpu_expression = require("../gpu-dataframe/gpu-expression.cjs");
|
|
28
31
|
var import_portable_expression = require("../gpu-dataframe/portable-expression.cjs");
|
|
32
|
+
var import_gpu_global_aggregation_compiler = require("../gpu-dataframe/gpu-global-aggregation-compiler.cjs");
|
|
33
|
+
var import_gpu_join_compiler = require("../gpu-dataframe/gpu-join-compiler.cjs");
|
|
29
34
|
class GPUSQLContext {
|
|
30
35
|
tables;
|
|
31
36
|
constructor(tables) {
|
|
@@ -45,7 +50,7 @@ class GPUSQLContext {
|
|
|
45
50
|
/** Parses and validates one immutable SELECT plan without touching registered GPU sources. */
|
|
46
51
|
query(source, options = {}) {
|
|
47
52
|
const statement = parseGPUSQLStatement(source);
|
|
48
|
-
return new GPUSQLQuery(source, buildGPUSQLPlan(this.tables, statement, options.parameters ?? {}));
|
|
53
|
+
return new GPUSQLQuery(source, buildGPUSQLPlan(this.tables, statement, options.parameters ?? {}, options.maxMeanScratchBytes));
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
class GPUSQLQuery {
|
|
@@ -58,12 +63,17 @@ class GPUSQLQuery {
|
|
|
58
63
|
this.plan = plan;
|
|
59
64
|
Object.freeze(this);
|
|
60
65
|
}
|
|
66
|
+
/** Returns a frozen plan description without allocating GPU resources. */
|
|
67
|
+
explain() {
|
|
68
|
+
return this.plan.explanation;
|
|
69
|
+
}
|
|
61
70
|
/** Compiles existing dataframe operations into the caller-owned GPU command graph. */
|
|
62
71
|
compile(graph) {
|
|
63
|
-
return this.plan.compile(graph);
|
|
72
|
+
return this.plan.plan.compile(graph);
|
|
64
73
|
}
|
|
65
74
|
}
|
|
66
|
-
function buildGPUSQLPlan(tables, statement, parameters) {
|
|
75
|
+
function buildGPUSQLPlan(tables, statement, parameters, maxMeanScratchBytes) {
|
|
76
|
+
var _a, _b;
|
|
67
77
|
const frame = tables[statement.table.toLowerCase()];
|
|
68
78
|
if (!frame)
|
|
69
79
|
throw new Error(`GPUSQL table "${statement.table}" is not registered`);
|
|
@@ -73,33 +83,234 @@ function buildGPUSQLPlan(tables, statement, parameters) {
|
|
|
73
83
|
if (statement.predicate) {
|
|
74
84
|
query = query.filter(new import_gpu_expression.GPUExpression(lowerSQLExpression(statement.predicate, parameters, resolve)));
|
|
75
85
|
}
|
|
86
|
+
const describe = (plan, execution, columns, workingColumns = columns, keyCount = 0) => ({
|
|
87
|
+
plan,
|
|
88
|
+
explanation: Object.freeze({
|
|
89
|
+
table: statement.table,
|
|
90
|
+
filtered: Boolean(statement.predicate),
|
|
91
|
+
...statement.having ? { having: true } : {},
|
|
92
|
+
execution,
|
|
93
|
+
columns: Object.freeze([...columns]),
|
|
94
|
+
workingColumns: Object.freeze([...workingColumns]),
|
|
95
|
+
keyCount,
|
|
96
|
+
...statement.join ? { join: Object.freeze({ table: statement.join.table, type: statement.join.type }) } : {},
|
|
97
|
+
...statement.limit !== void 0 || statement.offset !== void 0 ? { page: Object.freeze({ offset: statement.offset ?? 0, limit: statement.limit }) } : {}
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
const bindJoin = (join) => {
|
|
101
|
+
const right = tables[join.table.toLowerCase()];
|
|
102
|
+
if (!right)
|
|
103
|
+
throw new Error(`GPUSQL table "${join.table}" is not registered`);
|
|
104
|
+
const rightQualifier = join.alias ?? join.table;
|
|
105
|
+
const { left: firstOperand, right: secondOperand } = join;
|
|
106
|
+
const matchesLeft = (reference) => matchesGPUSQLColumn(reference, qualifier, frame.columnNames);
|
|
107
|
+
const matchesRight = (reference) => matchesGPUSQLColumn(reference, rightQualifier, right.columnNames);
|
|
108
|
+
const forward = matchesLeft(firstOperand) && matchesRight(secondOperand);
|
|
109
|
+
const reversed = matchesLeft(secondOperand) && matchesRight(firstOperand);
|
|
110
|
+
if (forward && reversed) {
|
|
111
|
+
throw new Error("GPUSQL JOIN key references are ambiguous; qualify the columns");
|
|
112
|
+
}
|
|
113
|
+
const leftKey = resolve(reversed ? secondOperand : firstOperand);
|
|
114
|
+
const rightKey = resolveGPUSQLColumn(reversed ? firstOperand : secondOperand, rightQualifier, right.columnNames);
|
|
115
|
+
return { right, leftKey, rightKey };
|
|
116
|
+
};
|
|
117
|
+
const joinMethods = {
|
|
118
|
+
left: "leftJoin",
|
|
119
|
+
semi: "semiJoin",
|
|
120
|
+
anti: "antiJoin",
|
|
121
|
+
inner: "innerJoin"
|
|
122
|
+
};
|
|
76
123
|
const aggregates = statement.items.filter((item) => item.aggregate);
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
124
|
+
if (statement.having && !statement.groupBy) {
|
|
125
|
+
throw new Error("GPUSQL HAVING requires GROUP BY");
|
|
126
|
+
}
|
|
127
|
+
if (aggregates.length > 0 || statement.having || statement.groupBy && statement.orderBy) {
|
|
128
|
+
if (!statement.groupBy && (statement.orderBy || statement.limit !== void 0 || statement.offset !== void 0)) {
|
|
129
|
+
throw new Error("GPUSQL aggregate queries without GROUP BY do not yet support ordering or pagination");
|
|
80
130
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
|
|
131
|
+
let aggregateJoin;
|
|
132
|
+
if (statement.join) {
|
|
133
|
+
const { right, leftKey, rightKey } = bindJoin(statement.join);
|
|
134
|
+
const type = statement.join.type;
|
|
135
|
+
const join = query[joinMethods[type]](right, { leftOn: leftKey, rightOn: rightKey });
|
|
136
|
+
aggregateJoin = { right, type, options: join.options };
|
|
137
|
+
}
|
|
138
|
+
const definitions = /* @__PURE__ */ Object.create(null);
|
|
139
|
+
const reservedNames = new Set(frame.columnNames);
|
|
140
|
+
const outputNames = /* @__PURE__ */ new Map();
|
|
141
|
+
const aggregateOutputs = /* @__PURE__ */ new Map();
|
|
142
|
+
let inputIndex = 0;
|
|
143
|
+
const registerAggregate = (operation, input, alias) => {
|
|
144
|
+
let inputColumn = (input == null ? void 0 : input.kind) === "column" ? input.name : void 0;
|
|
145
|
+
if (input && input.kind !== "column") {
|
|
146
|
+
if (!alias)
|
|
147
|
+
throw new Error("GPUSQL computed aggregate inputs require an explicit AS alias");
|
|
148
|
+
do {
|
|
149
|
+
inputColumn = "__sqlAggregateInput" + inputIndex++;
|
|
150
|
+
} while (reservedNames.has(inputColumn));
|
|
151
|
+
reservedNames.add(inputColumn);
|
|
152
|
+
query = query.withColumn(inputColumn, new import_gpu_expression.GPUExpression(input));
|
|
153
|
+
}
|
|
154
|
+
const name = alias ?? `${operation}_${inputColumn ?? "all"}`;
|
|
155
|
+
if (Object.hasOwn(definitions, name)) {
|
|
86
156
|
throw new Error(`GPUSQL aggregate alias "${name}" is duplicated`);
|
|
87
|
-
|
|
157
|
+
}
|
|
158
|
+
aggregateOutputs.set(JSON.stringify([operation, input ?? null]), name);
|
|
159
|
+
definitions[name] = operation === "count" ? inputColumn === void 0 ? "count" : { count: inputColumn } : { [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));
|
|
88
165
|
}
|
|
89
|
-
if (statement.groupBy) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
166
|
+
if (statement.groupBy !== void 0) {
|
|
167
|
+
if (maxMeanScratchBytes !== void 0 && (!Number.isSafeInteger(maxMeanScratchBytes) || maxMeanScratchBytes < 4)) {
|
|
168
|
+
throw new Error("GPUSQL mean scratch budget requires at least four bytes");
|
|
169
|
+
}
|
|
170
|
+
const keyItems = statement.items.filter((item) => !item.aggregate);
|
|
171
|
+
const occupied = new Set(Object.keys(definitions));
|
|
172
|
+
const selectedKeys = /* @__PURE__ */ new Map();
|
|
173
|
+
const keyByItem = /* @__PURE__ */ new Map();
|
|
174
|
+
const materializeKey = (expression) => {
|
|
175
|
+
if (expression.kind === "column")
|
|
176
|
+
return expression.name;
|
|
177
|
+
let source;
|
|
178
|
+
do {
|
|
179
|
+
source = "__sqlGroupKey" + inputIndex++;
|
|
180
|
+
} while (reservedNames.has(source));
|
|
181
|
+
reservedNames.add(source);
|
|
182
|
+
query = query.withColumn(source, new import_gpu_expression.GPUExpression(expression));
|
|
183
|
+
return source;
|
|
184
|
+
};
|
|
185
|
+
for (const item of keyItems) {
|
|
186
|
+
if (!item.expression) {
|
|
187
|
+
throw new Error("GPUSQL grouped SELECT requires explicit key expressions");
|
|
188
|
+
}
|
|
189
|
+
const expression = lowerSQLExpression(item.expression, parameters, resolve);
|
|
190
|
+
const output = item.alias ?? (expression.kind === "column" ? expression.name : void 0);
|
|
191
|
+
if (!output)
|
|
192
|
+
throw new Error("GPUSQL computed group keys require an explicit AS alias");
|
|
193
|
+
if (occupied.has(output)) {
|
|
194
|
+
throw new Error('GPUSQL output column "' + output + '" is duplicated');
|
|
195
|
+
}
|
|
196
|
+
const signature = JSON.stringify(expression);
|
|
197
|
+
if (selectedKeys.has(signature)) {
|
|
198
|
+
throw new Error("GPUSQL grouped queries must select each GROUP BY key exactly once");
|
|
199
|
+
}
|
|
200
|
+
const key2 = { source: materializeKey(expression), output };
|
|
201
|
+
selectedKeys.set(signature, key2);
|
|
202
|
+
keyByItem.set(item, key2);
|
|
203
|
+
occupied.add(output);
|
|
204
|
+
outputNames.set(item, output);
|
|
205
|
+
}
|
|
206
|
+
const hiddenKeys = /* @__PURE__ */ new Map();
|
|
207
|
+
const keys = statement.groupBy.map((reference) => {
|
|
208
|
+
if (reference.type === "Literal" && typeof reference.value === "number") {
|
|
209
|
+
const item = getGPUSQLProjectionItem(statement.items, reference.value, "GROUP BY");
|
|
210
|
+
const key3 = keyByItem.get(item);
|
|
211
|
+
if (!key3)
|
|
212
|
+
throw new Error("GPUSQL GROUP BY position must reference a group key directly");
|
|
213
|
+
return key3;
|
|
214
|
+
}
|
|
215
|
+
if (reference.type === "Identifier" && !("gpuSQLParameter" in reference) && !frame.columnNames.includes(reference.name)) {
|
|
216
|
+
const alias = keyItems.find((item) => item.alias === reference.name);
|
|
217
|
+
if (alias)
|
|
218
|
+
return keyByItem.get(alias);
|
|
219
|
+
}
|
|
220
|
+
const expression = lowerSQLExpression(reference, parameters, resolve);
|
|
221
|
+
const signature = JSON.stringify(expression);
|
|
222
|
+
const existing = selectedKeys.get(signature) ?? hiddenKeys.get(signature);
|
|
223
|
+
if (existing)
|
|
224
|
+
return existing;
|
|
225
|
+
const key2 = { source: materializeKey(expression) };
|
|
226
|
+
hiddenKeys.set(signature, key2);
|
|
227
|
+
return key2;
|
|
228
|
+
});
|
|
229
|
+
const uniqueKeys = new Set(keys);
|
|
230
|
+
if (uniqueKeys.size !== keys.length) {
|
|
231
|
+
throw new Error("GPUSQL GROUP BY keys must be distinct");
|
|
232
|
+
}
|
|
233
|
+
if ([...selectedKeys.values()].some((key2) => !uniqueKeys.has(key2))) {
|
|
234
|
+
throw new Error("GPUSQL grouped queries must group by every non-aggregate SELECT expression");
|
|
235
|
+
}
|
|
236
|
+
const columns = statement.items.map((item) => outputNames.get(item));
|
|
237
|
+
if (!statement.orderBy && (statement.limit !== void 0 || statement.offset !== void 0)) {
|
|
238
|
+
throw new Error("GPUSQL LIMIT or OFFSET currently requires ORDER BY");
|
|
239
|
+
}
|
|
240
|
+
const bindAggregateCall = (call) => {
|
|
241
|
+
const name = call.callee.type === "Identifier" ? String(call.callee["name"]).toLowerCase() : "";
|
|
242
|
+
const operation = name === "avg" ? "mean" : name;
|
|
243
|
+
if (operation !== "count" && operation !== "sum" && operation !== "min" && operation !== "max" && operation !== "mean")
|
|
244
|
+
return void 0;
|
|
245
|
+
if (call.arguments.length !== 1)
|
|
246
|
+
throw new Error("GPUSQL aggregates require one argument");
|
|
247
|
+
const argument = call.arguments[0];
|
|
248
|
+
const wildcard = argument.type === "Identifier" && argument["sqlWildcard"] === true;
|
|
249
|
+
if (wildcard && operation !== "count") {
|
|
250
|
+
throw new Error("GPUSQL only permits COUNT(*) as a wildcard aggregation");
|
|
251
|
+
}
|
|
252
|
+
const input = wildcard ? void 0 : lowerSQLExpression(argument, parameters, resolve);
|
|
253
|
+
const output = aggregateOutputs.get(JSON.stringify([operation, input ?? null]));
|
|
254
|
+
if (output !== void 0)
|
|
255
|
+
return (0, import_gpu_expression.column)(output).node;
|
|
256
|
+
let hiddenName;
|
|
257
|
+
do {
|
|
258
|
+
hiddenName = "__sqlPostGroupAggregate" + inputIndex++;
|
|
259
|
+
} while (occupied.has(hiddenName));
|
|
260
|
+
occupied.add(hiddenName);
|
|
261
|
+
return (0, import_gpu_expression.column)(registerAggregate(operation, input, hiddenName)).node;
|
|
262
|
+
};
|
|
263
|
+
const having = statement.having ? new import_gpu_expression.GPUExpression(lowerSQLExpression(statement.having, parameters, (reference) => resolveGPUSQLColumn(reference, "", columns), bindAggregateCall)) : void 0;
|
|
264
|
+
const ordering = (_a = statement.orderBy) == null ? void 0 : _a.map(({ expression, direction, nulls }, index) => {
|
|
265
|
+
const column2 = expression.type === "Literal" && typeof expression.value === "number" ? getGPUSQLProjectionItem(columns, expression.value, "ORDER BY") : expression.type === "Identifier" && !("gpuSQLParameter" in expression) ? expression.name : void 0;
|
|
266
|
+
const aggregate2 = expression.type === "CallExpression" ? bindAggregateCall(expression) : void 0;
|
|
267
|
+
const sortColumn = (aggregate2 == null ? void 0 : aggregate2.kind) === "column" ? aggregate2.name : column2;
|
|
268
|
+
if (sortColumn === void 0 || !aggregate2 && !columns.includes(sortColumn)) {
|
|
269
|
+
throw new Error("GPUSQL grouped ORDER BY requires a SELECT output name, position, or aggregate call");
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
column: sortColumn,
|
|
273
|
+
options: {
|
|
274
|
+
direction,
|
|
275
|
+
nulls: nulls ?? "last",
|
|
276
|
+
nans: "last",
|
|
277
|
+
algorithm: "auto",
|
|
278
|
+
...index === 0 ? { limit: statement.limit, offset: statement.offset } : {}
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
});
|
|
282
|
+
const { predicates: predicates2, selectedColumns: selectedColumns2, derivedColumns: derivedColumns2 } = query;
|
|
283
|
+
if (Object.keys(definitions).length === 0) {
|
|
284
|
+
throw new Error("GPUSQL GROUP BY requires at least one aggregation");
|
|
94
285
|
}
|
|
95
|
-
|
|
286
|
+
const normalized = (0, import_gpu_group_by_query.normalizeGPUDataFrameAggregations)({ ...query, source: frame }, keys[0].output, definitions);
|
|
287
|
+
if (keys.length > 1 || keys[0].output === void 0 || !frame.dictionaries[keys[0].source]) {
|
|
288
|
+
for (const { source } of keys) {
|
|
289
|
+
const format = (_b = frame.schema.fields.find((field) => field.name === source)) == null ? void 0 : _b.format;
|
|
290
|
+
if (!derivedColumns2.some((column2) => column2.name === source) && format !== "uint32" && format !== "sint32" && format !== "float32") {
|
|
291
|
+
throw new Error("GPUSQL GROUP BY requires 32-bit numeric or dictionary keys");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return describe({
|
|
295
|
+
compile: (graph) => (0, import_gpu_group_aggregation_compiler.compileGPUDataFrameObservedAggregation)(frame, predicates2, selectedColumns2, derivedColumns2, keys, normalized, graph, columns, ordering, having, aggregateJoin, maxMeanScratchBytes)
|
|
296
|
+
}, "observed-grouping", columns, selectedColumns2, keys.length);
|
|
297
|
+
}
|
|
298
|
+
const [key] = keys;
|
|
299
|
+
const { groupCount } = query.groupBy(key.source);
|
|
300
|
+
return describe({
|
|
301
|
+
compile: (graph) => (0, import_gpu_group_aggregation_compiler.compileGPUDataFrameGroupedAggregation)(frame, predicates2, selectedColumns2, derivedColumns2, key.source, groupCount, normalized, graph, { key: key.output, columns }, ordering, having, aggregateJoin, maxMeanScratchBytes)
|
|
302
|
+
}, "dense-grouping", columns, selectedColumns2, 1);
|
|
96
303
|
}
|
|
97
304
|
if (aggregates.length !== statement.items.length) {
|
|
98
305
|
throw new Error("GPUSQL global aggregates cannot mix ordinary source columns");
|
|
99
306
|
}
|
|
100
|
-
|
|
307
|
+
const aggregate = query.aggregate(definitions);
|
|
308
|
+
const { predicates, selectedColumns, derivedColumns } = query;
|
|
309
|
+
return describe(aggregateJoin ? {
|
|
310
|
+
compile: (graph) => (0, import_gpu_global_aggregation_compiler.compileGPUDataFrameAggregation)(frame, predicates, selectedColumns, derivedColumns, aggregate.definitions, graph, aggregateJoin)
|
|
311
|
+
} : aggregate, "global-aggregation", statement.items.map((item) => outputNames.get(item)), query.selectedColumns);
|
|
101
312
|
}
|
|
102
|
-
if (statement.groupBy)
|
|
313
|
+
if (statement.groupBy !== void 0)
|
|
103
314
|
throw new Error("GPUSQL GROUP BY requires at least one aggregation");
|
|
104
315
|
const selected = [];
|
|
105
316
|
for (const item of statement.items) {
|
|
@@ -127,55 +338,65 @@ function buildGPUSQLPlan(tables, statement, parameters) {
|
|
|
127
338
|
if (statement.orderBy || statement.limit !== void 0 || statement.offset !== void 0) {
|
|
128
339
|
throw new Error("GPUSQL joined results do not yet support ORDER BY or pagination");
|
|
129
340
|
}
|
|
130
|
-
const right =
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
throw new Error("GPUSQL joins require the left join key to remain selected");
|
|
143
|
-
}
|
|
144
|
-
query = query.select(selected);
|
|
145
|
-
const options = { leftOn: leftKey, rightOn: rightKey };
|
|
146
|
-
switch (statement.join.type) {
|
|
147
|
-
case "left":
|
|
148
|
-
return query.leftJoin(right, options);
|
|
149
|
-
case "semi":
|
|
150
|
-
return query.semiJoin(right, options);
|
|
151
|
-
case "anti":
|
|
152
|
-
return query.antiJoin(right, options);
|
|
153
|
-
default:
|
|
154
|
-
return query.innerJoin(right, options);
|
|
155
|
-
}
|
|
341
|
+
const { right, leftKey, rightKey } = bindJoin(statement.join);
|
|
342
|
+
const keyIsSelected = selected.includes(leftKey);
|
|
343
|
+
const workingColumns = keyIsSelected ? selected : [...selected, leftKey];
|
|
344
|
+
const workingQuery = query.select(workingColumns);
|
|
345
|
+
const joinType = statement.join.type;
|
|
346
|
+
const join = workingQuery[joinMethods[joinType]](right, { leftOn: leftKey, rightOn: rightKey });
|
|
347
|
+
if (keyIsSelected)
|
|
348
|
+
return describe(join, "unique-right-join", selected, workingColumns, 1);
|
|
349
|
+
const { predicates, derivedColumns } = workingQuery;
|
|
350
|
+
return describe({
|
|
351
|
+
compile: (graph) => (0, import_gpu_join_compiler.compileGPUDataFrameJoin)(frame, predicates, workingColumns, derivedColumns, right, join.options, joinType, graph, selected)
|
|
352
|
+
}, "unique-right-join", selected, workingColumns, 1);
|
|
156
353
|
}
|
|
157
354
|
if (statement.orderBy) {
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
355
|
+
const workingColumns = new Set(selected);
|
|
356
|
+
const resolvedKeys = statement.orderBy.map(({ expression, direction, nulls }) => {
|
|
357
|
+
let orderColumn;
|
|
358
|
+
if (expression.type === "Literal" && typeof expression.value === "number") {
|
|
359
|
+
orderColumn = getGPUSQLProjectionItem(selected, expression.value, "ORDER BY");
|
|
360
|
+
} else if (expression.type === "Identifier" && !("gpuSQLParameter" in expression) && selected.includes(expression.name)) {
|
|
361
|
+
orderColumn = expression.name;
|
|
362
|
+
} else {
|
|
363
|
+
const sortExpression = lowerSQLExpression(expression, parameters, resolve);
|
|
364
|
+
if (sortExpression.kind === "column") {
|
|
365
|
+
orderColumn = sortExpression.name;
|
|
366
|
+
} else {
|
|
367
|
+
orderColumn = "__sqlOrderKey";
|
|
368
|
+
while (frame.columnNames.includes(orderColumn) || workingColumns.has(orderColumn)) {
|
|
369
|
+
orderColumn += "_";
|
|
370
|
+
}
|
|
371
|
+
query = query.withColumn(orderColumn, new import_gpu_expression.GPUExpression(sortExpression));
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
workingColumns.add(orderColumn);
|
|
375
|
+
return { column: orderColumn, direction, nulls };
|
|
166
376
|
});
|
|
167
|
-
|
|
377
|
+
const columns = [...workingColumns];
|
|
378
|
+
const workingQuery = query.select(columns);
|
|
379
|
+
const plans = resolvedKeys.map(({ column: column3, direction, nulls }) => ({
|
|
380
|
+
column: column3,
|
|
381
|
+
plan: workingQuery.sortByGlobal(column3, { direction, nulls })
|
|
382
|
+
}));
|
|
383
|
+
const [{ column: column2, plan: sort }, ...secondary] = plans;
|
|
384
|
+
const page = statement.limit === void 0 && statement.offset === void 0 ? sort : sort.page(statement.offset ?? 0, statement.limit);
|
|
385
|
+
const projection = columns.length > selected.length ? selected : void 0;
|
|
386
|
+
if (!projection && secondary.length === 0)
|
|
387
|
+
return describe(page, "global-sort", selected, columns, plans.length);
|
|
388
|
+
const { predicates, derivedColumns } = workingQuery;
|
|
389
|
+
const additionalKeys = secondary.map((key) => ({
|
|
390
|
+
column: key.column,
|
|
391
|
+
options: key.plan.options
|
|
392
|
+
}));
|
|
393
|
+
return describe({
|
|
394
|
+
compile: (graph) => (0, import_gpu_global_sort_compiler.compileGPUDataFrameGlobalSort)(frame, predicates, columns, derivedColumns, column2, page.options, graph, projection, additionalKeys)
|
|
395
|
+
}, "global-sort", selected, columns, plans.length);
|
|
168
396
|
}
|
|
169
397
|
if (statement.limit !== void 0 || statement.offset !== void 0)
|
|
170
398
|
throw new Error("GPUSQL LIMIT or OFFSET currently requires ORDER BY");
|
|
171
|
-
return query.select(selected);
|
|
172
|
-
}
|
|
173
|
-
function resolveGPUSQLProjectionName(item, resolve) {
|
|
174
|
-
var _a, _b;
|
|
175
|
-
if (((_a = item.expression) == null ? void 0 : _a.type) !== "Identifier" && ((_b = item.expression) == null ? void 0 : _b.type) !== "MemberExpression") {
|
|
176
|
-
throw new Error("GPUSQL grouped source expressions must reference the group key directly");
|
|
177
|
-
}
|
|
178
|
-
return resolve(readGPUSQLColumn(item.expression));
|
|
399
|
+
return describe(query.select(selected), "projection", selected);
|
|
179
400
|
}
|
|
180
401
|
function formatGPUSQLColumn({ name, qualifier }) {
|
|
181
402
|
return qualifier === void 0 ? name : qualifier + "." + name;
|
|
@@ -192,26 +413,60 @@ function resolveGPUSQLColumn(reference, qualifier, columns) {
|
|
|
192
413
|
}
|
|
193
414
|
return reference.name;
|
|
194
415
|
}
|
|
416
|
+
function splitGPUSQLHaving(source) {
|
|
417
|
+
const tokens = /"(?:""|[^"])*"|'(?:''|[^'])*'|:[A-Za-z_]\w*|[A-Za-z_]\w*|[();]|--[^\r\n]*|\/\*/g;
|
|
418
|
+
let depth = 0;
|
|
419
|
+
let start = -1;
|
|
420
|
+
let predicateStart = -1;
|
|
421
|
+
let end = source.length;
|
|
422
|
+
let tailStarted = false;
|
|
423
|
+
for (const token of source.matchAll(tokens)) {
|
|
424
|
+
if (token[0].startsWith("--"))
|
|
425
|
+
continue;
|
|
426
|
+
if (token[0] === "/*") {
|
|
427
|
+
throw new Error("GPUSQL does not support SQL comments");
|
|
428
|
+
}
|
|
429
|
+
if (token[0] === "(")
|
|
430
|
+
depth++;
|
|
431
|
+
if (token[0] === ")")
|
|
432
|
+
depth--;
|
|
433
|
+
if (depth !== 0)
|
|
434
|
+
continue;
|
|
435
|
+
const keyword = token[0].toUpperCase();
|
|
436
|
+
if (start !== -1 && ["ORDER", "LIMIT", "OFFSET", ";"].includes(keyword)) {
|
|
437
|
+
end = token.index;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
if (start === -1 && ["ORDER", "LIMIT", "OFFSET", ";"].includes(keyword))
|
|
441
|
+
tailStarted = true;
|
|
442
|
+
if (start === -1 && keyword === "HAVING") {
|
|
443
|
+
if (tailStarted)
|
|
444
|
+
throw new Error("GPUSQL HAVING must precede ORDER BY and pagination");
|
|
445
|
+
start = token.index;
|
|
446
|
+
predicateStart = start + token[0].length;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return start === -1 ? { select: source } : {
|
|
450
|
+
select: source.slice(0, start) + " " + source.slice(end),
|
|
451
|
+
having: source.slice(predicateStart, end)
|
|
452
|
+
};
|
|
453
|
+
}
|
|
195
454
|
function parseGPUSQLStatement(source) {
|
|
196
|
-
var _a, _b, _c
|
|
197
|
-
const
|
|
455
|
+
var _a, _b, _c;
|
|
456
|
+
const { select, having } = splitGPUSQLHaving(source);
|
|
457
|
+
const options = {
|
|
198
458
|
parseParameter: (name) => ({ type: "Identifier", name, gpuSQLParameter: true })
|
|
199
|
-
}
|
|
459
|
+
};
|
|
460
|
+
const statement = (0, import_parser.parseSQLSelectStatement)(select, options);
|
|
200
461
|
if (statement.offset !== void 0 && statement.offset > 4294967295) {
|
|
201
462
|
throw new Error("GPUSQL OFFSET must fit an unsigned 32-bit row count");
|
|
202
463
|
}
|
|
203
464
|
if (statement.joins.length > 1)
|
|
204
465
|
throw new Error("GPUSQL currently supports one JOIN");
|
|
205
|
-
if ((((_a = statement.groupBy) == null ? void 0 : _a.length) ?? 0) > 1) {
|
|
206
|
-
throw new Error("GPUSQL currently supports one GROUP BY column");
|
|
207
|
-
}
|
|
208
|
-
if ((((_b = statement.orderBy) == null ? void 0 : _b.length) ?? 0) > 1) {
|
|
209
|
-
throw new Error("GPUSQL currently supports one ORDER BY column");
|
|
210
|
-
}
|
|
211
466
|
if (statement.limit !== void 0 && statement.limit > 4294967295) {
|
|
212
467
|
throw new Error("GPUSQL LIMIT must fit an unsigned 32-bit row count");
|
|
213
468
|
}
|
|
214
|
-
const items = ((
|
|
469
|
+
const items = ((_a = statement.select) == null ? void 0 : _a.map(({ expression, alias }) => {
|
|
215
470
|
if (expression.type === "CallExpression" && expression.callee.type === "Identifier") {
|
|
216
471
|
const name = String(expression.callee["name"]).toLowerCase();
|
|
217
472
|
const aggregate = name === "avg" ? "mean" : name;
|
|
@@ -226,12 +481,12 @@ function parseGPUSQLStatement(source) {
|
|
|
226
481
|
}
|
|
227
482
|
const argument = expression.arguments[0];
|
|
228
483
|
const wildcard = argument.type === "Identifier" && argument["sqlWildcard"] === true;
|
|
229
|
-
if (aggregate
|
|
484
|
+
if (wildcard && aggregate !== "count") {
|
|
230
485
|
throw new Error("GPUSQL only permits COUNT(*) as a wildcard aggregation");
|
|
231
486
|
}
|
|
232
487
|
return {
|
|
233
488
|
aggregate,
|
|
234
|
-
...wildcard ? {} : {
|
|
489
|
+
...wildcard ? {} : { aggregateInput: argument },
|
|
235
490
|
alias
|
|
236
491
|
};
|
|
237
492
|
}
|
|
@@ -260,23 +515,29 @@ function parseGPUSQLStatement(source) {
|
|
|
260
515
|
right: readGPUSQLColumn(join.on.right)
|
|
261
516
|
};
|
|
262
517
|
}
|
|
263
|
-
const sort = (_d = statement.orderBy) == null ? void 0 : _d[0];
|
|
264
518
|
return {
|
|
265
519
|
items,
|
|
266
520
|
table: statement.from.name,
|
|
267
521
|
alias: statement.from.alias,
|
|
268
522
|
join: loweredJoin,
|
|
269
523
|
predicate: statement.where,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
524
|
+
having: having === void 0 ? void 0 : (0, import_parser.parseSQLSelectStatement)("SELECT (" + having + "\n) FROM __gpu_having", options).select[0].expression,
|
|
525
|
+
groupBy: ((_b = statement.groupBy) == null ? void 0 : _b.length) ? statement.groupBy.map((expression) => expression) : void 0,
|
|
526
|
+
orderBy: ((_c = statement.orderBy) == null ? void 0 : _c.length) ? statement.orderBy.map((sort) => ({
|
|
527
|
+
expression: sort.expression,
|
|
273
528
|
direction: sort.direction === "desc" ? "descending" : "ascending",
|
|
274
529
|
nulls: sort.nulls
|
|
275
|
-
},
|
|
530
|
+
})) : void 0,
|
|
276
531
|
offset: statement.offset,
|
|
277
532
|
limit: statement.limit
|
|
278
533
|
};
|
|
279
534
|
}
|
|
535
|
+
function getGPUSQLProjectionItem(projection, position, clause) {
|
|
536
|
+
if (!Number.isSafeInteger(position) || position < 1 || position > projection.length) {
|
|
537
|
+
throw new Error("GPUSQL " + clause + " position must be a one-based SELECT column number");
|
|
538
|
+
}
|
|
539
|
+
return projection[position - 1];
|
|
540
|
+
}
|
|
280
541
|
function readGPUSQLColumn(node) {
|
|
281
542
|
const expression = node;
|
|
282
543
|
if (expression.type === "Identifier" && !("gpuSQLParameter" in expression)) {
|
|
@@ -291,7 +552,7 @@ function readGPUSQLColumn(node) {
|
|
|
291
552
|
}
|
|
292
553
|
throw new Error("GPUSQL expected a table or column identifier");
|
|
293
554
|
}
|
|
294
|
-
function lowerSQLExpression(node, parameters, resolve) {
|
|
555
|
+
function lowerSQLExpression(node, parameters, resolve, resolveCall) {
|
|
295
556
|
const expression = node;
|
|
296
557
|
try {
|
|
297
558
|
return (0, import_portable_expression.lowerPortableExpression)(expression, (leaf) => {
|
|
@@ -306,6 +567,9 @@ function lowerSQLExpression(node, parameters, resolve) {
|
|
|
306
567
|
return (0, import_gpu_expression.column)(resolve(readGPUSQLColumn(leaf))).node;
|
|
307
568
|
}
|
|
308
569
|
if (leaf.type === "CallExpression" && leaf.callee.type === "Identifier") {
|
|
570
|
+
const replacement = resolveCall == null ? void 0 : resolveCall(leaf);
|
|
571
|
+
if (replacement)
|
|
572
|
+
return replacement;
|
|
309
573
|
const name = leaf.callee["name"];
|
|
310
574
|
const functionName = typeof name === "string" && leaf["sqlFunction"] === true ? name.toLowerCase() : name;
|
|
311
575
|
if (name !== "isNull" && name !== "isNotNull" && name !== "in" && name !== "cast" && functionName !== "coalesce" && functionName !== "nullif" && !(0, import_gpu_expression.isGPUScalarFunction)(functionName)) {
|
|
@@ -1,12 +1,50 @@
|
|
|
1
1
|
import type { GPUCommandGraph } from '@luma.gl/graph/gpu-core';
|
|
2
2
|
import { GPUDataFrame } from "../gpu-dataframe/gpu-data-frame.js";
|
|
3
|
+
import type { GPUDataFrameJoinType } from "../gpu-dataframe/gpu-join-query.js";
|
|
3
4
|
import type { CompiledGPUDataFrameQuery, GPUDataFrameQueryParameters } from "../gpu-dataframe/gpu-query-compiler.js";
|
|
4
5
|
/** Explicit GPU dataframe registrations; Arrow remains exclusively an adapter boundary. */
|
|
5
6
|
export type GPUSQLTables = Readonly<Record<string, GPUDataFrame>>;
|
|
6
|
-
/**
|
|
7
|
+
/** Configuration for GPU-only SQL planning. */
|
|
7
8
|
export type GPUSQLQueryOptions = Readonly<{
|
|
9
|
+
/** Defaults for named SQL parameters such as :minimumFare. */
|
|
8
10
|
parameters?: GPUDataFrameQueryParameters;
|
|
11
|
+
/** Maximum temporary count bytes per grouped AVG operation. */
|
|
12
|
+
maxMeanScratchBytes?: number;
|
|
9
13
|
}>;
|
|
14
|
+
/** Execution route selected by the GPU SQL planner. */
|
|
15
|
+
export type GPUSQLExecution = 'projection' | 'global-sort' | 'global-aggregation' | 'dense-grouping' | 'observed-grouping' | 'unique-right-join';
|
|
16
|
+
/** CPU-only description of the bound GPU SQL plan. */
|
|
17
|
+
export type GPUSQLExplanation = Readonly<{
|
|
18
|
+
/** Registered input table. */
|
|
19
|
+
table: string;
|
|
20
|
+
/** Whether a source-row WHERE predicate runs before the terminal operation. */
|
|
21
|
+
filtered: boolean;
|
|
22
|
+
/** A post-aggregation HAVING predicate filters the grouped result. */
|
|
23
|
+
having?: true;
|
|
24
|
+
/** Terminal GPU dataframe execution route. */
|
|
25
|
+
execution: GPUSQLExecution;
|
|
26
|
+
/** Result fields in SELECT order. */
|
|
27
|
+
columns: readonly string[];
|
|
28
|
+
/** Columns used internally, including derived or hidden keys when applicable. */
|
|
29
|
+
workingColumns: readonly string[];
|
|
30
|
+
/** Number of resolved grouping or ordering keys. */
|
|
31
|
+
keyCount: number;
|
|
32
|
+
/** Registered right table and join type for join plans. */
|
|
33
|
+
join?: Readonly<{
|
|
34
|
+
table: string;
|
|
35
|
+
type: GPUDataFrameJoinType;
|
|
36
|
+
}>;
|
|
37
|
+
/** Applied global page bounds, when supplied. */
|
|
38
|
+
page?: Readonly<{
|
|
39
|
+
offset: number;
|
|
40
|
+
limit?: number;
|
|
41
|
+
}>;
|
|
42
|
+
}>;
|
|
43
|
+
/** Binds executable operations to the immutable description produced at planning time. */
|
|
44
|
+
type GPUSQLBoundPlan = {
|
|
45
|
+
plan: GPUSQLCompiledPlan;
|
|
46
|
+
explanation: GPUSQLExplanation;
|
|
47
|
+
};
|
|
10
48
|
type GPUSQLCompiledPlan = Readonly<{
|
|
11
49
|
compile: (graph: GPUCommandGraph<GPUDataFrameQueryParameters>) => CompiledGPUDataFrameQuery;
|
|
12
50
|
}>;
|
|
@@ -28,7 +66,9 @@ export declare class GPUSQLQuery {
|
|
|
28
66
|
readonly sql: string;
|
|
29
67
|
private readonly plan;
|
|
30
68
|
/** @internal */
|
|
31
|
-
constructor(sql: string, plan:
|
|
69
|
+
constructor(sql: string, plan: GPUSQLBoundPlan);
|
|
70
|
+
/** Returns a frozen plan description without allocating GPU resources. */
|
|
71
|
+
explain(): GPUSQLExplanation;
|
|
32
72
|
/** Compiles existing dataframe operations into the caller-owned GPU command graph. */
|
|
33
73
|
compile(graph: GPUCommandGraph<GPUDataFrameQueryParameters>): CompiledGPUDataFrameQuery;
|
|
34
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gpu-sql.d.ts","sourceRoot":"","sources":["../../src/gpu-sql/gpu-sql.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"gpu-sql.d.ts","sourceRoot":"","sources":["../../src/gpu-sql/gpu-sql.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAG7D,OAAO,EAAC,YAAY,EAAC,2CAAwC;AA0B7D,OAAO,KAAK,EACV,oBAAoB,EAErB,2CAAwC;AACzC,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC5B,+CAA4C;AAE7C,2FAA2F;AAC3F,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAElE,+CAA+C;AAC/C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,8DAA8D;IAC9D,UAAU,CAAC,EAAE,2BAA2B,CAAC;IACzC,+DAA+D;IAC/D,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC,CAAC;AAqCH,uDAAuD;AACvD,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,aAAa,GACb,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,mBAAmB,CAAC;AAExB,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,QAAQ,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,MAAM,CAAC,EAAE,IAAI,CAAC;IACd,8CAA8C;IAC9C,SAAS,EAAE,eAAe,CAAC;IAC3B,qCAAqC;IACrC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3B,iFAAiF;IACjF,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,oBAAoB,CAAA;KAAC,CAAC,CAAC;IAC7D,iDAAiD;IACjD,IAAI,CAAC,EAAE,QAAQ,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CACnD,CAAC,CAAC;AAEH,0FAA0F;AAC1F,KAAK,eAAe,GAAG;IAAC,IAAI,EAAE,kBAAkB,CAAC;IAAC,WAAW,EAAE,iBAAiB,CAAA;CAAC,CAAC;AAElF,KAAK,kBAAkB,GAAG,QAAQ,CAAC;IACjC,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,2BAA2B,CAAC,KAAK,yBAAyB,CAAC;CAC7F,CAAC,CAAC;AAyCH;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyC;gBAEpD,MAAM,EAAE,YAAY;IAchC,8FAA8F;IAC9F,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,WAAW;CAOrE;AAED,+FAA+F;AAC/F,qBAAa,WAAW;IACtB,2FAA2F;IAC3F,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkB;IAEvC,gBAAgB;gBACJ,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,eAAe;IAM9C,0EAA0E;IAC1E,OAAO,IAAI,iBAAiB;IAI5B,sFAAsF;IACtF,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,2BAA2B,CAAC,GAAG,yBAAyB;CAGxF"}
|