@slexisvn/query-engine 0.1.0
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/binder/binder.d.ts +130 -0
- package/dist/binder/expression-binder.d.ts +168 -0
- package/dist/binder/scope.d.ts +40 -0
- package/dist/browser.d.ts +8 -0
- package/dist/catalog/catalog.d.ts +53 -0
- package/dist/catalog/function-registry.d.ts +26 -0
- package/dist/catalog/statistics-cache.d.ts +39 -0
- package/dist/catalog/statistics.d.ts +72 -0
- package/dist/catalog/tpch-schema.d.ts +15 -0
- package/dist/cli/cli-common.d.ts +11 -0
- package/dist/cli/coordinator.d.ts +1 -0
- package/dist/cli/format.d.ts +8 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/loaders/csv-loader.d.ts +17 -0
- package/dist/cli/loaders/data-loader.d.ts +7 -0
- package/dist/cli/loaders/json-loader.d.ts +13 -0
- package/dist/cli/loaders/loader-factory.d.ts +4 -0
- package/dist/cli/repl.d.ts +6 -0
- package/dist/cli/worker.d.ts +1 -0
- package/dist/config.d.ts +42 -0
- package/dist/core.wasm +0 -0
- package/dist/dataframe/column-expr.d.ts +67 -0
- package/dist/dataframe/dataframe.d.ts +96 -0
- package/dist/dataframe/expr-types.d.ts +6 -0
- package/dist/dataframe/in-memory-relation.d.ts +31 -0
- package/dist/dataframe/index.d.ts +4 -0
- package/dist/dataframe/schema.d.ts +35 -0
- package/dist/dataframe/sql-expr-binder.d.ts +17 -0
- package/dist/dataframe/type-inference.d.ts +8 -0
- package/dist/distributed/cluster/cluster-manager.d.ts +54 -0
- package/dist/distributed/cluster/heartbeat-monitor.d.ts +27 -0
- package/dist/distributed/cluster/node-descriptor.d.ts +41 -0
- package/dist/distributed/distributed-types.d.ts +336 -0
- package/dist/distributed/execution/coordinator.d.ts +53 -0
- package/dist/distributed/execution/exchange-operator.d.ts +44 -0
- package/dist/distributed/execution/fragment-executor.d.ts +48 -0
- package/dist/distributed/execution/merge-exchange.d.ts +55 -0
- package/dist/distributed/optimizer/distributed-sort.d.ts +6 -0
- package/dist/distributed/optimizer/distribution-aware-join.d.ts +28 -0
- package/dist/distributed/optimizer/partial-aggregate.d.ts +9 -0
- package/dist/distributed/partition/partition-map.d.ts +27 -0
- package/dist/distributed/partition/partition-pruner.d.ts +33 -0
- package/dist/distributed/partition/partition-strategy.d.ts +43 -0
- package/dist/distributed/planner/distributed-planner.d.ts +71 -0
- package/dist/distributed/planner/exchange-placement.d.ts +19 -0
- package/dist/distributed/planner/expr-utils.d.ts +2 -0
- package/dist/distributed/planner/fragment.d.ts +47 -0
- package/dist/distributed/transport/chunk-codec.d.ts +18 -0
- package/dist/distributed/transport/http-transport.d.ts +49 -0
- package/dist/distributed/transport/transport.d.ts +13 -0
- package/dist/engine/query-engine.d.ts +142 -0
- package/dist/engine-entry.d.ts +12 -0
- package/dist/execution/builders/aggregate-builder.d.ts +46 -0
- package/dist/execution/builders/builder-utils.d.ts +5 -0
- package/dist/execution/builders/cte-builders.d.ts +20 -0
- package/dist/execution/builders/exchange-builders.d.ts +33 -0
- package/dist/execution/builders/join-builder.d.ts +67 -0
- package/dist/execution/builders/pipeline-builders.d.ts +30 -0
- package/dist/execution/builders/source-builders.d.ts +23 -0
- package/dist/execution/column-resolve.d.ts +7 -0
- package/dist/execution/execution-types.d.ts +33 -0
- package/dist/execution/expression-eval.d.ts +13 -0
- package/dist/execution/fragment-spec.d.ts +125 -0
- package/dist/execution/join-utils.d.ts +14 -0
- package/dist/execution/operator-registry.d.ts +9 -0
- package/dist/execution/operators/agg-wasm.d.ts +16 -0
- package/dist/execution/operators/dedup-core.d.ts +10 -0
- package/dist/execution/operators/dependent-join.d.ts +14 -0
- package/dist/execution/operators/distinct.d.ts +12 -0
- package/dist/execution/operators/filter.d.ts +87 -0
- package/dist/execution/operators/hash-aggregate.d.ts +121 -0
- package/dist/execution/operators/hash-join.d.ts +74 -0
- package/dist/execution/operators/index-scan.d.ts +34 -0
- package/dist/execution/operators/join-core.d.ts +47 -0
- package/dist/execution/operators/merge-join.d.ts +38 -0
- package/dist/execution/operators/nested-loop-join.d.ts +28 -0
- package/dist/execution/operators/projection.d.ts +20 -0
- package/dist/execution/operators/scan.d.ts +17 -0
- package/dist/execution/operators/sort.d.ts +48 -0
- package/dist/execution/operators/stream-aggregate.d.ts +30 -0
- package/dist/execution/operators/union.d.ts +13 -0
- package/dist/execution/operators/vector-aggregate.d.ts +73 -0
- package/dist/execution/operators/window.d.ts +22 -0
- package/dist/execution/physical-plan.d.ts +14 -0
- package/dist/execution/pipeline.d.ts +28 -0
- package/dist/execution/query-executor.d.ts +70 -0
- package/dist/execution/query-result.d.ts +15 -0
- package/dist/execution/result-sink.d.ts +26 -0
- package/dist/execution/scheduler.d.ts +8 -0
- package/dist/execution/vector-ops.d.ts +32 -0
- package/dist/execution/wasm-expr-eval.d.ts +7 -0
- package/dist/index.browser.js +17999 -0
- package/dist/index.cli.js +1002 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.node.js +21432 -0
- package/dist/optimizer/dphyp/cardinality.d.ts +69 -0
- package/dist/optimizer/dphyp/cost-model.d.ts +47 -0
- package/dist/optimizer/dphyp/dphyp.d.ts +32 -0
- package/dist/optimizer/dphyp/hypergraph.d.ts +38 -0
- package/dist/optimizer/optimizer.d.ts +12 -0
- package/dist/optimizer/pass.d.ts +5 -0
- package/dist/optimizer/passes/aggregate-pushdown.d.ts +6 -0
- package/dist/optimizer/passes/cte-optimization.d.ts +6 -0
- package/dist/optimizer/passes/empty-propagation.d.ts +6 -0
- package/dist/optimizer/passes/expr-walk.d.ts +20 -0
- package/dist/optimizer/passes/expression-simplifier.d.ts +8 -0
- package/dist/optimizer/passes/filter-ordering.d.ts +13 -0
- package/dist/optimizer/passes/having-pushdown.d.ts +6 -0
- package/dist/optimizer/passes/index-selection.d.ts +24 -0
- package/dist/optimizer/passes/join-elimination.d.ts +6 -0
- package/dist/optimizer/passes/join-reorder.d.ts +12 -0
- package/dist/optimizer/passes/join-residual-split.d.ts +6 -0
- package/dist/optimizer/passes/limit-pushdown.d.ts +6 -0
- package/dist/optimizer/passes/node-merge.d.ts +6 -0
- package/dist/optimizer/passes/outer-to-inner.d.ts +6 -0
- package/dist/optimizer/passes/physical-design.d.ts +12 -0
- package/dist/optimizer/passes/plan-refs.d.ts +22 -0
- package/dist/optimizer/passes/predicate-dedup.d.ts +6 -0
- package/dist/optimizer/passes/predicate-inference.d.ts +6 -0
- package/dist/optimizer/passes/predicate-pushdown.d.ts +9 -0
- package/dist/optimizer/passes/projection-pushdown.d.ts +6 -0
- package/dist/optimizer/passes/sort-elimination.d.ts +6 -0
- package/dist/optimizer/passes/subquery-unnesting.d.ts +6 -0
- package/dist/optimizer/passes/topn-fusion.d.ts +6 -0
- package/dist/parallel/chunk-transport.d.ts +24 -0
- package/dist/parallel/fragment-pool.d.ts +49 -0
- package/dist/parallel/fragment-worker.d.ts +1 -0
- package/dist/parallel/morsel-scheduler.d.ts +11 -0
- package/dist/parallel/parallel-dispatch.d.ts +69 -0
- package/dist/parallel/partial-spill.d.ts +3 -0
- package/dist/parallel/worker-messages.d.ts +243 -0
- package/dist/parallel/worker-pool.d.ts +62 -0
- package/dist/parallel/worker-thread.d.ts +1 -0
- package/dist/parser/ast.d.ts +298 -0
- package/dist/parser/lexer.d.ts +135 -0
- package/dist/parser/parser.d.ts +64 -0
- package/dist/planner/logical-plan.d.ts +250 -0
- package/dist/planner/logical-planner.d.ts +23 -0
- package/dist/planner/plan-formatter.d.ts +4 -0
- package/dist/planner/plan-visitor.d.ts +58 -0
- package/dist/runtime/platform.d.ts +4 -0
- package/dist/storage/backend/memory-storage-backend.d.ts +14 -0
- package/dist/storage/backend/node-storage-backend.d.ts +11 -0
- package/dist/storage/btree.d.ts +34 -0
- package/dist/storage/buffer-pool.d.ts +17 -0
- package/dist/storage/chunk.d.ts +26 -0
- package/dist/storage/column.d.ts +38 -0
- package/dist/storage/data-type.d.ts +54 -0
- package/dist/storage/dictionary-column.d.ts +33 -0
- package/dist/storage/page-store/file-page-store.d.ts +13 -0
- package/dist/storage/page-store/memory-page-store.d.ts +9 -0
- package/dist/storage/sab-arena.d.ts +26 -0
- package/dist/storage/serializer.d.ts +6 -0
- package/dist/storage/spill-manager/fs-storage.d.ts +11 -0
- package/dist/storage/spill-manager/memory-storage.d.ts +10 -0
- package/dist/storage/spill-manager/spill-manager.d.ts +17 -0
- package/dist/storage/storage-constants.d.ts +3 -0
- package/dist/storage/table.d.ts +31 -0
- package/dist/storage/temp-space/memory-temp-space.d.ts +11 -0
- package/dist/storage/temp-space/temp-directory-manager.d.ts +14 -0
- package/dist/utils/bitmap.d.ts +11 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/lru-cache.d.ts +24 -0
- package/dist/utils/priority-queue.d.ts +18 -0
- package/dist/wasm/dispatch.d.ts +13 -0
- package/dist/wasm/fetch-byte-source.d.ts +2 -0
- package/dist/wasm/kernels/core-instance.d.ts +6 -0
- package/dist/wasm/kernels/kernel-factory.d.ts +8 -0
- package/dist/wasm/kernels/wasm-aggregate.d.ts +6 -0
- package/dist/wasm/kernels/wasm-arithmetic.d.ts +13 -0
- package/dist/wasm/kernels/wasm-filter-f64.d.ts +8 -0
- package/dist/wasm/kernels/wasm-filter.d.ts +5 -0
- package/dist/wasm/loader.d.ts +17 -0
- package/dist/wasm/node-byte-source.d.ts +1 -0
- package/dist/wasm/region-allocator.d.ts +23 -0
- package/dist/wasm/register-kernels.d.ts +1 -0
- package/dist/wasm/wasm-loader-base.d.ts +33 -0
- package/dist/wasm/wasm-types.d.ts +103 -0
- package/package.json +60 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type BoundExpr, type BoundColumnRefNode, type BoundBinaryNode, type BoundBetweenNode, type BoundLikeNode, type BoundInListNode, type BoundIsNullNode, type LiteralValue } from '../../binder/expression-binder.js';
|
|
2
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
export interface Mcv {
|
|
4
|
+
values: (string | number)[];
|
|
5
|
+
frequencies: number[];
|
|
6
|
+
}
|
|
7
|
+
export interface Histogram {
|
|
8
|
+
numBuckets: number;
|
|
9
|
+
totalCount: number;
|
|
10
|
+
boundaries: (number | bigint)[];
|
|
11
|
+
bucketCounts: number[];
|
|
12
|
+
bucketDistincts: number[];
|
|
13
|
+
estimateLessThan(value: LiteralValue): number;
|
|
14
|
+
estimateRange(low: LiteralValue, high: LiteralValue): number;
|
|
15
|
+
}
|
|
16
|
+
export interface ColumnStats {
|
|
17
|
+
ndv?: number;
|
|
18
|
+
nullFraction?: number;
|
|
19
|
+
avgLength?: number;
|
|
20
|
+
min?: number | bigint | string | null;
|
|
21
|
+
max?: number | bigint | string | null;
|
|
22
|
+
mcv?: Mcv;
|
|
23
|
+
histogram?: Histogram;
|
|
24
|
+
}
|
|
25
|
+
export interface TableStats {
|
|
26
|
+
rowCount: number;
|
|
27
|
+
columnStats?: Map<string, ColumnStats>;
|
|
28
|
+
getCorrelation?(a: string, b: string): number | null;
|
|
29
|
+
}
|
|
30
|
+
export interface StatsProvider {
|
|
31
|
+
get(key: string): TableStats | undefined;
|
|
32
|
+
values(): IterableIterator<TableStats>;
|
|
33
|
+
}
|
|
34
|
+
export interface EquiPred {
|
|
35
|
+
left: BoundExpr;
|
|
36
|
+
right: BoundExpr;
|
|
37
|
+
}
|
|
38
|
+
export declare class DefaultCardinalityEstimator {
|
|
39
|
+
stats: StatsProvider;
|
|
40
|
+
constructor(statisticsProvider: StatsProvider);
|
|
41
|
+
estimateScan(tableName: string): number;
|
|
42
|
+
estimatePlan(node?: LogicalPlanNode | null): number;
|
|
43
|
+
estimateFilter(inputCard: number, predicate: BoundExpr | null): number;
|
|
44
|
+
estimateJoin(leftCard: number, rightCard: number, condition: BoundExpr | null): number;
|
|
45
|
+
estimateEquiJoinSelectivity(leftExpr: BoundExpr, rightExpr: BoundExpr, leftCard: number, rightCard: number): number;
|
|
46
|
+
_histogramJoinCollision(sA: ColumnStats | null, sB: ColumnStats | null): number | null;
|
|
47
|
+
estimateLeftJoin(leftCard: number, rightCard: number, condition: BoundExpr | null): number;
|
|
48
|
+
estimateSemiJoin(leftCard: number, rightCard: number, condition: BoundExpr | null): number;
|
|
49
|
+
estimateSemiJoinSelectivity(leftExpr: BoundExpr, rightExpr: BoundExpr): number;
|
|
50
|
+
estimateAntiJoin(leftCard: number, rightCard: number, condition: BoundExpr | null): number;
|
|
51
|
+
estimateAggregate(inputCard: number, groupByCount: number, groupByExprs?: BoundExpr[]): number;
|
|
52
|
+
estimateSelectivity(predicate: BoundExpr | null): number;
|
|
53
|
+
estimateEqualitySelectivity(predicate: BoundBinaryNode): number;
|
|
54
|
+
estimateRangeSelectivity(predicate: BoundBinaryNode): number;
|
|
55
|
+
estimateBetweenSelectivity(predicate: BoundBetweenNode): number;
|
|
56
|
+
estimateInListSelectivity(predicate: BoundInListNode): number;
|
|
57
|
+
estimateIsNullSelectivity(predicate: BoundIsNullNode): number;
|
|
58
|
+
estimateLikeSelectivity(predicate: BoundLikeNode): number;
|
|
59
|
+
isPrefixPattern(pattern: string): boolean;
|
|
60
|
+
isContainsPattern(pattern: string): boolean;
|
|
61
|
+
isSuffixPattern(pattern: string): boolean;
|
|
62
|
+
likeFallback(type: string): number;
|
|
63
|
+
lookupCorrelation(leftPred: BoundExpr, rightPred: BoundExpr): number;
|
|
64
|
+
extractSingleColumn(pred: BoundExpr): BoundColumnRefNode | null;
|
|
65
|
+
getColumnNdv(expr: BoundExpr): number;
|
|
66
|
+
getColumnStats(expr: BoundExpr | null): ColumnStats | null;
|
|
67
|
+
extractEquiPredicates(condition: BoundExpr | null): EquiPred[];
|
|
68
|
+
_collectEqui(expr: BoundExpr | null, result: EquiPred[]): void;
|
|
69
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface CostModelOptions {
|
|
2
|
+
hashBuildCost?: number;
|
|
3
|
+
hashProbeCost?: number;
|
|
4
|
+
compareCost?: number;
|
|
5
|
+
scanCost?: number;
|
|
6
|
+
filterCost?: number;
|
|
7
|
+
outputCost?: number;
|
|
8
|
+
memoryCost?: number;
|
|
9
|
+
ioCost?: number;
|
|
10
|
+
spillThreshold?: number;
|
|
11
|
+
crossJoinPenalty?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class DefaultCostModel {
|
|
14
|
+
C_HASH_BUILD: number;
|
|
15
|
+
C_HASH_PROBE: number;
|
|
16
|
+
C_COMPARE: number;
|
|
17
|
+
C_SCAN: number;
|
|
18
|
+
C_FILTER: number;
|
|
19
|
+
C_OUTPUT: number;
|
|
20
|
+
C_MEMORY: number;
|
|
21
|
+
C_IO: number;
|
|
22
|
+
SPILL_THRESHOLD: number;
|
|
23
|
+
C_CROSS: number;
|
|
24
|
+
constructor(options?: CostModelOptions);
|
|
25
|
+
hashJoinCost(buildCard: number, probeCard: number, outputCard?: number | null): number;
|
|
26
|
+
mergeJoinCost(leftCard: number, rightCard: number, outputCard?: number | null): number;
|
|
27
|
+
sortMergeJoinCost(leftCard: number, rightCard: number, outputCard?: number | null): number;
|
|
28
|
+
nestedLoopJoinCost(outerCard: number, innerCard: number): number;
|
|
29
|
+
crossJoinCost(leftCard: number, rightCard: number): number;
|
|
30
|
+
sortCost(card: number): number;
|
|
31
|
+
topNSortCost(card: number, limit: number): number;
|
|
32
|
+
scanCost(card: number): number;
|
|
33
|
+
filterCost(card: number): number;
|
|
34
|
+
aggregateCost(card: number): number;
|
|
35
|
+
hashAggregateCost(card: number, numGroups?: number | null): number;
|
|
36
|
+
streamAggregateCost(card: number): number;
|
|
37
|
+
totalJoinCost(buildPlan: {
|
|
38
|
+
totalCost: number;
|
|
39
|
+
}, probePlan: {
|
|
40
|
+
totalCost: number;
|
|
41
|
+
}, buildCard: number, probeCard: number, outputCard: number): number;
|
|
42
|
+
cheaperJoinCost(leftCard: number, rightCard: number, leftSorted: boolean, rightSorted: boolean, outputCard: number, downstreamSortSaving?: number): {
|
|
43
|
+
hashCost: number;
|
|
44
|
+
mergeCost: number;
|
|
45
|
+
preferMerge: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type HyperGraph } from './hypergraph.js';
|
|
2
|
+
import { type BoundExpr } from '../../binder/expression-binder.js';
|
|
3
|
+
import type { LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
4
|
+
import type { DefaultCostModel } from './cost-model.js';
|
|
5
|
+
import type { DefaultCardinalityEstimator } from './cardinality.js';
|
|
6
|
+
export interface DPhypPlan {
|
|
7
|
+
type: 'HashJoin';
|
|
8
|
+
buildSide: LogicalPlanNode | DPhypPlan;
|
|
9
|
+
probeSide: LogicalPlanNode | DPhypPlan;
|
|
10
|
+
condition: BoundExpr | null;
|
|
11
|
+
buildCard: number;
|
|
12
|
+
probeCard: number;
|
|
13
|
+
}
|
|
14
|
+
export interface DPEntry {
|
|
15
|
+
plan: LogicalPlanNode | DPhypPlan;
|
|
16
|
+
cardinality: number;
|
|
17
|
+
totalCost: number;
|
|
18
|
+
mask: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class DPhypEnumerator {
|
|
21
|
+
graph: HyperGraph;
|
|
22
|
+
costModel: DefaultCostModel;
|
|
23
|
+
cardEstimator: DefaultCardinalityEstimator;
|
|
24
|
+
dp: Map<number, DPEntry>;
|
|
25
|
+
constructor(hyperGraph: HyperGraph, costModel: DefaultCostModel, cardinalityEstimator: DefaultCardinalityEstimator);
|
|
26
|
+
solve(): DPEntry | null;
|
|
27
|
+
enumerateSize(size: number): void;
|
|
28
|
+
enumerateCsgCmpPairs(combined: number): void;
|
|
29
|
+
emitPair(s1Mask: number, s2Mask: number, combinedMask: number, predicates: BoundExpr[]): void;
|
|
30
|
+
tryJoinOrder(build: DPEntry, probe: DPEntry, combinedMask: number, joinCondition: BoundExpr | null): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function runDPhyp(hyperGraph: HyperGraph, costModel: DefaultCostModel, cardinalityEstimator: DefaultCardinalityEstimator): DPEntry | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type BoundExpr } from '../../binder/expression-binder.js';
|
|
2
|
+
import type { LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import type { DefaultCardinalityEstimator } from './cardinality.js';
|
|
4
|
+
export interface Relation {
|
|
5
|
+
name: string;
|
|
6
|
+
alias?: string;
|
|
7
|
+
plan: LogicalPlanNode;
|
|
8
|
+
}
|
|
9
|
+
export interface RelationEntry {
|
|
10
|
+
id: number;
|
|
11
|
+
name: string;
|
|
12
|
+
plan: LogicalPlanNode;
|
|
13
|
+
cardinality: number;
|
|
14
|
+
mask: number;
|
|
15
|
+
}
|
|
16
|
+
export declare class HyperEdge {
|
|
17
|
+
leftMask: number;
|
|
18
|
+
rightMask: number;
|
|
19
|
+
predicate: BoundExpr;
|
|
20
|
+
constructor(leftMask: number, rightMask: number, predicate: BoundExpr);
|
|
21
|
+
}
|
|
22
|
+
export declare class HyperGraph {
|
|
23
|
+
relations: RelationEntry[];
|
|
24
|
+
relationIndex: Map<string, number>;
|
|
25
|
+
edges: HyperEdge[];
|
|
26
|
+
adjacency: number[];
|
|
27
|
+
constructor();
|
|
28
|
+
addRelation(name: string, plan: LogicalPlanNode, cardinality: number): number;
|
|
29
|
+
addEdge(leftNames: string[], rightNames: string[], predicate: BoundExpr): void;
|
|
30
|
+
getNeighborhood(subset: number): number;
|
|
31
|
+
isConnected(subset: number): boolean;
|
|
32
|
+
findJoinPredicates(leftMask: number, rightMask: number): BoundExpr[];
|
|
33
|
+
get size(): number;
|
|
34
|
+
get fullMask(): number;
|
|
35
|
+
}
|
|
36
|
+
export declare function buildHyperGraph(relations: Relation[], joinPredicates: BoundExpr[], cardinalityEstimator: DefaultCardinalityEstimator): HyperGraph;
|
|
37
|
+
export declare function popcount(mask: number): number;
|
|
38
|
+
export declare function subsets(mask: number): number[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LogicalPlanNode } from '../planner/logical-plan.js';
|
|
2
|
+
import type { OptimizationPass } from './pass.js';
|
|
3
|
+
export declare class Optimizer {
|
|
4
|
+
passes: OptimizationPass[];
|
|
5
|
+
constructor();
|
|
6
|
+
registerPass(pass: OptimizationPass): this;
|
|
7
|
+
removePass(name: string): this;
|
|
8
|
+
insertPassBefore(name: string, pass: OptimizationPass): this;
|
|
9
|
+
insertPassAfter(name: string, pass: OptimizationPass): this;
|
|
10
|
+
optimize(plan: LogicalPlanNode, context?: Record<string, never>): LogicalPlanNode;
|
|
11
|
+
listPasses(): string[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type BoundExpr } from '../../binder/expression-binder.js';
|
|
2
|
+
export type ExprLike = BoundExpr & {
|
|
3
|
+
left?: BoundExpr;
|
|
4
|
+
right?: BoundExpr;
|
|
5
|
+
operand?: BoundExpr;
|
|
6
|
+
expr?: BoundExpr;
|
|
7
|
+
low?: BoundExpr;
|
|
8
|
+
high?: BoundExpr;
|
|
9
|
+
args?: BoundExpr[];
|
|
10
|
+
whenClauses?: Array<{
|
|
11
|
+
condition: BoundExpr;
|
|
12
|
+
result: BoundExpr;
|
|
13
|
+
}>;
|
|
14
|
+
elseExpr?: BoundExpr;
|
|
15
|
+
list?: BoundExpr | BoundExpr[];
|
|
16
|
+
pattern?: BoundExpr;
|
|
17
|
+
source?: BoundExpr;
|
|
18
|
+
};
|
|
19
|
+
export declare function walkExpr(expr: BoundExpr | null | undefined, fn: (e: BoundExpr) => void): void;
|
|
20
|
+
export declare function containsAggregate(expr?: BoundExpr): boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { OptimizationPass } from '../pass.js';
|
|
2
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import { type BoundExpr } from '../../binder/expression-binder.js';
|
|
4
|
+
export declare class ExpressionSimplifier extends OptimizationPass {
|
|
5
|
+
get name(): string;
|
|
6
|
+
apply(plan: LogicalPlanNode): LogicalPlanNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function simplifyExpression(expr: BoundExpr | null): BoundExpr | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OptimizationPass } from '../pass.js';
|
|
2
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import { DefaultCardinalityEstimator } from '../dphyp/cardinality.js';
|
|
4
|
+
interface TableStatistics {
|
|
5
|
+
rowCount: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class FilterOrdering extends OptimizationPass {
|
|
8
|
+
cardEstimator: DefaultCardinalityEstimator;
|
|
9
|
+
constructor(statisticsMap?: Map<string, TableStatistics>);
|
|
10
|
+
get name(): string;
|
|
11
|
+
apply(plan: LogicalPlanNode): LogicalPlanNode;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { OptimizationPass } from '../pass.js';
|
|
2
|
+
import { type LogicalPlanNode, type IndexScanValue } from '../../planner/logical-plan.js';
|
|
3
|
+
interface ColumnStatsLike {
|
|
4
|
+
ndv: number;
|
|
5
|
+
min: IndexScanValue;
|
|
6
|
+
max: IndexScanValue;
|
|
7
|
+
}
|
|
8
|
+
interface TableStatsLike {
|
|
9
|
+
getColumnStats(column: string): ColumnStatsLike | null;
|
|
10
|
+
}
|
|
11
|
+
interface StatisticsLike {
|
|
12
|
+
get(name: string): TableStatsLike | undefined;
|
|
13
|
+
}
|
|
14
|
+
interface CatalogLike {
|
|
15
|
+
getIndexForColumn(table: string, column: string): object | null;
|
|
16
|
+
}
|
|
17
|
+
export declare class IndexSelection extends OptimizationPass {
|
|
18
|
+
catalog: CatalogLike;
|
|
19
|
+
statistics: StatisticsLike | null;
|
|
20
|
+
constructor(catalog: CatalogLike, statistics: StatisticsLike | null);
|
|
21
|
+
get name(): string;
|
|
22
|
+
apply(plan: LogicalPlanNode): LogicalPlanNode;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OptimizationPass } from '../pass.js';
|
|
2
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import { DefaultCostModel } from '../dphyp/cost-model.js';
|
|
4
|
+
import { DefaultCardinalityEstimator, type TableStats } from '../dphyp/cardinality.js';
|
|
5
|
+
export declare class JoinReorder extends OptimizationPass {
|
|
6
|
+
statisticsMap: Map<string, TableStats>;
|
|
7
|
+
costModel: DefaultCostModel;
|
|
8
|
+
cardEstimator: DefaultCardinalityEstimator;
|
|
9
|
+
constructor(statisticsMap?: Map<string, TableStats>, costModel?: DefaultCostModel | null, cardEstimator?: DefaultCardinalityEstimator | null);
|
|
10
|
+
get name(): string;
|
|
11
|
+
apply(plan: LogicalPlanNode): LogicalPlanNode;
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { OptimizationPass } from '../pass.js';
|
|
2
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import { DefaultCostModel } from '../dphyp/cost-model.js';
|
|
4
|
+
import { DefaultCardinalityEstimator, type TableStats } from '../dphyp/cardinality.js';
|
|
5
|
+
export declare class PhysicalDesign extends OptimizationPass {
|
|
6
|
+
statisticsMap: Map<string, TableStats>;
|
|
7
|
+
costModel: DefaultCostModel;
|
|
8
|
+
cardEstimator: DefaultCardinalityEstimator;
|
|
9
|
+
constructor(statisticsMap?: Map<string, TableStats>, costModel?: DefaultCostModel | null, cardEstimator?: DefaultCardinalityEstimator | null);
|
|
10
|
+
get name(): string;
|
|
11
|
+
apply(plan: LogicalPlanNode): LogicalPlanNode;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
2
|
+
export interface PlanRefs {
|
|
3
|
+
aliases: Set<string>;
|
|
4
|
+
columns: Set<string>;
|
|
5
|
+
}
|
|
6
|
+
export interface ExprRef {
|
|
7
|
+
tableAlias: string;
|
|
8
|
+
columnName: string;
|
|
9
|
+
}
|
|
10
|
+
export interface NamedExpr {
|
|
11
|
+
outputName?: string;
|
|
12
|
+
alias?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
columnName?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface CollectPlanRefsOptions {
|
|
17
|
+
recurseProject?: boolean;
|
|
18
|
+
dottedAlias?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare function addOutputRefs(node: LogicalPlanNode, refs: PlanRefs, options?: CollectPlanRefsOptions): void;
|
|
21
|
+
export declare function collectPlanRefs(node: LogicalPlanNode, options?: CollectPlanRefsOptions): PlanRefs;
|
|
22
|
+
export declare function refBelongsToPlan(ref: ExprRef, planRefs: PlanRefs, options?: CollectPlanRefsOptions): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OptimizationPass } from '../pass.js';
|
|
2
|
+
import { type LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import { type BoundExpr } from '../../binder/expression-binder.js';
|
|
4
|
+
export declare class PredicatePushdown extends OptimizationPass {
|
|
5
|
+
get name(): string;
|
|
6
|
+
apply(plan: LogicalPlanNode): LogicalPlanNode;
|
|
7
|
+
}
|
|
8
|
+
export declare function splitConjuncts(expr: BoundExpr | null): BoundExpr[];
|
|
9
|
+
export declare function combineConjuncts(preds: BoundExpr[]): BoundExpr | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DataChunk } from '../storage/chunk.js';
|
|
2
|
+
import { type Allocator } from '../storage/sab-arena.js';
|
|
3
|
+
import type { EncodedChunkSet } from './worker-messages.js';
|
|
4
|
+
export declare function shareChunk(chunk: DataChunk, columnIndexes: number[], arena: Allocator, forceCopy?: boolean): DataChunk;
|
|
5
|
+
interface DictBlob {
|
|
6
|
+
lengths: Uint32Array;
|
|
7
|
+
count: number;
|
|
8
|
+
blob: Uint8Array;
|
|
9
|
+
totalBytes: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function encodeChunkSet(chunks: DataChunk[], columnIndexes: number[], arena: Allocator, dictCache?: Map<string[], DictBlob>): EncodedChunkSet;
|
|
12
|
+
export declare function transportBytes(chunkSet: EncodedChunkSet): number;
|
|
13
|
+
export declare class ChunkSetReader {
|
|
14
|
+
buffers: ArrayBufferLike[];
|
|
15
|
+
meta: Uint32Array;
|
|
16
|
+
sizes: Uint32Array;
|
|
17
|
+
colCount: number;
|
|
18
|
+
cache: Map<number, DataChunk>;
|
|
19
|
+
constructor({ buffers, meta, sizes, colCount }: EncodedChunkSet);
|
|
20
|
+
get count(): number;
|
|
21
|
+
chunk(index: number): DataChunk;
|
|
22
|
+
_decode(index: number): DataChunk;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Worker } from 'worker_threads';
|
|
2
|
+
import type { DataChunk } from '../storage/chunk.js';
|
|
3
|
+
import type { FragmentSpec, JoinSpec } from '../execution/fragment-spec.js';
|
|
4
|
+
import type { PartialGroupRecord, JoinOutputTypes, FragmentAggregateRequest, FragmentCombineRequest, FragmentJoinPartitionRequest, FragmentJoinProbeRequest, FragmentReplyMessage, FragmentSuccessMessage } from './worker-messages.js';
|
|
5
|
+
interface WorkerEntry {
|
|
6
|
+
worker: Worker;
|
|
7
|
+
slot: number;
|
|
8
|
+
}
|
|
9
|
+
interface PendingRequest {
|
|
10
|
+
expected: number;
|
|
11
|
+
replies: FragmentSuccessMessage[];
|
|
12
|
+
resolve: (replies: FragmentSuccessMessage[]) => void;
|
|
13
|
+
reject: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
interface RunAggregateOptions {
|
|
16
|
+
byteLimit?: number;
|
|
17
|
+
spillDir?: string | null;
|
|
18
|
+
}
|
|
19
|
+
interface JoinStreamSide {
|
|
20
|
+
chunks: DataChunk[];
|
|
21
|
+
columnIndexes: number[] | null;
|
|
22
|
+
}
|
|
23
|
+
interface PoolStats {
|
|
24
|
+
spillFiles: number;
|
|
25
|
+
}
|
|
26
|
+
export declare class FragmentPool {
|
|
27
|
+
workerCount: number;
|
|
28
|
+
morselRows: number;
|
|
29
|
+
workers: WorkerEntry[];
|
|
30
|
+
pending: Map<number, PendingRequest>;
|
|
31
|
+
nextReqId: number;
|
|
32
|
+
closed: boolean;
|
|
33
|
+
spillSeq?: number;
|
|
34
|
+
stats?: PoolStats;
|
|
35
|
+
constructor(workerCount?: number, morselRows?: number);
|
|
36
|
+
_ensure(): void;
|
|
37
|
+
_spawn(slot: number): WorkerEntry;
|
|
38
|
+
_updateRefs(): void;
|
|
39
|
+
_settle(reqId: number, settle: () => void): void;
|
|
40
|
+
_onMessage(msg: FragmentReplyMessage): void;
|
|
41
|
+
_failAll(err: Error): void;
|
|
42
|
+
_request(entry: WorkerEntry, payload: FragmentCombineRequest | FragmentJoinProbeRequest): Promise<FragmentSuccessMessage>;
|
|
43
|
+
_broadcast(payload: FragmentAggregateRequest | FragmentJoinPartitionRequest): Promise<FragmentSuccessMessage[]>;
|
|
44
|
+
runAggregate(spec: FragmentSpec, columnIndexes: number[], chunks: DataChunk[], options?: RunAggregateOptions): Promise<DataChunk[]>;
|
|
45
|
+
_combineAndFinalize(spec: FragmentSpec, perWorkerPartitions: PartialGroupRecord[][][], spillFiles: string[], partitionCount: number): Promise<DataChunk[]>;
|
|
46
|
+
runJoinStream(spec: JoinSpec, buildSide: JoinStreamSide, probeSide: JoinStreamSide, outputTypes: JoinOutputTypes): AsyncGenerator<DataChunk>;
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MorselSchedulerDescriptor, MorselRange } from './worker-messages.js';
|
|
2
|
+
export declare class MorselScheduler {
|
|
3
|
+
totalUnits: number;
|
|
4
|
+
unitsPerMorsel: number;
|
|
5
|
+
counter: Int32Array;
|
|
6
|
+
constructor(totalUnits: number, unitsPerMorsel: number);
|
|
7
|
+
static attach({ counterBuffer, totalUnits, unitsPerMorsel }: MorselSchedulerDescriptor): MorselScheduler;
|
|
8
|
+
descriptor(): MorselSchedulerDescriptor;
|
|
9
|
+
next(): MorselRange | null;
|
|
10
|
+
drain(): Generator<MorselRange>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { AnyTypedArray, ColumnValue, DataType } from '../storage/data-type.js';
|
|
2
|
+
import type { WasmVecData } from '../wasm/wasm-types.js';
|
|
3
|
+
import type { CompoundCombineOp, FilterDescriptor, PipelineStage, WorkerTask, SelectionVectorResult, ScalarAggregateResult, ProjectResult, ScalarAggregatePartial } from './worker-messages.js';
|
|
4
|
+
type WasmKernel = (data: WasmVecData | number, arg1?: WasmVecData | number, arg2?: WasmVecData | number) => Promise<Uint32Array | number> | WasmVecData | Promise<WasmVecData>;
|
|
5
|
+
interface RegionAllocatorLike {
|
|
6
|
+
memory: WebAssembly.Memory;
|
|
7
|
+
resetStaging(): void;
|
|
8
|
+
allocStaging(bytes: number): number;
|
|
9
|
+
}
|
|
10
|
+
interface GlobalDispatchLike {
|
|
11
|
+
lookup(operation: string, dataType: string): WasmKernel | null;
|
|
12
|
+
}
|
|
13
|
+
interface WorkerPoolLike {
|
|
14
|
+
activeWorkerCount(): number;
|
|
15
|
+
execute<R>(tasks: WorkerTask[]): Promise<R[]>;
|
|
16
|
+
}
|
|
17
|
+
interface FilterParams {
|
|
18
|
+
value?: ColumnValue;
|
|
19
|
+
low?: ColumnValue;
|
|
20
|
+
high?: ColumnValue;
|
|
21
|
+
}
|
|
22
|
+
interface ProjectParams {
|
|
23
|
+
scalar?: number;
|
|
24
|
+
dataB?: AnyTypedArray;
|
|
25
|
+
}
|
|
26
|
+
interface Morsel {
|
|
27
|
+
start: number;
|
|
28
|
+
length: number;
|
|
29
|
+
}
|
|
30
|
+
interface PipelineAggregatesPartialResult {
|
|
31
|
+
aggregates?: ScalarAggregatePartial[];
|
|
32
|
+
}
|
|
33
|
+
interface MergedPipelineAggregates {
|
|
34
|
+
aggregates: Record<string, ScalarAggregateResult | null>;
|
|
35
|
+
}
|
|
36
|
+
interface FilterFallbackParams {
|
|
37
|
+
value?: ColumnValue;
|
|
38
|
+
low?: ColumnValue;
|
|
39
|
+
high?: ColumnValue;
|
|
40
|
+
}
|
|
41
|
+
export declare class ParallelDispatch {
|
|
42
|
+
workerPool: WorkerPoolLike | null;
|
|
43
|
+
regionAllocator: RegionAllocatorLike;
|
|
44
|
+
globalDispatch: GlobalDispatchLike;
|
|
45
|
+
constructor(workerPool: WorkerPoolLike | null, regionAllocator: RegionAllocatorLike, globalDispatch: GlobalDispatchLike);
|
|
46
|
+
canParallelize(operation: string, dataType: string, count: number): boolean;
|
|
47
|
+
filterParallel(data: AnyTypedArray, count: number, operation: string, dataType: DataType, params: FilterParams): Promise<SelectionVectorResult | null>;
|
|
48
|
+
aggregateParallel(data: AnyTypedArray, count: number, aggType: string, dataType: DataType): Promise<ScalarAggregateResult | null>;
|
|
49
|
+
compoundFilterParallel(data: AnyTypedArray, count: number, filters: FilterDescriptor[], combineOp: CompoundCombineOp, dataType: DataType): Promise<SelectionVectorResult | null>;
|
|
50
|
+
pipelineParallel(data: AnyTypedArray, count: number, dataType: DataType, stages: PipelineStage[]): Promise<SelectionVectorResult | MergedPipelineAggregates>;
|
|
51
|
+
projectParallel(data: AnyTypedArray, count: number, op: string, params?: ProjectParams): Promise<Float64Array | null>;
|
|
52
|
+
_gatherProjectResults(results: ProjectResult[], totalCount: number): Float64Array;
|
|
53
|
+
_resolveDataPtr(data: AnyTypedArray, count: number, bw: number): number;
|
|
54
|
+
_splitRange(totalCount: number, workerCount: number): Morsel[];
|
|
55
|
+
_gatherSelectionVectors(results: SelectionVectorResult[], totalCount: number): SelectionVectorResult;
|
|
56
|
+
_mergeAggregates(results: ScalarAggregateResult[], aggType: string): ScalarAggregateResult | null;
|
|
57
|
+
_mergePipelineAggregates(results: PipelineAggregatesPartialResult[]): MergedPipelineAggregates;
|
|
58
|
+
_compoundFilterFallback(data: AnyTypedArray, count: number, filters: FilterDescriptor[], combineOp: CompoundCombineOp, dataType: DataType): Promise<SelectionVectorResult>;
|
|
59
|
+
_pipelineFallback(data: AnyTypedArray, count: number, dataType: DataType, stages: PipelineStage[]): Promise<SelectionVectorResult | MergedPipelineAggregates>;
|
|
60
|
+
_gatherByIndices(data: AnyTypedArray, indices: Uint32Array, dataType: DataType): Float64Array | Int32Array;
|
|
61
|
+
_intersectSorted(a: Uint32Array, b: Uint32Array): Uint32Array;
|
|
62
|
+
_unionSorted(a: Uint32Array, b: Uint32Array): Uint32Array;
|
|
63
|
+
_filterFallback(operation: string, dataType: DataType, data: AnyTypedArray, params: FilterFallbackParams): Promise<{
|
|
64
|
+
selectionVector: Uint32Array;
|
|
65
|
+
matchCount: number;
|
|
66
|
+
} | null>;
|
|
67
|
+
_aggregateFallback(aggType: string, dataType: DataType, data: AnyTypedArray): Promise<ScalarAggregateResult | null>;
|
|
68
|
+
}
|
|
69
|
+
export {};
|