@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,135 @@
|
|
|
1
|
+
export declare enum TokenType {
|
|
2
|
+
IDENT = "IDENT",
|
|
3
|
+
NUMBER = "NUMBER",
|
|
4
|
+
STRING = "STRING",
|
|
5
|
+
COMMA = "COMMA",
|
|
6
|
+
DOT = "DOT",
|
|
7
|
+
STAR = "STAR",
|
|
8
|
+
LPAREN = "LPAREN",
|
|
9
|
+
RPAREN = "RPAREN",
|
|
10
|
+
EQ = "EQ",
|
|
11
|
+
NEQ = "NEQ",
|
|
12
|
+
LT = "LT",
|
|
13
|
+
GT = "GT",
|
|
14
|
+
LTE = "LTE",
|
|
15
|
+
GTE = "GTE",
|
|
16
|
+
PLUS = "PLUS",
|
|
17
|
+
MINUS = "MINUS",
|
|
18
|
+
SLASH = "SLASH",
|
|
19
|
+
PERCENT = "PERCENT",
|
|
20
|
+
SEMICOLON = "SEMICOLON",
|
|
21
|
+
CONCAT = "CONCAT",
|
|
22
|
+
COLON = "COLON",
|
|
23
|
+
EOF = "EOF",
|
|
24
|
+
EXPLAIN = "EXPLAIN",
|
|
25
|
+
SELECT = "SELECT",
|
|
26
|
+
FROM = "FROM",
|
|
27
|
+
WHERE = "WHERE",
|
|
28
|
+
AND = "AND",
|
|
29
|
+
OR = "OR",
|
|
30
|
+
NOT = "NOT",
|
|
31
|
+
AS = "AS",
|
|
32
|
+
ON = "ON",
|
|
33
|
+
JOIN = "JOIN",
|
|
34
|
+
INNER = "INNER",
|
|
35
|
+
LEFT = "LEFT",
|
|
36
|
+
RIGHT = "RIGHT",
|
|
37
|
+
FULL = "FULL",
|
|
38
|
+
OUTER = "OUTER",
|
|
39
|
+
CROSS = "CROSS",
|
|
40
|
+
IN = "IN",
|
|
41
|
+
EXISTS = "EXISTS",
|
|
42
|
+
BETWEEN = "BETWEEN",
|
|
43
|
+
LIKE = "LIKE",
|
|
44
|
+
IS = "IS",
|
|
45
|
+
NULL = "NULL",
|
|
46
|
+
TRUE = "TRUE",
|
|
47
|
+
FALSE = "FALSE",
|
|
48
|
+
CASE = "CASE",
|
|
49
|
+
WHEN = "WHEN",
|
|
50
|
+
THEN = "THEN",
|
|
51
|
+
ELSE = "ELSE",
|
|
52
|
+
END = "END",
|
|
53
|
+
DISTINCT = "DISTINCT",
|
|
54
|
+
ALL = "ALL",
|
|
55
|
+
GROUP = "GROUP",
|
|
56
|
+
BY = "BY",
|
|
57
|
+
HAVING = "HAVING",
|
|
58
|
+
ORDER = "ORDER",
|
|
59
|
+
ASC = "ASC",
|
|
60
|
+
DESC = "DESC",
|
|
61
|
+
LIMIT = "LIMIT",
|
|
62
|
+
OFFSET = "OFFSET",
|
|
63
|
+
UNION = "UNION",
|
|
64
|
+
EXCEPT = "EXCEPT",
|
|
65
|
+
INTERSECT = "INTERSECT",
|
|
66
|
+
WITH = "WITH",
|
|
67
|
+
CAST = "CAST",
|
|
68
|
+
INTERVAL = "INTERVAL",
|
|
69
|
+
EXTRACT = "EXTRACT",
|
|
70
|
+
SUBSTRING = "SUBSTRING",
|
|
71
|
+
TRIM = "TRIM",
|
|
72
|
+
YEAR = "YEAR",
|
|
73
|
+
MONTH = "MONTH",
|
|
74
|
+
DAY = "DAY",
|
|
75
|
+
DATE = "DATE",
|
|
76
|
+
SUM = "SUM",
|
|
77
|
+
AVG = "AVG",
|
|
78
|
+
COUNT = "COUNT",
|
|
79
|
+
MIN = "MIN",
|
|
80
|
+
MAX = "MAX",
|
|
81
|
+
CREATE = "CREATE",
|
|
82
|
+
VIEW = "VIEW",
|
|
83
|
+
NULLS = "NULLS",
|
|
84
|
+
FIRST = "FIRST",
|
|
85
|
+
LAST = "LAST",
|
|
86
|
+
FETCH = "FETCH",
|
|
87
|
+
NEXT = "NEXT",
|
|
88
|
+
ROWS = "ROWS",
|
|
89
|
+
ONLY = "ONLY",
|
|
90
|
+
SOME = "SOME",
|
|
91
|
+
ANY = "ANY",
|
|
92
|
+
LEADING = "LEADING",
|
|
93
|
+
TRAILING = "TRAILING",
|
|
94
|
+
BOTH = "BOTH",
|
|
95
|
+
FOR = "FOR",
|
|
96
|
+
TIMESTAMP = "TIMESTAMP",
|
|
97
|
+
HOUR = "HOUR",
|
|
98
|
+
MINUTE = "MINUTE",
|
|
99
|
+
SECOND = "SECOND",
|
|
100
|
+
OVER = "OVER",
|
|
101
|
+
PARTITION = "PARTITION",
|
|
102
|
+
RANGE = "RANGE",
|
|
103
|
+
UNBOUNDED = "UNBOUNDED",
|
|
104
|
+
PRECEDING = "PRECEDING",
|
|
105
|
+
FOLLOWING = "FOLLOWING",
|
|
106
|
+
CURRENT = "CURRENT",
|
|
107
|
+
ROW = "ROW",
|
|
108
|
+
NATURAL = "NATURAL",
|
|
109
|
+
USING = "USING",
|
|
110
|
+
TABLE = "TABLE",
|
|
111
|
+
DROP = "DROP",
|
|
112
|
+
IF = "IF",
|
|
113
|
+
ANALYZE = "ANALYZE"
|
|
114
|
+
}
|
|
115
|
+
export declare class Token {
|
|
116
|
+
type: TokenType;
|
|
117
|
+
value: string;
|
|
118
|
+
position: number;
|
|
119
|
+
constructor(type: TokenType, value: string, position: number);
|
|
120
|
+
}
|
|
121
|
+
export declare class Lexer {
|
|
122
|
+
input: string;
|
|
123
|
+
pos: number;
|
|
124
|
+
tokens: Token[];
|
|
125
|
+
constructor(input: string);
|
|
126
|
+
_tokenize(): void;
|
|
127
|
+
_skipWhitespaceAndComments(): void;
|
|
128
|
+
_readString(start: number): Token;
|
|
129
|
+
_readNumber(start: number): Token;
|
|
130
|
+
_readIdentOrKeyword(start: number): Token;
|
|
131
|
+
_readSymbol(start: number): Token;
|
|
132
|
+
_isDigit(ch: string): boolean;
|
|
133
|
+
_isIdentStart(ch: string): boolean;
|
|
134
|
+
_isIdentPart(ch: string): boolean;
|
|
135
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Token, TokenType } from './lexer.js';
|
|
2
|
+
import * as AST from './ast.js';
|
|
3
|
+
export declare class Parser {
|
|
4
|
+
tokens: Token[];
|
|
5
|
+
pos: number;
|
|
6
|
+
constructor(sql: string);
|
|
7
|
+
parse(): AST.Statement;
|
|
8
|
+
parseStatement(): AST.Statement;
|
|
9
|
+
parseCreateTable(): AST.CreateTableStmtNode;
|
|
10
|
+
parseDropTable(): AST.DropTableStmtNode;
|
|
11
|
+
parseQueryExpr(): AST.QueryStmt;
|
|
12
|
+
parseSelectStmt(): AST.QueryStmt;
|
|
13
|
+
parseWithClause(): AST.WithClauseNode;
|
|
14
|
+
parseCTE(): AST.CTENode;
|
|
15
|
+
parseSelectItems(): AST.SelectItemNode[];
|
|
16
|
+
parseOptionalAlias(guard?: () => boolean): string | null;
|
|
17
|
+
parseSelectItem(): AST.SelectItemNode;
|
|
18
|
+
parseFromClause(): AST.FromItem;
|
|
19
|
+
parseTableRef(): AST.FromItem;
|
|
20
|
+
parseSubqueryRef(): AST.SubqueryRefNode;
|
|
21
|
+
parseJoin(left: AST.FromItem): AST.JoinRefNode;
|
|
22
|
+
parseExpression(): AST.Expr;
|
|
23
|
+
parseOr(): AST.Expr;
|
|
24
|
+
parseAnd(): AST.Expr;
|
|
25
|
+
parseNot(): AST.Expr;
|
|
26
|
+
parseComparison(): AST.Expr;
|
|
27
|
+
parseBetween(left: AST.Expr, negated: boolean): AST.BetweenExprNode;
|
|
28
|
+
parseIn(left: AST.Expr, negated: boolean): AST.InExprNode;
|
|
29
|
+
parseLike(left: AST.Expr, negated: boolean): AST.LikeExprNode;
|
|
30
|
+
parseExists(): AST.ExistsExprNode;
|
|
31
|
+
parseAddition(): AST.Expr;
|
|
32
|
+
parseMultiplication(): AST.Expr;
|
|
33
|
+
parseUnary(): AST.Expr;
|
|
34
|
+
parsePrimary(): AST.Expr;
|
|
35
|
+
parseAggregateCall(): AST.AggregateCallNode | AST.WindowCallNode;
|
|
36
|
+
parseFunctionCallNamed(name: string): AST.FunctionCallNode | AST.WindowCallNode;
|
|
37
|
+
parseWindowCall(name: string, args: AST.Expr[]): AST.WindowCallNode;
|
|
38
|
+
parseCaseExpr(): AST.CaseExprNode;
|
|
39
|
+
parseCast(): AST.CastExprNode;
|
|
40
|
+
parseExtract(): AST.ExtractExprNode;
|
|
41
|
+
parseSubstringFn(): AST.SubstringExprNode;
|
|
42
|
+
parseTrim(): AST.FunctionCallNode;
|
|
43
|
+
parseInterval(): AST.IntervalExprNode;
|
|
44
|
+
parseTypeName(): AST.TypeNameNode;
|
|
45
|
+
parseExpressionList(): AST.Expr[];
|
|
46
|
+
parseOrderByList(): AST.OrderKeyNode[];
|
|
47
|
+
peek(): Token;
|
|
48
|
+
peekAhead(offset: number): Token | null;
|
|
49
|
+
advance(): Token;
|
|
50
|
+
isAt(type: TokenType): boolean;
|
|
51
|
+
tryConsume(type: TokenType): boolean;
|
|
52
|
+
expect(type: TokenType): Token;
|
|
53
|
+
expectIdent(): string;
|
|
54
|
+
isNonReservedKeyword(type: TokenType): boolean;
|
|
55
|
+
isAggregateKeyword(type: TokenType): boolean;
|
|
56
|
+
isJoinKeyword(): boolean;
|
|
57
|
+
isClauseKeyword(): boolean;
|
|
58
|
+
isSubqueryStart(): boolean;
|
|
59
|
+
isLookaheadSelect(): boolean;
|
|
60
|
+
isAtKeyword(keyword: string): boolean;
|
|
61
|
+
error(message: string): never;
|
|
62
|
+
}
|
|
63
|
+
export declare function parse(sql: string): AST.Statement;
|
|
64
|
+
export declare function parseExpression(sql: string): AST.Expr;
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import type { BoundExpr, BoundColumnRefNode } from '../binder/expression-binder.js';
|
|
2
|
+
import type { ColumnInfo } from '../binder/scope.js';
|
|
3
|
+
export type IndexScanValue = string | number | bigint | null;
|
|
4
|
+
export type ProjectedExpr = BoundExpr & {
|
|
5
|
+
outputName?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare enum PlanNodeType {
|
|
8
|
+
SCAN = "Scan",
|
|
9
|
+
FILTER = "Filter",
|
|
10
|
+
PROJECT = "Project",
|
|
11
|
+
JOIN = "Join",
|
|
12
|
+
AGGREGATE = "Aggregate",
|
|
13
|
+
SORT = "Sort",
|
|
14
|
+
LIMIT = "Limit",
|
|
15
|
+
DISTINCT = "Distinct",
|
|
16
|
+
UNION = "Union",
|
|
17
|
+
CTE_SCAN = "CTEScan",
|
|
18
|
+
CTE_ANCHOR = "CTEAnchor",
|
|
19
|
+
DEPENDENT_JOIN = "DependentJoin",
|
|
20
|
+
MATERIALIZE = "Materialize",
|
|
21
|
+
EMPTY = "Empty",
|
|
22
|
+
TOP_N = "TopN",
|
|
23
|
+
INDEX_SCAN = "IndexScan",
|
|
24
|
+
WINDOW = "Window",
|
|
25
|
+
EXCHANGE = "Exchange",
|
|
26
|
+
PARTIAL_AGGREGATE = "PartialAggregate",
|
|
27
|
+
FINAL_AGGREGATE = "FinalAggregate",
|
|
28
|
+
MERGE_EXCHANGE = "MergeExchange",
|
|
29
|
+
EXCHANGE_RECEIVE = "ExchangeReceive",
|
|
30
|
+
SINGLE_ROW = "SingleRow"
|
|
31
|
+
}
|
|
32
|
+
export declare enum JoinType {
|
|
33
|
+
INNER = "INNER",
|
|
34
|
+
LEFT = "LEFT",
|
|
35
|
+
RIGHT = "RIGHT",
|
|
36
|
+
FULL = "FULL",
|
|
37
|
+
SEMI = "SEMI",
|
|
38
|
+
ANTI = "ANTI",
|
|
39
|
+
MARK = "MARK",
|
|
40
|
+
SINGLE = "SINGLE",
|
|
41
|
+
CROSS = "CROSS"
|
|
42
|
+
}
|
|
43
|
+
export declare enum PhysicalStrategy {
|
|
44
|
+
HASH = "HASH",
|
|
45
|
+
MERGE = "MERGE",
|
|
46
|
+
NESTED_LOOP = "NESTED_LOOP",
|
|
47
|
+
STREAM = "STREAM",
|
|
48
|
+
UNGROUPED = "UNGROUPED",
|
|
49
|
+
PERFECT_HASH = "PERFECT_HASH"
|
|
50
|
+
}
|
|
51
|
+
export declare enum SortDirection {
|
|
52
|
+
ASC = "ASC",
|
|
53
|
+
DESC = "DESC"
|
|
54
|
+
}
|
|
55
|
+
export declare enum NullOrder {
|
|
56
|
+
FIRST = "FIRST",
|
|
57
|
+
LAST = "LAST"
|
|
58
|
+
}
|
|
59
|
+
export interface LogicalOrderKey {
|
|
60
|
+
expr: BoundExpr;
|
|
61
|
+
direction?: string;
|
|
62
|
+
nullOrder?: string | null;
|
|
63
|
+
}
|
|
64
|
+
export type SortedByEntry = string | {
|
|
65
|
+
key: string;
|
|
66
|
+
direction?: string;
|
|
67
|
+
};
|
|
68
|
+
interface PlanNodeBase {
|
|
69
|
+
children?: LogicalPlanNode[];
|
|
70
|
+
_cardinality?: number;
|
|
71
|
+
_sortedBy?: SortedByEntry[];
|
|
72
|
+
_cteMap?: Map<string, LogicalPlanNode>;
|
|
73
|
+
_requiresSort?: {
|
|
74
|
+
left: boolean;
|
|
75
|
+
right: boolean;
|
|
76
|
+
};
|
|
77
|
+
_buildSide?: 'left' | 'right';
|
|
78
|
+
_dedupeBuild?: boolean;
|
|
79
|
+
_cost?: number;
|
|
80
|
+
}
|
|
81
|
+
export interface LogicalScanNode extends PlanNodeBase {
|
|
82
|
+
type: PlanNodeType.SCAN;
|
|
83
|
+
table: string;
|
|
84
|
+
columns: ColumnInfo[];
|
|
85
|
+
alias: string;
|
|
86
|
+
}
|
|
87
|
+
export interface LogicalFilterNode extends PlanNodeBase {
|
|
88
|
+
type: PlanNodeType.FILTER;
|
|
89
|
+
condition: BoundExpr | null;
|
|
90
|
+
children: LogicalPlanNode[];
|
|
91
|
+
}
|
|
92
|
+
export interface LogicalProjectNode extends PlanNodeBase {
|
|
93
|
+
type: PlanNodeType.PROJECT;
|
|
94
|
+
expressions: ProjectedExpr[];
|
|
95
|
+
children: LogicalPlanNode[];
|
|
96
|
+
}
|
|
97
|
+
export interface LogicalJoinNode extends PlanNodeBase {
|
|
98
|
+
type: PlanNodeType.JOIN;
|
|
99
|
+
joinType: JoinType;
|
|
100
|
+
condition: BoundExpr | null;
|
|
101
|
+
physicalStrategy: PhysicalStrategy;
|
|
102
|
+
children: LogicalPlanNode[];
|
|
103
|
+
}
|
|
104
|
+
export interface LogicalAggregateNode extends PlanNodeBase {
|
|
105
|
+
type: PlanNodeType.AGGREGATE;
|
|
106
|
+
groupBy: BoundExpr[];
|
|
107
|
+
aggregates: BoundExpr[];
|
|
108
|
+
physicalStrategy: PhysicalStrategy;
|
|
109
|
+
children: LogicalPlanNode[];
|
|
110
|
+
}
|
|
111
|
+
export interface LogicalSortNode extends PlanNodeBase {
|
|
112
|
+
type: PlanNodeType.SORT;
|
|
113
|
+
orderKeys: LogicalOrderKey[];
|
|
114
|
+
limit?: number;
|
|
115
|
+
offset?: number;
|
|
116
|
+
children: LogicalPlanNode[];
|
|
117
|
+
}
|
|
118
|
+
export interface LogicalLimitNode extends PlanNodeBase {
|
|
119
|
+
type: PlanNodeType.LIMIT;
|
|
120
|
+
count: number;
|
|
121
|
+
offset: number;
|
|
122
|
+
children: LogicalPlanNode[];
|
|
123
|
+
}
|
|
124
|
+
export interface LogicalDistinctNode extends PlanNodeBase {
|
|
125
|
+
type: PlanNodeType.DISTINCT;
|
|
126
|
+
children: LogicalPlanNode[];
|
|
127
|
+
}
|
|
128
|
+
export interface LogicalUnionNode extends PlanNodeBase {
|
|
129
|
+
type: PlanNodeType.UNION;
|
|
130
|
+
all: boolean;
|
|
131
|
+
children: LogicalPlanNode[];
|
|
132
|
+
}
|
|
133
|
+
export interface LogicalCTEScanNode extends PlanNodeBase {
|
|
134
|
+
type: PlanNodeType.CTE_SCAN;
|
|
135
|
+
cteName: string;
|
|
136
|
+
cteId: number;
|
|
137
|
+
children: LogicalPlanNode[];
|
|
138
|
+
}
|
|
139
|
+
export interface LogicalCTEAnchorNode extends PlanNodeBase {
|
|
140
|
+
type: PlanNodeType.CTE_ANCHOR;
|
|
141
|
+
cteName: string;
|
|
142
|
+
cteId: number;
|
|
143
|
+
children: LogicalPlanNode[];
|
|
144
|
+
}
|
|
145
|
+
export interface LogicalDependentJoinNode extends PlanNodeBase {
|
|
146
|
+
type: PlanNodeType.DEPENDENT_JOIN;
|
|
147
|
+
correlatedColumns: BoundColumnRefNode[];
|
|
148
|
+
subqueryType: string;
|
|
149
|
+
condition: BoundExpr | null;
|
|
150
|
+
children: LogicalPlanNode[];
|
|
151
|
+
}
|
|
152
|
+
export interface LogicalTopNNode extends PlanNodeBase {
|
|
153
|
+
type: PlanNodeType.TOP_N;
|
|
154
|
+
orderKeys: LogicalOrderKey[];
|
|
155
|
+
count: number;
|
|
156
|
+
offset: number;
|
|
157
|
+
children: LogicalPlanNode[];
|
|
158
|
+
}
|
|
159
|
+
export interface LogicalIndexScanNode extends PlanNodeBase {
|
|
160
|
+
type: PlanNodeType.INDEX_SCAN;
|
|
161
|
+
table: string;
|
|
162
|
+
alias: string;
|
|
163
|
+
indexName: string;
|
|
164
|
+
columnName: string;
|
|
165
|
+
scanType: string;
|
|
166
|
+
scanKey: IndexScanValue;
|
|
167
|
+
scanLow: IndexScanValue;
|
|
168
|
+
scanHigh: IndexScanValue;
|
|
169
|
+
lowInc: boolean;
|
|
170
|
+
highInc: boolean;
|
|
171
|
+
columns: ColumnInfo[];
|
|
172
|
+
}
|
|
173
|
+
export interface LogicalWindowNode extends PlanNodeBase {
|
|
174
|
+
type: PlanNodeType.WINDOW;
|
|
175
|
+
windowExprs: BoundExpr[];
|
|
176
|
+
children: LogicalPlanNode[];
|
|
177
|
+
}
|
|
178
|
+
export interface LogicalMaterializeNode extends PlanNodeBase {
|
|
179
|
+
type: PlanNodeType.MATERIALIZE;
|
|
180
|
+
children: LogicalPlanNode[];
|
|
181
|
+
}
|
|
182
|
+
export interface LogicalExchangeNode extends PlanNodeBase {
|
|
183
|
+
type: PlanNodeType.EXCHANGE;
|
|
184
|
+
exchangeType: string;
|
|
185
|
+
partitionKeys: BoundExpr[];
|
|
186
|
+
partitionCount: number;
|
|
187
|
+
children: LogicalPlanNode[];
|
|
188
|
+
}
|
|
189
|
+
export interface LogicalPartialAggregateNode extends PlanNodeBase {
|
|
190
|
+
type: PlanNodeType.PARTIAL_AGGREGATE;
|
|
191
|
+
groupBy: BoundExpr[];
|
|
192
|
+
aggregates: BoundExpr[];
|
|
193
|
+
physicalStrategy: PhysicalStrategy;
|
|
194
|
+
children: LogicalPlanNode[];
|
|
195
|
+
}
|
|
196
|
+
export interface LogicalFinalAggregateNode extends PlanNodeBase {
|
|
197
|
+
type: PlanNodeType.FINAL_AGGREGATE;
|
|
198
|
+
groupBy: BoundExpr[];
|
|
199
|
+
aggregates: BoundExpr[];
|
|
200
|
+
partialAggregates: BoundExpr[];
|
|
201
|
+
physicalStrategy: PhysicalStrategy;
|
|
202
|
+
children: LogicalPlanNode[];
|
|
203
|
+
}
|
|
204
|
+
export interface LogicalMergeExchangeNode extends PlanNodeBase {
|
|
205
|
+
type: PlanNodeType.MERGE_EXCHANGE;
|
|
206
|
+
orderKeys: LogicalOrderKey[];
|
|
207
|
+
limit: number | null;
|
|
208
|
+
children: LogicalPlanNode[];
|
|
209
|
+
}
|
|
210
|
+
export interface LogicalExchangeReceiveNode extends PlanNodeBase {
|
|
211
|
+
type: PlanNodeType.EXCHANGE_RECEIVE;
|
|
212
|
+
sourceFragmentIds: number[];
|
|
213
|
+
schema: ColumnInfo[];
|
|
214
|
+
children: LogicalPlanNode[];
|
|
215
|
+
}
|
|
216
|
+
export interface LogicalSingleRowNode extends PlanNodeBase {
|
|
217
|
+
type: PlanNodeType.SINGLE_ROW;
|
|
218
|
+
children: LogicalPlanNode[];
|
|
219
|
+
}
|
|
220
|
+
export interface LogicalEmptyNode extends PlanNodeBase {
|
|
221
|
+
type: PlanNodeType.EMPTY;
|
|
222
|
+
children?: LogicalPlanNode[];
|
|
223
|
+
}
|
|
224
|
+
export type LogicalPlanNode = LogicalScanNode | LogicalFilterNode | LogicalProjectNode | LogicalJoinNode | LogicalAggregateNode | LogicalSortNode | LogicalLimitNode | LogicalDistinctNode | LogicalUnionNode | LogicalCTEScanNode | LogicalCTEAnchorNode | LogicalDependentJoinNode | LogicalTopNNode | LogicalIndexScanNode | LogicalWindowNode | LogicalMaterializeNode | LogicalExchangeNode | LogicalPartialAggregateNode | LogicalFinalAggregateNode | LogicalMergeExchangeNode | LogicalExchangeReceiveNode | LogicalSingleRowNode | LogicalEmptyNode;
|
|
225
|
+
export declare function LogicalScan(table: string, columns: ColumnInfo[], alias?: string): LogicalScanNode;
|
|
226
|
+
export declare function LogicalFilter(condition: BoundExpr | null, child: LogicalPlanNode): LogicalFilterNode;
|
|
227
|
+
export declare function LogicalProject(expressions: ProjectedExpr[], child: LogicalPlanNode): LogicalProjectNode;
|
|
228
|
+
export declare function LogicalJoin(joinType: JoinType, condition: BoundExpr | null, left: LogicalPlanNode, right: LogicalPlanNode, physicalStrategy?: PhysicalStrategy): LogicalJoinNode;
|
|
229
|
+
export declare function LogicalAggregate(groupBy: BoundExpr[], aggregates: BoundExpr[], child: LogicalPlanNode, physicalStrategy?: PhysicalStrategy): LogicalAggregateNode;
|
|
230
|
+
export declare function LogicalSort(orderKeys: LogicalOrderKey[], child: LogicalPlanNode): LogicalSortNode;
|
|
231
|
+
export declare function LogicalLimit(count: number, offset: number | null | undefined, child: LogicalPlanNode): LogicalLimitNode;
|
|
232
|
+
export declare function LogicalDistinct(child: LogicalPlanNode): LogicalDistinctNode;
|
|
233
|
+
export declare function LogicalUnion(left: LogicalPlanNode, right: LogicalPlanNode, all: boolean): LogicalUnionNode;
|
|
234
|
+
export declare function LogicalCTEScan(cteName: string, cteId: number): LogicalCTEScanNode;
|
|
235
|
+
export declare function LogicalCTEAnchor(cteName: string, cteId: number, producer: LogicalPlanNode, consumer: LogicalPlanNode): LogicalCTEAnchorNode;
|
|
236
|
+
export declare function LogicalDependentJoin(child: LogicalPlanNode, subquery: LogicalPlanNode, correlatedColumns: BoundColumnRefNode[], subqueryType: string, condition: BoundExpr | null): LogicalDependentJoinNode;
|
|
237
|
+
export declare function LogicalTopN(orderKeys: LogicalOrderKey[], count: number, offset: number | null | undefined, child: LogicalPlanNode): LogicalTopNNode;
|
|
238
|
+
export declare function LogicalIndexScan(table: string, alias: string | undefined, indexName: string, columnName: string, scanType: string, scanKey: IndexScanValue, scanLow: IndexScanValue, scanHigh: IndexScanValue, lowInc: boolean, highInc: boolean, columns: ColumnInfo[]): LogicalIndexScanNode;
|
|
239
|
+
export declare function LogicalWindow(windowExprs: BoundExpr[], child: LogicalPlanNode): LogicalWindowNode;
|
|
240
|
+
export declare function LogicalMaterialize(child: LogicalPlanNode): LogicalMaterializeNode;
|
|
241
|
+
export declare function LogicalExchange(exchangeType: string, partitionKeys: BoundExpr[] | null | undefined, partitionCount: number | null | undefined, child: LogicalPlanNode): LogicalExchangeNode;
|
|
242
|
+
export declare function LogicalPartialAggregate(groupBy: BoundExpr[], aggregates: BoundExpr[], child: LogicalPlanNode): LogicalPartialAggregateNode;
|
|
243
|
+
export declare function LogicalFinalAggregate(groupBy: BoundExpr[], aggregates: BoundExpr[], partialAggregates: BoundExpr[], child: LogicalPlanNode): LogicalFinalAggregateNode;
|
|
244
|
+
export declare function LogicalMergeExchange(orderKeys: LogicalOrderKey[], limit: number | null | undefined, child: LogicalPlanNode): LogicalMergeExchangeNode;
|
|
245
|
+
export declare function LogicalExchangeReceive(sourceFragmentIds: number[], schema?: ColumnInfo[]): LogicalExchangeReceiveNode;
|
|
246
|
+
export declare function LogicalSingleRow(): LogicalSingleRowNode;
|
|
247
|
+
export declare function getChildren(node: LogicalPlanNode): LogicalPlanNode[];
|
|
248
|
+
export declare function setChildren<T extends LogicalPlanNode>(node: T, children: LogicalPlanNode[]): T;
|
|
249
|
+
export declare function planToString(node: LogicalPlanNode, indent?: number): string;
|
|
250
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as LP from './logical-plan.js';
|
|
2
|
+
import { type BoundExpr, type BoundColumnRefNode } from '../binder/expression-binder.js';
|
|
3
|
+
import type { BoundQuery, BoundSelect, BoundSetOp, BoundFrom } from '../binder/binder.js';
|
|
4
|
+
export declare class LogicalPlanner {
|
|
5
|
+
cteMap: Map<string, LP.LogicalPlanNode>;
|
|
6
|
+
constructor();
|
|
7
|
+
plan(boundQuery: BoundQuery): LP.LogicalPlanNode;
|
|
8
|
+
planQuery(bound: BoundQuery): LP.LogicalPlanNode;
|
|
9
|
+
planSetOp(bound: BoundSetOp): LP.LogicalPlanNode;
|
|
10
|
+
planSelect(bound: BoundSelect): LP.LogicalPlanNode;
|
|
11
|
+
planFrom(bound: BoundFrom): LP.LogicalPlanNode;
|
|
12
|
+
extractSubqueries(expr: BoundExpr | null, currentPlan: LP.LogicalPlanNode): {
|
|
13
|
+
expr: BoundExpr | null;
|
|
14
|
+
subqueryJoins: Array<(child: LP.LogicalPlanNode) => LP.LogicalPlanNode>;
|
|
15
|
+
};
|
|
16
|
+
walkAndReplace(expr: BoundExpr | null, fn: (node: BoundExpr) => BoundExpr | null): BoundExpr | null;
|
|
17
|
+
_collectWindows(expr: BoundExpr | null, out: BoundExpr[]): void;
|
|
18
|
+
findCorrelatedRefs(boundQuery: BoundQuery): BoundColumnRefNode[];
|
|
19
|
+
_scanQuery(q: BoundQuery, refs: BoundColumnRefNode[]): void;
|
|
20
|
+
_scanFrom(f: BoundFrom, refs: BoundColumnRefNode[]): void;
|
|
21
|
+
_scanExpr(e: BoundExpr | null, refs: BoundColumnRefNode[]): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function createLogicalPlan(boundQuery: BoundQuery): LP.LogicalPlanNode;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type LogicalPlanNode } from './logical-plan.js';
|
|
2
|
+
import { type BoundExpr } from '../binder/expression-binder.js';
|
|
3
|
+
export declare function formatExpression(expr?: BoundExpr | null): string;
|
|
4
|
+
export declare function formatPlan(plan: LogicalPlanNode, depth?: number): string;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as LP from './logical-plan.js';
|
|
2
|
+
import { type LogicalPlanNode } from './logical-plan.js';
|
|
3
|
+
export declare class PlanVisitor {
|
|
4
|
+
visitScan?(node: LP.LogicalScanNode): void;
|
|
5
|
+
visitFilter?(node: LP.LogicalFilterNode): void;
|
|
6
|
+
visitProject?(node: LP.LogicalProjectNode): void;
|
|
7
|
+
visitJoin?(node: LP.LogicalJoinNode): void;
|
|
8
|
+
visitAggregate?(node: LP.LogicalAggregateNode): void;
|
|
9
|
+
visitSort?(node: LP.LogicalSortNode): void;
|
|
10
|
+
visitLimit?(node: LP.LogicalLimitNode): void;
|
|
11
|
+
visitDistinct?(node: LP.LogicalDistinctNode): void;
|
|
12
|
+
visitUnion?(node: LP.LogicalUnionNode): void;
|
|
13
|
+
visitCTEScan?(node: LP.LogicalCTEScanNode): void;
|
|
14
|
+
visitCTEAnchor?(node: LP.LogicalCTEAnchorNode): void;
|
|
15
|
+
visitDependentJoin?(node: LP.LogicalDependentJoinNode): void;
|
|
16
|
+
visitMaterialize?(node: LP.LogicalMaterializeNode): void;
|
|
17
|
+
visitEmpty?(node: LP.LogicalEmptyNode): void;
|
|
18
|
+
visitTopN?(node: LP.LogicalTopNNode): void;
|
|
19
|
+
visitIndexScan?(node: LP.LogicalIndexScanNode): void;
|
|
20
|
+
visitWindow?(node: LP.LogicalWindowNode): void;
|
|
21
|
+
visitExchange?(node: LP.LogicalExchangeNode): void;
|
|
22
|
+
visitPartialAggregate?(node: LP.LogicalPartialAggregateNode): void;
|
|
23
|
+
visitFinalAggregate?(node: LP.LogicalFinalAggregateNode): void;
|
|
24
|
+
visitMergeExchange?(node: LP.LogicalMergeExchangeNode): void;
|
|
25
|
+
visitExchangeReceive?(node: LP.LogicalExchangeReceiveNode): void;
|
|
26
|
+
visitSingleRow?(node: LP.LogicalSingleRowNode): void;
|
|
27
|
+
visit(node: LogicalPlanNode): void;
|
|
28
|
+
visitDefault(node: LogicalPlanNode): void;
|
|
29
|
+
visitChildren(node: LogicalPlanNode): void;
|
|
30
|
+
}
|
|
31
|
+
export declare class PlanRewriter {
|
|
32
|
+
rewriteScan?(node: LP.LogicalScanNode): LogicalPlanNode;
|
|
33
|
+
rewriteFilter?(node: LP.LogicalFilterNode): LogicalPlanNode;
|
|
34
|
+
rewriteProject?(node: LP.LogicalProjectNode): LogicalPlanNode;
|
|
35
|
+
rewriteJoin?(node: LP.LogicalJoinNode): LogicalPlanNode;
|
|
36
|
+
rewriteAggregate?(node: LP.LogicalAggregateNode): LogicalPlanNode;
|
|
37
|
+
rewriteSort?(node: LP.LogicalSortNode): LogicalPlanNode;
|
|
38
|
+
rewriteLimit?(node: LP.LogicalLimitNode): LogicalPlanNode;
|
|
39
|
+
rewriteDistinct?(node: LP.LogicalDistinctNode): LogicalPlanNode;
|
|
40
|
+
rewriteUnion?(node: LP.LogicalUnionNode): LogicalPlanNode;
|
|
41
|
+
rewriteCTEScan?(node: LP.LogicalCTEScanNode): LogicalPlanNode;
|
|
42
|
+
rewriteCTEAnchor?(node: LP.LogicalCTEAnchorNode): LogicalPlanNode;
|
|
43
|
+
rewriteDependentJoin?(node: LP.LogicalDependentJoinNode): LogicalPlanNode;
|
|
44
|
+
rewriteMaterialize?(node: LP.LogicalMaterializeNode): LogicalPlanNode;
|
|
45
|
+
rewriteEmpty?(node: LP.LogicalEmptyNode): LogicalPlanNode;
|
|
46
|
+
rewriteTopN?(node: LP.LogicalTopNNode): LogicalPlanNode;
|
|
47
|
+
rewriteIndexScan?(node: LP.LogicalIndexScanNode): LogicalPlanNode;
|
|
48
|
+
rewriteWindow?(node: LP.LogicalWindowNode): LogicalPlanNode;
|
|
49
|
+
rewriteExchange?(node: LP.LogicalExchangeNode): LogicalPlanNode;
|
|
50
|
+
rewritePartialAggregate?(node: LP.LogicalPartialAggregateNode): LogicalPlanNode;
|
|
51
|
+
rewriteFinalAggregate?(node: LP.LogicalFinalAggregateNode): LogicalPlanNode;
|
|
52
|
+
rewriteMergeExchange?(node: LP.LogicalMergeExchangeNode): LogicalPlanNode;
|
|
53
|
+
rewriteExchangeReceive?(node: LP.LogicalExchangeReceiveNode): LogicalPlanNode;
|
|
54
|
+
rewriteSingleRow?(node: LP.LogicalSingleRowNode): LogicalPlanNode;
|
|
55
|
+
rewrite(node: LogicalPlanNode): LogicalPlanNode;
|
|
56
|
+
rewriteDefault(node: LogicalPlanNode): LogicalPlanNode;
|
|
57
|
+
rewriteChildren<T extends LogicalPlanNode>(node: T): T;
|
|
58
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function getEnvInt(key: string, fallback: number): number;
|
|
2
|
+
export declare function getEnvFloat(key: string, fallback: number): number;
|
|
3
|
+
export declare function getEnvFlag(key: string, fallback: boolean): boolean;
|
|
4
|
+
export declare function getCpuCount(): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MemoryTempSpace } from '../temp-space/memory-temp-space.js';
|
|
2
|
+
import { MemoryPageStore } from '../page-store/memory-page-store.js';
|
|
3
|
+
import { SpillManager } from '../spill-manager/spill-manager.js';
|
|
4
|
+
export interface StorageBackendOptions {
|
|
5
|
+
baseDir?: string;
|
|
6
|
+
tempDir?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class MemoryStorageBackend {
|
|
9
|
+
options: StorageBackendOptions;
|
|
10
|
+
constructor(options?: StorageBackendOptions);
|
|
11
|
+
createTempSpace(): MemoryTempSpace;
|
|
12
|
+
createPageStore(): MemoryPageStore;
|
|
13
|
+
createSpillManager(): SpillManager;
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TempDirectoryManager } from '../temp-space/temp-directory-manager.js';
|
|
2
|
+
import { FilePageStore } from '../page-store/file-page-store.js';
|
|
3
|
+
import { SpillManager } from '../spill-manager/spill-manager.js';
|
|
4
|
+
import type { StorageBackendOptions } from './memory-storage-backend.js';
|
|
5
|
+
export declare class NodeStorageBackend {
|
|
6
|
+
options: StorageBackendOptions;
|
|
7
|
+
constructor(options?: StorageBackendOptions);
|
|
8
|
+
createTempSpace(): TempDirectoryManager;
|
|
9
|
+
createPageStore(handle: string): FilePageStore;
|
|
10
|
+
createSpillManager(handle: string): SpillManager;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { DataType } from './data-type.js';
|
|
2
|
+
export type BTreeKey = string | number | bigint | boolean | null | undefined;
|
|
3
|
+
export interface RowLocation {
|
|
4
|
+
pageId: string;
|
|
5
|
+
rowIndex: number;
|
|
6
|
+
}
|
|
7
|
+
interface SplitResult {
|
|
8
|
+
key: BTreeKey;
|
|
9
|
+
right: BTreeNode;
|
|
10
|
+
}
|
|
11
|
+
declare class BTreeNode {
|
|
12
|
+
isLeaf: boolean;
|
|
13
|
+
keys: BTreeKey[];
|
|
14
|
+
children: BTreeNode[];
|
|
15
|
+
values: RowLocation[][];
|
|
16
|
+
next: BTreeNode | null;
|
|
17
|
+
constructor(isLeaf: boolean);
|
|
18
|
+
}
|
|
19
|
+
export declare class BTreeIndex {
|
|
20
|
+
dataType: DataType;
|
|
21
|
+
root: BTreeNode;
|
|
22
|
+
order: number;
|
|
23
|
+
constructor(dataType: DataType);
|
|
24
|
+
_compare(a: BTreeKey, b: BTreeKey): number;
|
|
25
|
+
_findIndex(keys: BTreeKey[], key: BTreeKey): number;
|
|
26
|
+
insert(key: BTreeKey, rowLocation: RowLocation): void;
|
|
27
|
+
_insertInternal(node: BTreeNode, key: BTreeKey, rowLocation: RowLocation): SplitResult | null;
|
|
28
|
+
_findChildIndex(node: BTreeNode, key: BTreeKey): number;
|
|
29
|
+
_splitLeaf(leaf: BTreeNode): SplitResult;
|
|
30
|
+
_splitInternal(node: BTreeNode): SplitResult;
|
|
31
|
+
search(key: BTreeKey): RowLocation[];
|
|
32
|
+
range(low: BTreeKey, high: BTreeKey, lowInclusive: boolean, highInclusive: boolean): Generator<RowLocation>;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LRUCache } from '../utils/lru-cache.js';
|
|
2
|
+
import type { DataChunk } from './chunk.js';
|
|
3
|
+
export interface PageStore {
|
|
4
|
+
write(pageId: string, chunk: DataChunk): Promise<void>;
|
|
5
|
+
read(pageId: string): Promise<DataChunk | null>;
|
|
6
|
+
clear(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare class BufferPoolManager {
|
|
9
|
+
maxPages: number;
|
|
10
|
+
cache: LRUCache<string, DataChunk | null>;
|
|
11
|
+
pageStore: PageStore;
|
|
12
|
+
constructor(maxPages: number, pageStore: PageStore);
|
|
13
|
+
clear(): void;
|
|
14
|
+
writePage(pageId: string, chunk: DataChunk): Promise<void>;
|
|
15
|
+
readPage(pageId: string): Promise<DataChunk | null>;
|
|
16
|
+
fetchPage(pageId: string, bypassCache?: boolean): Promise<DataChunk | null>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Column } from './column.js';
|
|
2
|
+
import { DictionaryColumn } from './dictionary-column.js';
|
|
3
|
+
import { DataType, type ColumnValue } from './data-type.js';
|
|
4
|
+
export type AnyColumn = Column | DictionaryColumn;
|
|
5
|
+
export type SelectionVector = Uint32Array | Int32Array | number[];
|
|
6
|
+
export declare class DataChunk {
|
|
7
|
+
columns: AnyColumn[];
|
|
8
|
+
size: number;
|
|
9
|
+
selectionVector: SelectionVector | null;
|
|
10
|
+
_cachedColumnCount: number;
|
|
11
|
+
constructor(columns: AnyColumn[], size?: number);
|
|
12
|
+
static fromSchema(schema: ReadonlyArray<{
|
|
13
|
+
dataType: DataType;
|
|
14
|
+
}>, capacity?: number): DataChunk;
|
|
15
|
+
getColumn(index: number): AnyColumn;
|
|
16
|
+
columnCount(): number;
|
|
17
|
+
getValue(rowIndex: number, colIndex: number): ColumnValue;
|
|
18
|
+
activeRowIndex(i: number): number;
|
|
19
|
+
setSelectionVector(sv: SelectionVector | null, count: number): void;
|
|
20
|
+
clearSelectionVector(): void;
|
|
21
|
+
appendRow(values: ColumnValue[]): void;
|
|
22
|
+
project(indices: number[]): DataChunk;
|
|
23
|
+
flatten(): DataChunk;
|
|
24
|
+
reset(): void;
|
|
25
|
+
toRows(): ColumnValue[][];
|
|
26
|
+
}
|