@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,243 @@
|
|
|
1
|
+
import type { DataType, ColumnValue } from '../storage/data-type.js';
|
|
2
|
+
import type { FragmentSpec, JoinSpec } from '../execution/fragment-spec.js';
|
|
3
|
+
export type FilterOperation = 'filterEq' | 'filterLt' | 'filterGt' | 'filterLe' | 'filterGe' | 'filterBetween';
|
|
4
|
+
export type CompoundCombineOp = 'and' | 'or';
|
|
5
|
+
export type ScalarAggType = 'sum' | 'min' | 'max' | 'count';
|
|
6
|
+
export type WasmDataType = 'INT32' | 'FLOAT64' | 'DATE';
|
|
7
|
+
export type ProjectOp = 'scalarAddF64' | 'scalarSubF64' | 'scalarMulF64' | 'scalarDivF64' | 'scalarSubRevF64' | 'scalarDivRevF64' | 'vecAddF64' | 'vecSubF64' | 'vecMulF64' | 'vecDivF64' | 'negF64' | 'widenI32ToF64';
|
|
8
|
+
export declare enum WorkerTaskType {
|
|
9
|
+
FILTER = "filter",
|
|
10
|
+
AGGREGATE = "aggregate",
|
|
11
|
+
FILTER_COMPOUND = "filter_compound",
|
|
12
|
+
PIPELINE = "pipeline",
|
|
13
|
+
PROJECT = "project"
|
|
14
|
+
}
|
|
15
|
+
export interface FilterDescriptor {
|
|
16
|
+
operation: FilterOperation;
|
|
17
|
+
value?: number;
|
|
18
|
+
low?: number;
|
|
19
|
+
high?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface PipelineFilterStage {
|
|
22
|
+
kind: 'filter';
|
|
23
|
+
operation: FilterOperation;
|
|
24
|
+
value?: number;
|
|
25
|
+
low?: number;
|
|
26
|
+
high?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface PipelineAggregateStage {
|
|
29
|
+
kind: 'aggregate';
|
|
30
|
+
aggType: ScalarAggType;
|
|
31
|
+
}
|
|
32
|
+
export interface PipelineCountStage {
|
|
33
|
+
kind: 'count';
|
|
34
|
+
}
|
|
35
|
+
export type PipelineStage = PipelineFilterStage | PipelineAggregateStage | PipelineCountStage;
|
|
36
|
+
export interface FilterTask {
|
|
37
|
+
type: WorkerTaskType.FILTER;
|
|
38
|
+
dataOffset: number;
|
|
39
|
+
count: number;
|
|
40
|
+
operation: FilterOperation;
|
|
41
|
+
dataType: WasmDataType;
|
|
42
|
+
baseIndex: number;
|
|
43
|
+
value?: number;
|
|
44
|
+
low?: number;
|
|
45
|
+
high?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface AggregateTask {
|
|
48
|
+
type: WorkerTaskType.AGGREGATE;
|
|
49
|
+
dataOffset: number;
|
|
50
|
+
count: number;
|
|
51
|
+
aggType: ScalarAggType;
|
|
52
|
+
dataType: WasmDataType;
|
|
53
|
+
}
|
|
54
|
+
export interface CompoundFilterTask {
|
|
55
|
+
type: WorkerTaskType.FILTER_COMPOUND;
|
|
56
|
+
dataOffset: number;
|
|
57
|
+
count: number;
|
|
58
|
+
filters: FilterDescriptor[];
|
|
59
|
+
combineOp: CompoundCombineOp;
|
|
60
|
+
dataType: WasmDataType;
|
|
61
|
+
baseIndex: number;
|
|
62
|
+
}
|
|
63
|
+
export interface PipelineTask {
|
|
64
|
+
type: WorkerTaskType.PIPELINE;
|
|
65
|
+
dataOffset: number;
|
|
66
|
+
count: number;
|
|
67
|
+
dataType: WasmDataType;
|
|
68
|
+
baseIndex: number;
|
|
69
|
+
stages: PipelineStage[];
|
|
70
|
+
}
|
|
71
|
+
export interface ProjectTask {
|
|
72
|
+
type: WorkerTaskType.PROJECT;
|
|
73
|
+
dataOffset: number;
|
|
74
|
+
dataBOffset?: number;
|
|
75
|
+
count: number;
|
|
76
|
+
op: ProjectOp;
|
|
77
|
+
scalar?: number;
|
|
78
|
+
}
|
|
79
|
+
export type WorkerTask = FilterTask | AggregateTask | CompoundFilterTask | PipelineTask | ProjectTask;
|
|
80
|
+
export type WorkerTaskMessage = WorkerTask & {
|
|
81
|
+
taskId: number;
|
|
82
|
+
};
|
|
83
|
+
export interface ScalarAggregatePartial {
|
|
84
|
+
aggType: ScalarAggType;
|
|
85
|
+
result: number;
|
|
86
|
+
count: number;
|
|
87
|
+
}
|
|
88
|
+
export interface SelectionVectorResult {
|
|
89
|
+
matchCount: number;
|
|
90
|
+
selectionVector?: Uint32Array;
|
|
91
|
+
}
|
|
92
|
+
export interface ScalarAggregateResult {
|
|
93
|
+
result: number;
|
|
94
|
+
count: number;
|
|
95
|
+
}
|
|
96
|
+
export interface PipelineAggregatesResult {
|
|
97
|
+
aggregates: ScalarAggregatePartial[];
|
|
98
|
+
}
|
|
99
|
+
export interface ProjectResult {
|
|
100
|
+
count: number;
|
|
101
|
+
resultData?: Float64Array;
|
|
102
|
+
}
|
|
103
|
+
export type WorkerResultData = SelectionVectorResult | ScalarAggregateResult | PipelineAggregatesResult | ProjectResult;
|
|
104
|
+
export interface WorkerReadyMessage {
|
|
105
|
+
type: 'ready';
|
|
106
|
+
workerId: number;
|
|
107
|
+
}
|
|
108
|
+
export interface WorkerResultMessage {
|
|
109
|
+
type: 'result';
|
|
110
|
+
taskId: number;
|
|
111
|
+
data: WorkerResultData;
|
|
112
|
+
}
|
|
113
|
+
export interface WorkerErrorMessage {
|
|
114
|
+
type: 'error';
|
|
115
|
+
taskId: number;
|
|
116
|
+
error: string;
|
|
117
|
+
}
|
|
118
|
+
export type WorkerOutboundMessage = WorkerReadyMessage | WorkerResultMessage | WorkerErrorMessage;
|
|
119
|
+
export interface WorkerInitData {
|
|
120
|
+
workerId: number;
|
|
121
|
+
wasmModule: WebAssembly.Module;
|
|
122
|
+
wasmMemory: WebAssembly.Memory;
|
|
123
|
+
regionId: number;
|
|
124
|
+
regionStart: number;
|
|
125
|
+
regionCapacity: number;
|
|
126
|
+
}
|
|
127
|
+
export interface MorselSchedulerDescriptor {
|
|
128
|
+
counterBuffer: SharedArrayBuffer;
|
|
129
|
+
totalUnits: number;
|
|
130
|
+
unitsPerMorsel: number;
|
|
131
|
+
}
|
|
132
|
+
export interface MorselRange {
|
|
133
|
+
start: number;
|
|
134
|
+
end: number;
|
|
135
|
+
}
|
|
136
|
+
export interface EncodedChunkSet {
|
|
137
|
+
buffers: ArrayBufferLike[];
|
|
138
|
+
meta: Uint32Array;
|
|
139
|
+
sizes: Uint32Array;
|
|
140
|
+
colCount: number;
|
|
141
|
+
}
|
|
142
|
+
export type AccumulatorState = ColumnValue | {
|
|
143
|
+
sum: number;
|
|
144
|
+
count: number;
|
|
145
|
+
} | ColumnValue[];
|
|
146
|
+
export interface PartialGroupRecord {
|
|
147
|
+
key: string | number | bigint | boolean | null;
|
|
148
|
+
groupValues: ColumnValue[];
|
|
149
|
+
states: AccumulatorState[];
|
|
150
|
+
}
|
|
151
|
+
export interface SpillDescriptor {
|
|
152
|
+
dir: string;
|
|
153
|
+
tag: string;
|
|
154
|
+
groupLimit: number;
|
|
155
|
+
}
|
|
156
|
+
export interface SpillRef {
|
|
157
|
+
file: string;
|
|
158
|
+
partition: number;
|
|
159
|
+
}
|
|
160
|
+
export interface JoinOutputTypes {
|
|
161
|
+
build: DataType[];
|
|
162
|
+
probe: DataType[];
|
|
163
|
+
}
|
|
164
|
+
export declare enum FragmentTaskType {
|
|
165
|
+
AGGREGATE = "aggregate",
|
|
166
|
+
COMBINE = "combine",
|
|
167
|
+
JOIN_PARTITION = "joinPartition",
|
|
168
|
+
JOIN_PROBE = "joinProbe"
|
|
169
|
+
}
|
|
170
|
+
export interface FragmentAggregateRequest {
|
|
171
|
+
type: FragmentTaskType.AGGREGATE;
|
|
172
|
+
spec: FragmentSpec;
|
|
173
|
+
chunks: EncodedChunkSet;
|
|
174
|
+
scheduler: MorselSchedulerDescriptor;
|
|
175
|
+
partitionCount: number;
|
|
176
|
+
spill: SpillDescriptor | null;
|
|
177
|
+
}
|
|
178
|
+
export interface FragmentCombineRequest {
|
|
179
|
+
type: FragmentTaskType.COMBINE;
|
|
180
|
+
spec: FragmentSpec;
|
|
181
|
+
partials: PartialGroupRecord[][];
|
|
182
|
+
spillRefs: SpillRef[];
|
|
183
|
+
}
|
|
184
|
+
export interface FragmentJoinPartitionRequest {
|
|
185
|
+
type: FragmentTaskType.JOIN_PARTITION;
|
|
186
|
+
spec: JoinSpec;
|
|
187
|
+
buildChunks: EncodedChunkSet;
|
|
188
|
+
probeChunks: EncodedChunkSet;
|
|
189
|
+
buildScheduler: MorselSchedulerDescriptor;
|
|
190
|
+
probeScheduler: MorselSchedulerDescriptor;
|
|
191
|
+
partitionCount: number;
|
|
192
|
+
}
|
|
193
|
+
export interface FragmentJoinProbeRequest {
|
|
194
|
+
type: FragmentTaskType.JOIN_PROBE;
|
|
195
|
+
spec: JoinSpec;
|
|
196
|
+
buildChunks: EncodedChunkSet;
|
|
197
|
+
probeChunks: EncodedChunkSet;
|
|
198
|
+
buildRefs: Uint32Array;
|
|
199
|
+
probeRefs: Uint32Array;
|
|
200
|
+
hasNullKey: boolean;
|
|
201
|
+
outputTypes: JoinOutputTypes;
|
|
202
|
+
}
|
|
203
|
+
export type FragmentRequest = FragmentAggregateRequest | FragmentCombineRequest | FragmentJoinPartitionRequest | FragmentJoinProbeRequest;
|
|
204
|
+
export type FragmentRequestMessage = FragmentRequest & {
|
|
205
|
+
reqId: number;
|
|
206
|
+
};
|
|
207
|
+
export interface FragmentAggregateResult {
|
|
208
|
+
partitions: PartialGroupRecord[][];
|
|
209
|
+
spillFiles: string[];
|
|
210
|
+
}
|
|
211
|
+
export interface FragmentCombineResult {
|
|
212
|
+
partials: PartialGroupRecord[];
|
|
213
|
+
}
|
|
214
|
+
export interface FragmentJoinPartitionResult {
|
|
215
|
+
buildPartitions: Uint32Array[];
|
|
216
|
+
buildNullCount: number;
|
|
217
|
+
probePartitions: Uint32Array[];
|
|
218
|
+
probeNullRows: ColumnValue[][];
|
|
219
|
+
buildNullRows: ColumnValue[][];
|
|
220
|
+
}
|
|
221
|
+
export interface FragmentJoinProbeResult {
|
|
222
|
+
chunks: EncodedChunkSet | null;
|
|
223
|
+
}
|
|
224
|
+
export type FragmentResult = FragmentAggregateResult | FragmentCombineResult | FragmentJoinPartitionResult | FragmentJoinProbeResult;
|
|
225
|
+
export interface FragmentSuccessMessage {
|
|
226
|
+
reqId: number;
|
|
227
|
+
ok: true;
|
|
228
|
+
partitions?: PartialGroupRecord[][];
|
|
229
|
+
spillFiles?: string[];
|
|
230
|
+
partials?: PartialGroupRecord[] | PartialGroupRecord[][];
|
|
231
|
+
buildPartitions?: Uint32Array[];
|
|
232
|
+
buildNullCount?: number;
|
|
233
|
+
probePartitions?: Uint32Array[];
|
|
234
|
+
probeNullRows?: ColumnValue[][];
|
|
235
|
+
buildNullRows?: ColumnValue[][];
|
|
236
|
+
chunks?: EncodedChunkSet | null;
|
|
237
|
+
}
|
|
238
|
+
export interface FragmentFailureMessage {
|
|
239
|
+
reqId: number;
|
|
240
|
+
ok: false;
|
|
241
|
+
error: string;
|
|
242
|
+
}
|
|
243
|
+
export type FragmentReplyMessage = FragmentSuccessMessage | FragmentFailureMessage;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Worker } from 'worker_threads';
|
|
2
|
+
import type { WorkerTask, WorkerResultData } from './worker-messages.js';
|
|
3
|
+
declare const WORKER_STATE: {
|
|
4
|
+
readonly IDLE: 0;
|
|
5
|
+
readonly BUSY: 1;
|
|
6
|
+
readonly TERMINATED: 2;
|
|
7
|
+
};
|
|
8
|
+
type WorkerStateValue = typeof WORKER_STATE[keyof typeof WORKER_STATE];
|
|
9
|
+
interface RegionBounds {
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
}
|
|
13
|
+
interface RegionAllocatorLike {
|
|
14
|
+
addRegion(): number;
|
|
15
|
+
getRegionBounds(regionId: number): RegionBounds;
|
|
16
|
+
}
|
|
17
|
+
interface WorkerPoolOptions {
|
|
18
|
+
maxWorkers: number;
|
|
19
|
+
wasmModule: WebAssembly.Module;
|
|
20
|
+
wasmMemory: WebAssembly.Memory;
|
|
21
|
+
regionAllocator: RegionAllocatorLike;
|
|
22
|
+
}
|
|
23
|
+
interface WorkerEntry {
|
|
24
|
+
worker: Worker;
|
|
25
|
+
id: number;
|
|
26
|
+
regionId: number;
|
|
27
|
+
state: WorkerStateValue;
|
|
28
|
+
}
|
|
29
|
+
interface PendingTask {
|
|
30
|
+
taskId: number;
|
|
31
|
+
task: WorkerTask;
|
|
32
|
+
resolve: (value: WorkerResultData) => void;
|
|
33
|
+
reject: (reason: Error) => void;
|
|
34
|
+
targetWorkerId: number | undefined;
|
|
35
|
+
workerId: number | null;
|
|
36
|
+
}
|
|
37
|
+
export declare class WorkerPool {
|
|
38
|
+
maxWorkers: number;
|
|
39
|
+
wasmModule: WebAssembly.Module;
|
|
40
|
+
wasmMemory: WebAssembly.Memory;
|
|
41
|
+
regionAllocator: RegionAllocatorLike;
|
|
42
|
+
workers: Map<number, WorkerEntry>;
|
|
43
|
+
taskQueue: PendingTask[];
|
|
44
|
+
taskIdCounter: number;
|
|
45
|
+
pendingTasks: Map<number, PendingTask>;
|
|
46
|
+
initialized: boolean;
|
|
47
|
+
constructor({ maxWorkers, wasmModule, wasmMemory, regionAllocator }: WorkerPoolOptions);
|
|
48
|
+
init(): Promise<void>;
|
|
49
|
+
_spawnWorker(id: number): Promise<void>;
|
|
50
|
+
execute(tasks: WorkerTask[]): Promise<WorkerResultData[]>;
|
|
51
|
+
executeOnWorker(workerId: number, task: WorkerTask): Promise<WorkerResultData>;
|
|
52
|
+
_submitTask(task: WorkerTask, targetWorkerId?: number): Promise<WorkerResultData>;
|
|
53
|
+
_dispatch(entry: WorkerEntry, taskId: number, task: WorkerTask, pending: PendingTask): void;
|
|
54
|
+
_drainQueue(): void;
|
|
55
|
+
_findIdleWorker(): WorkerEntry | null;
|
|
56
|
+
activeWorkerCount(): number;
|
|
57
|
+
idleWorkerCount(): number;
|
|
58
|
+
resize(newCount: number): Promise<void>;
|
|
59
|
+
_terminateWorker(id: number): Promise<void>;
|
|
60
|
+
shutdown(): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
export declare enum NodeKind {
|
|
2
|
+
EXPLAIN_STMT = "ExplainStmt",
|
|
3
|
+
SELECT_STMT = "SelectStmt",
|
|
4
|
+
SET_OP = "SetOp",
|
|
5
|
+
WITH_CLAUSE = "WithClause",
|
|
6
|
+
CTE = "CTE",
|
|
7
|
+
SELECT_ITEM = "SelectItem",
|
|
8
|
+
ALL_COLUMNS = "AllColumns",
|
|
9
|
+
TABLE_REF = "TableRef",
|
|
10
|
+
JOIN_REF = "JoinRef",
|
|
11
|
+
SUBQUERY_REF = "SubqueryRef",
|
|
12
|
+
COLUMN_REF = "ColumnRef",
|
|
13
|
+
LITERAL = "Literal",
|
|
14
|
+
BINARY_EXPR = "BinaryExpr",
|
|
15
|
+
UNARY_EXPR = "UnaryExpr",
|
|
16
|
+
BETWEEN_EXPR = "BetweenExpr",
|
|
17
|
+
IN_EXPR = "InExpr",
|
|
18
|
+
LIKE_EXPR = "LikeExpr",
|
|
19
|
+
IS_NULL_EXPR = "IsNullExpr",
|
|
20
|
+
EXISTS_EXPR = "ExistsExpr",
|
|
21
|
+
SUBQUERY_EXPR = "SubqueryExpr",
|
|
22
|
+
FUNCTION_CALL = "FunctionCall",
|
|
23
|
+
AGGREGATE_CALL = "AggregateCall",
|
|
24
|
+
CASE_EXPR = "CaseExpr",
|
|
25
|
+
WHEN_CLAUSE = "WhenClause",
|
|
26
|
+
CAST_EXPR = "CastExpr",
|
|
27
|
+
EXTRACT_EXPR = "ExtractExpr",
|
|
28
|
+
SUBSTRING_EXPR = "SubstringExpr",
|
|
29
|
+
INTERVAL_EXPR = "IntervalExpr",
|
|
30
|
+
ORDER_KEY = "OrderKey",
|
|
31
|
+
TYPE_NAME = "TypeName",
|
|
32
|
+
WINDOW_SPEC = "WindowSpec",
|
|
33
|
+
WINDOW_CALL = "WindowCall",
|
|
34
|
+
CREATE_TABLE_STMT = "CreateTableStmt",
|
|
35
|
+
DROP_TABLE_STMT = "DropTableStmt",
|
|
36
|
+
COLUMN_DEF = "ColumnDef",
|
|
37
|
+
EXPLAIN_ANALYZE_STMT = "ExplainAnalyzeStmt"
|
|
38
|
+
}
|
|
39
|
+
export type Expr = ColumnRefNode | LiteralNode | BinaryExprNode | UnaryExprNode | BetweenExprNode | InExprNode | LikeExprNode | IsNullExprNode | ExistsExprNode | SubqueryExprNode | FunctionCallNode | AggregateCallNode | CaseExprNode | CastExprNode | ExtractExprNode | SubstringExprNode | IntervalExprNode | WindowCallNode | AllColumnsNode;
|
|
40
|
+
export type FromItem = TableRefNode | JoinRefNode | SubqueryRefNode;
|
|
41
|
+
export type QueryStmt = SelectStmtNode | SetOpNode;
|
|
42
|
+
export type Statement = QueryStmt | ExplainStmtNode | ExplainAnalyzeStmtNode | CreateTableStmtNode | DropTableStmtNode;
|
|
43
|
+
export type ASTNode = Statement | WithClauseNode | CTENode | SelectItemNode | FromItem | Expr | WhenClauseNode | OrderKeyNode | TypeNameNode | WindowSpecNode | ColumnDefNode | QuantifiedSubqueryNode;
|
|
44
|
+
export interface ExplainStmtNode {
|
|
45
|
+
kind: NodeKind.EXPLAIN_STMT;
|
|
46
|
+
query: QueryStmt;
|
|
47
|
+
}
|
|
48
|
+
export interface SelectStmtNode {
|
|
49
|
+
kind: NodeKind.SELECT_STMT;
|
|
50
|
+
withClause: WithClauseNode | null;
|
|
51
|
+
distinct: boolean;
|
|
52
|
+
selectItems: SelectItemNode[];
|
|
53
|
+
from: FromItem | null;
|
|
54
|
+
where: Expr | null;
|
|
55
|
+
groupBy: Expr[] | null;
|
|
56
|
+
having: Expr | null;
|
|
57
|
+
orderBy: OrderKeyNode[] | null;
|
|
58
|
+
limit: Expr | null;
|
|
59
|
+
offset: Expr | null;
|
|
60
|
+
}
|
|
61
|
+
export interface SetOpNode {
|
|
62
|
+
kind: NodeKind.SET_OP;
|
|
63
|
+
op: string;
|
|
64
|
+
left: QueryStmt;
|
|
65
|
+
right: QueryStmt;
|
|
66
|
+
all: boolean;
|
|
67
|
+
}
|
|
68
|
+
export interface WithClauseNode {
|
|
69
|
+
kind: NodeKind.WITH_CLAUSE;
|
|
70
|
+
ctes: CTENode[];
|
|
71
|
+
}
|
|
72
|
+
export interface CTENode {
|
|
73
|
+
kind: NodeKind.CTE;
|
|
74
|
+
name: string;
|
|
75
|
+
query: QueryStmt;
|
|
76
|
+
columnAliases: string[] | null;
|
|
77
|
+
}
|
|
78
|
+
export interface SelectItemNode {
|
|
79
|
+
kind: NodeKind.SELECT_ITEM;
|
|
80
|
+
expr: Expr;
|
|
81
|
+
alias: string | null;
|
|
82
|
+
}
|
|
83
|
+
export interface AllColumnsNode {
|
|
84
|
+
kind: NodeKind.ALL_COLUMNS;
|
|
85
|
+
table: string | null;
|
|
86
|
+
}
|
|
87
|
+
export interface TableRefNode {
|
|
88
|
+
kind: NodeKind.TABLE_REF;
|
|
89
|
+
name: string;
|
|
90
|
+
alias: string;
|
|
91
|
+
}
|
|
92
|
+
export interface JoinRefNode {
|
|
93
|
+
kind: NodeKind.JOIN_REF;
|
|
94
|
+
left: FromItem;
|
|
95
|
+
right: FromItem;
|
|
96
|
+
joinType: string;
|
|
97
|
+
condition: Expr | null;
|
|
98
|
+
natural?: boolean;
|
|
99
|
+
usingColumns?: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface SubqueryRefNode {
|
|
102
|
+
kind: NodeKind.SUBQUERY_REF;
|
|
103
|
+
query: QueryStmt;
|
|
104
|
+
alias: string | null;
|
|
105
|
+
}
|
|
106
|
+
export interface ColumnRefNode {
|
|
107
|
+
kind: NodeKind.COLUMN_REF;
|
|
108
|
+
name: string;
|
|
109
|
+
table: string | null;
|
|
110
|
+
}
|
|
111
|
+
export interface LiteralNode {
|
|
112
|
+
kind: NodeKind.LITERAL;
|
|
113
|
+
value: string | number | boolean | null;
|
|
114
|
+
dataType: string | null;
|
|
115
|
+
}
|
|
116
|
+
export interface BinaryExprNode {
|
|
117
|
+
kind: NodeKind.BINARY_EXPR;
|
|
118
|
+
op: string;
|
|
119
|
+
left: Expr;
|
|
120
|
+
right: Expr | QuantifiedSubqueryNode;
|
|
121
|
+
}
|
|
122
|
+
export interface UnaryExprNode {
|
|
123
|
+
kind: NodeKind.UNARY_EXPR;
|
|
124
|
+
op: string;
|
|
125
|
+
operand: Expr;
|
|
126
|
+
}
|
|
127
|
+
export interface BetweenExprNode {
|
|
128
|
+
kind: NodeKind.BETWEEN_EXPR;
|
|
129
|
+
expr: Expr;
|
|
130
|
+
low: Expr;
|
|
131
|
+
high: Expr;
|
|
132
|
+
negated: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface InExprNode {
|
|
135
|
+
kind: NodeKind.IN_EXPR;
|
|
136
|
+
expr: Expr;
|
|
137
|
+
list: Expr[] | SubqueryExprNode;
|
|
138
|
+
negated: boolean;
|
|
139
|
+
}
|
|
140
|
+
export interface LikeExprNode {
|
|
141
|
+
kind: NodeKind.LIKE_EXPR;
|
|
142
|
+
expr: Expr;
|
|
143
|
+
pattern: Expr;
|
|
144
|
+
negated: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface IsNullExprNode {
|
|
147
|
+
kind: NodeKind.IS_NULL_EXPR;
|
|
148
|
+
expr: Expr;
|
|
149
|
+
negated: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface ExistsExprNode {
|
|
152
|
+
kind: NodeKind.EXISTS_EXPR;
|
|
153
|
+
query: QueryStmt;
|
|
154
|
+
negated: boolean;
|
|
155
|
+
}
|
|
156
|
+
export interface SubqueryExprNode {
|
|
157
|
+
kind: NodeKind.SUBQUERY_EXPR;
|
|
158
|
+
query: QueryStmt;
|
|
159
|
+
}
|
|
160
|
+
export interface FunctionCallNode {
|
|
161
|
+
kind: NodeKind.FUNCTION_CALL;
|
|
162
|
+
name: string;
|
|
163
|
+
args: Expr[];
|
|
164
|
+
}
|
|
165
|
+
export interface AggregateCallNode {
|
|
166
|
+
kind: NodeKind.AGGREGATE_CALL;
|
|
167
|
+
name: string;
|
|
168
|
+
args: Expr[];
|
|
169
|
+
distinct: boolean;
|
|
170
|
+
}
|
|
171
|
+
export interface CaseExprNode {
|
|
172
|
+
kind: NodeKind.CASE_EXPR;
|
|
173
|
+
operand: Expr | null;
|
|
174
|
+
whenClauses: WhenClauseNode[];
|
|
175
|
+
elseExpr: Expr | null;
|
|
176
|
+
}
|
|
177
|
+
export interface WhenClauseNode {
|
|
178
|
+
kind: NodeKind.WHEN_CLAUSE;
|
|
179
|
+
condition: Expr;
|
|
180
|
+
result: Expr;
|
|
181
|
+
}
|
|
182
|
+
export interface CastExprNode {
|
|
183
|
+
kind: NodeKind.CAST_EXPR;
|
|
184
|
+
expr: Expr;
|
|
185
|
+
targetType: TypeNameNode;
|
|
186
|
+
}
|
|
187
|
+
export interface ExtractExprNode {
|
|
188
|
+
kind: NodeKind.EXTRACT_EXPR;
|
|
189
|
+
field: string;
|
|
190
|
+
source: Expr;
|
|
191
|
+
}
|
|
192
|
+
export interface SubstringExprNode {
|
|
193
|
+
kind: NodeKind.SUBSTRING_EXPR;
|
|
194
|
+
expr: Expr;
|
|
195
|
+
from: Expr;
|
|
196
|
+
length: Expr | null;
|
|
197
|
+
}
|
|
198
|
+
export interface IntervalExprNode {
|
|
199
|
+
kind: NodeKind.INTERVAL_EXPR;
|
|
200
|
+
value: string;
|
|
201
|
+
unit: string;
|
|
202
|
+
}
|
|
203
|
+
export interface OrderKeyNode {
|
|
204
|
+
kind: NodeKind.ORDER_KEY;
|
|
205
|
+
expr: Expr;
|
|
206
|
+
direction: string;
|
|
207
|
+
nullOrder: string | null;
|
|
208
|
+
}
|
|
209
|
+
export interface TypeNameNode {
|
|
210
|
+
kind: NodeKind.TYPE_NAME;
|
|
211
|
+
name: string;
|
|
212
|
+
params: number[];
|
|
213
|
+
}
|
|
214
|
+
export interface WindowSpecNode {
|
|
215
|
+
kind: NodeKind.WINDOW_SPEC;
|
|
216
|
+
partitionBy: Expr[];
|
|
217
|
+
orderBy: OrderKeyNode[];
|
|
218
|
+
}
|
|
219
|
+
export interface WindowCallNode {
|
|
220
|
+
kind: NodeKind.WINDOW_CALL;
|
|
221
|
+
name: string;
|
|
222
|
+
args: Expr[];
|
|
223
|
+
windowSpec: WindowSpecNode;
|
|
224
|
+
}
|
|
225
|
+
export interface CreateTableStmtNode {
|
|
226
|
+
kind: NodeKind.CREATE_TABLE_STMT;
|
|
227
|
+
name: string;
|
|
228
|
+
columns: ColumnDefNode[] | null;
|
|
229
|
+
ifNotExists: boolean;
|
|
230
|
+
as: QueryStmt | null;
|
|
231
|
+
}
|
|
232
|
+
export interface DropTableStmtNode {
|
|
233
|
+
kind: NodeKind.DROP_TABLE_STMT;
|
|
234
|
+
name: string;
|
|
235
|
+
ifExists: boolean;
|
|
236
|
+
}
|
|
237
|
+
export interface ColumnDefNode {
|
|
238
|
+
kind: NodeKind.COLUMN_DEF;
|
|
239
|
+
name: string;
|
|
240
|
+
typeName: TypeNameNode;
|
|
241
|
+
}
|
|
242
|
+
export interface ExplainAnalyzeStmtNode {
|
|
243
|
+
kind: NodeKind.EXPLAIN_ANALYZE_STMT;
|
|
244
|
+
query: QueryStmt;
|
|
245
|
+
}
|
|
246
|
+
export interface QuantifiedSubqueryNode {
|
|
247
|
+
kind: 'QuantifiedSubquery';
|
|
248
|
+
quantifier: string;
|
|
249
|
+
query: QueryStmt;
|
|
250
|
+
}
|
|
251
|
+
export interface SelectStmtOptions {
|
|
252
|
+
withClause?: WithClauseNode | null;
|
|
253
|
+
distinct?: boolean;
|
|
254
|
+
selectItems: SelectItemNode[];
|
|
255
|
+
from?: FromItem | null;
|
|
256
|
+
where?: Expr | null;
|
|
257
|
+
groupBy?: Expr[] | null;
|
|
258
|
+
having?: Expr | null;
|
|
259
|
+
orderBy?: OrderKeyNode[] | null;
|
|
260
|
+
limit?: Expr | null;
|
|
261
|
+
offset?: Expr | null;
|
|
262
|
+
}
|
|
263
|
+
export declare function ExplainStmt(query: QueryStmt): ExplainStmtNode;
|
|
264
|
+
export declare function SelectStmt({ withClause, distinct, selectItems, from, where, groupBy, having, orderBy, limit, offset, }: SelectStmtOptions): SelectStmtNode;
|
|
265
|
+
export declare function SetOp(op: string, left: QueryStmt, right: QueryStmt, all?: boolean): SetOpNode;
|
|
266
|
+
export declare function WithClause(ctes: CTENode[]): WithClauseNode;
|
|
267
|
+
export declare function CTE(name: string, query: QueryStmt, columnAliases?: string[] | null): CTENode;
|
|
268
|
+
export declare function SelectItem(expr: Expr, alias?: string | null): SelectItemNode;
|
|
269
|
+
export declare function AllColumns(table?: string | null): AllColumnsNode;
|
|
270
|
+
export declare function TableRef(name: string, alias?: string | null): TableRefNode;
|
|
271
|
+
export declare function JoinRef(left: FromItem, right: FromItem, joinType: string, condition?: Expr | null): JoinRefNode;
|
|
272
|
+
export declare function SubqueryRef(query: QueryStmt, alias: string | null): SubqueryRefNode;
|
|
273
|
+
export declare function ColumnRef(name: string, table?: string | null): ColumnRefNode;
|
|
274
|
+
export declare function Literal(value: string | number | boolean | null, dataType?: string | null): LiteralNode;
|
|
275
|
+
export declare function BinaryExpr(op: string, left: Expr, right: Expr | QuantifiedSubqueryNode): BinaryExprNode;
|
|
276
|
+
export declare function UnaryExpr(op: string, operand: Expr): UnaryExprNode;
|
|
277
|
+
export declare function BetweenExpr(expr: Expr, low: Expr, high: Expr, negated?: boolean): BetweenExprNode;
|
|
278
|
+
export declare function InExpr(expr: Expr, list: Expr[] | SubqueryExprNode, negated?: boolean): InExprNode;
|
|
279
|
+
export declare function LikeExpr(expr: Expr, pattern: Expr, negated?: boolean): LikeExprNode;
|
|
280
|
+
export declare function IsNullExpr(expr: Expr, negated?: boolean): IsNullExprNode;
|
|
281
|
+
export declare function ExistsExpr(query: QueryStmt, negated?: boolean): ExistsExprNode;
|
|
282
|
+
export declare function SubqueryExpr(query: QueryStmt): SubqueryExprNode;
|
|
283
|
+
export declare function FunctionCall(name: string, args: Expr[]): FunctionCallNode;
|
|
284
|
+
export declare function AggregateCall(name: string, args: Expr[], distinct?: boolean): AggregateCallNode;
|
|
285
|
+
export declare function CaseExpr(operand: Expr | null, whenClauses: WhenClauseNode[], elseExpr?: Expr | null): CaseExprNode;
|
|
286
|
+
export declare function WhenClause(condition: Expr, result: Expr): WhenClauseNode;
|
|
287
|
+
export declare function CastExpr(expr: Expr, targetType: TypeNameNode): CastExprNode;
|
|
288
|
+
export declare function ExtractExpr(field: string, source: Expr): ExtractExprNode;
|
|
289
|
+
export declare function SubstringExpr(expr: Expr, from: Expr, length?: Expr | null): SubstringExprNode;
|
|
290
|
+
export declare function IntervalExpr(value: string, unit: string): IntervalExprNode;
|
|
291
|
+
export declare function OrderKey(expr: Expr, direction?: string, nullOrder?: string | null): OrderKeyNode;
|
|
292
|
+
export declare function TypeName(name: string, params?: number[]): TypeNameNode;
|
|
293
|
+
export declare function WindowSpec(partitionBy?: Expr[], orderBy?: OrderKeyNode[]): WindowSpecNode;
|
|
294
|
+
export declare function WindowCall(name: string, args: Expr[], windowSpec: WindowSpecNode): WindowCallNode;
|
|
295
|
+
export declare function CreateTableStmt(name: string, columns: ColumnDefNode[] | null, ifNotExists?: boolean, as?: QueryStmt | null): CreateTableStmtNode;
|
|
296
|
+
export declare function DropTableStmt(name: string, ifExists?: boolean): DropTableStmtNode;
|
|
297
|
+
export declare function ColumnDef(name: string, typeName: TypeNameNode): ColumnDefNode;
|
|
298
|
+
export declare function ExplainAnalyzeStmt(query: QueryStmt): ExplainAnalyzeStmtNode;
|