@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.
Files changed (179) hide show
  1. package/dist/binder/binder.d.ts +130 -0
  2. package/dist/binder/expression-binder.d.ts +168 -0
  3. package/dist/binder/scope.d.ts +40 -0
  4. package/dist/browser.d.ts +8 -0
  5. package/dist/catalog/catalog.d.ts +53 -0
  6. package/dist/catalog/function-registry.d.ts +26 -0
  7. package/dist/catalog/statistics-cache.d.ts +39 -0
  8. package/dist/catalog/statistics.d.ts +72 -0
  9. package/dist/catalog/tpch-schema.d.ts +15 -0
  10. package/dist/cli/cli-common.d.ts +11 -0
  11. package/dist/cli/coordinator.d.ts +1 -0
  12. package/dist/cli/format.d.ts +8 -0
  13. package/dist/cli/index.d.ts +1 -0
  14. package/dist/cli/loaders/csv-loader.d.ts +17 -0
  15. package/dist/cli/loaders/data-loader.d.ts +7 -0
  16. package/dist/cli/loaders/json-loader.d.ts +13 -0
  17. package/dist/cli/loaders/loader-factory.d.ts +4 -0
  18. package/dist/cli/repl.d.ts +6 -0
  19. package/dist/cli/worker.d.ts +1 -0
  20. package/dist/config.d.ts +42 -0
  21. package/dist/core.wasm +0 -0
  22. package/dist/dataframe/column-expr.d.ts +67 -0
  23. package/dist/dataframe/dataframe.d.ts +96 -0
  24. package/dist/dataframe/expr-types.d.ts +6 -0
  25. package/dist/dataframe/in-memory-relation.d.ts +31 -0
  26. package/dist/dataframe/index.d.ts +4 -0
  27. package/dist/dataframe/schema.d.ts +35 -0
  28. package/dist/dataframe/sql-expr-binder.d.ts +17 -0
  29. package/dist/dataframe/type-inference.d.ts +8 -0
  30. package/dist/distributed/cluster/cluster-manager.d.ts +54 -0
  31. package/dist/distributed/cluster/heartbeat-monitor.d.ts +27 -0
  32. package/dist/distributed/cluster/node-descriptor.d.ts +41 -0
  33. package/dist/distributed/distributed-types.d.ts +336 -0
  34. package/dist/distributed/execution/coordinator.d.ts +53 -0
  35. package/dist/distributed/execution/exchange-operator.d.ts +44 -0
  36. package/dist/distributed/execution/fragment-executor.d.ts +48 -0
  37. package/dist/distributed/execution/merge-exchange.d.ts +55 -0
  38. package/dist/distributed/optimizer/distributed-sort.d.ts +6 -0
  39. package/dist/distributed/optimizer/distribution-aware-join.d.ts +28 -0
  40. package/dist/distributed/optimizer/partial-aggregate.d.ts +9 -0
  41. package/dist/distributed/partition/partition-map.d.ts +27 -0
  42. package/dist/distributed/partition/partition-pruner.d.ts +33 -0
  43. package/dist/distributed/partition/partition-strategy.d.ts +43 -0
  44. package/dist/distributed/planner/distributed-planner.d.ts +71 -0
  45. package/dist/distributed/planner/exchange-placement.d.ts +19 -0
  46. package/dist/distributed/planner/expr-utils.d.ts +2 -0
  47. package/dist/distributed/planner/fragment.d.ts +47 -0
  48. package/dist/distributed/transport/chunk-codec.d.ts +18 -0
  49. package/dist/distributed/transport/http-transport.d.ts +49 -0
  50. package/dist/distributed/transport/transport.d.ts +13 -0
  51. package/dist/engine/query-engine.d.ts +142 -0
  52. package/dist/engine-entry.d.ts +12 -0
  53. package/dist/execution/builders/aggregate-builder.d.ts +46 -0
  54. package/dist/execution/builders/builder-utils.d.ts +5 -0
  55. package/dist/execution/builders/cte-builders.d.ts +20 -0
  56. package/dist/execution/builders/exchange-builders.d.ts +33 -0
  57. package/dist/execution/builders/join-builder.d.ts +67 -0
  58. package/dist/execution/builders/pipeline-builders.d.ts +30 -0
  59. package/dist/execution/builders/source-builders.d.ts +23 -0
  60. package/dist/execution/column-resolve.d.ts +7 -0
  61. package/dist/execution/execution-types.d.ts +33 -0
  62. package/dist/execution/expression-eval.d.ts +13 -0
  63. package/dist/execution/fragment-spec.d.ts +125 -0
  64. package/dist/execution/join-utils.d.ts +14 -0
  65. package/dist/execution/operator-registry.d.ts +9 -0
  66. package/dist/execution/operators/agg-wasm.d.ts +16 -0
  67. package/dist/execution/operators/dedup-core.d.ts +10 -0
  68. package/dist/execution/operators/dependent-join.d.ts +14 -0
  69. package/dist/execution/operators/distinct.d.ts +12 -0
  70. package/dist/execution/operators/filter.d.ts +87 -0
  71. package/dist/execution/operators/hash-aggregate.d.ts +121 -0
  72. package/dist/execution/operators/hash-join.d.ts +74 -0
  73. package/dist/execution/operators/index-scan.d.ts +34 -0
  74. package/dist/execution/operators/join-core.d.ts +47 -0
  75. package/dist/execution/operators/merge-join.d.ts +38 -0
  76. package/dist/execution/operators/nested-loop-join.d.ts +28 -0
  77. package/dist/execution/operators/projection.d.ts +20 -0
  78. package/dist/execution/operators/scan.d.ts +17 -0
  79. package/dist/execution/operators/sort.d.ts +48 -0
  80. package/dist/execution/operators/stream-aggregate.d.ts +30 -0
  81. package/dist/execution/operators/union.d.ts +13 -0
  82. package/dist/execution/operators/vector-aggregate.d.ts +73 -0
  83. package/dist/execution/operators/window.d.ts +22 -0
  84. package/dist/execution/physical-plan.d.ts +14 -0
  85. package/dist/execution/pipeline.d.ts +28 -0
  86. package/dist/execution/query-executor.d.ts +70 -0
  87. package/dist/execution/query-result.d.ts +15 -0
  88. package/dist/execution/result-sink.d.ts +26 -0
  89. package/dist/execution/scheduler.d.ts +8 -0
  90. package/dist/execution/vector-ops.d.ts +32 -0
  91. package/dist/execution/wasm-expr-eval.d.ts +7 -0
  92. package/dist/index.browser.js +17999 -0
  93. package/dist/index.cli.js +1002 -0
  94. package/dist/index.d.ts +20 -0
  95. package/dist/index.node.js +21432 -0
  96. package/dist/optimizer/dphyp/cardinality.d.ts +69 -0
  97. package/dist/optimizer/dphyp/cost-model.d.ts +47 -0
  98. package/dist/optimizer/dphyp/dphyp.d.ts +32 -0
  99. package/dist/optimizer/dphyp/hypergraph.d.ts +38 -0
  100. package/dist/optimizer/optimizer.d.ts +12 -0
  101. package/dist/optimizer/pass.d.ts +5 -0
  102. package/dist/optimizer/passes/aggregate-pushdown.d.ts +6 -0
  103. package/dist/optimizer/passes/cte-optimization.d.ts +6 -0
  104. package/dist/optimizer/passes/empty-propagation.d.ts +6 -0
  105. package/dist/optimizer/passes/expr-walk.d.ts +20 -0
  106. package/dist/optimizer/passes/expression-simplifier.d.ts +8 -0
  107. package/dist/optimizer/passes/filter-ordering.d.ts +13 -0
  108. package/dist/optimizer/passes/having-pushdown.d.ts +6 -0
  109. package/dist/optimizer/passes/index-selection.d.ts +24 -0
  110. package/dist/optimizer/passes/join-elimination.d.ts +6 -0
  111. package/dist/optimizer/passes/join-reorder.d.ts +12 -0
  112. package/dist/optimizer/passes/join-residual-split.d.ts +6 -0
  113. package/dist/optimizer/passes/limit-pushdown.d.ts +6 -0
  114. package/dist/optimizer/passes/node-merge.d.ts +6 -0
  115. package/dist/optimizer/passes/outer-to-inner.d.ts +6 -0
  116. package/dist/optimizer/passes/physical-design.d.ts +12 -0
  117. package/dist/optimizer/passes/plan-refs.d.ts +22 -0
  118. package/dist/optimizer/passes/predicate-dedup.d.ts +6 -0
  119. package/dist/optimizer/passes/predicate-inference.d.ts +6 -0
  120. package/dist/optimizer/passes/predicate-pushdown.d.ts +9 -0
  121. package/dist/optimizer/passes/projection-pushdown.d.ts +6 -0
  122. package/dist/optimizer/passes/sort-elimination.d.ts +6 -0
  123. package/dist/optimizer/passes/subquery-unnesting.d.ts +6 -0
  124. package/dist/optimizer/passes/topn-fusion.d.ts +6 -0
  125. package/dist/parallel/chunk-transport.d.ts +24 -0
  126. package/dist/parallel/fragment-pool.d.ts +49 -0
  127. package/dist/parallel/fragment-worker.d.ts +1 -0
  128. package/dist/parallel/morsel-scheduler.d.ts +11 -0
  129. package/dist/parallel/parallel-dispatch.d.ts +69 -0
  130. package/dist/parallel/partial-spill.d.ts +3 -0
  131. package/dist/parallel/worker-messages.d.ts +243 -0
  132. package/dist/parallel/worker-pool.d.ts +62 -0
  133. package/dist/parallel/worker-thread.d.ts +1 -0
  134. package/dist/parser/ast.d.ts +298 -0
  135. package/dist/parser/lexer.d.ts +135 -0
  136. package/dist/parser/parser.d.ts +64 -0
  137. package/dist/planner/logical-plan.d.ts +250 -0
  138. package/dist/planner/logical-planner.d.ts +23 -0
  139. package/dist/planner/plan-formatter.d.ts +4 -0
  140. package/dist/planner/plan-visitor.d.ts +58 -0
  141. package/dist/runtime/platform.d.ts +4 -0
  142. package/dist/storage/backend/memory-storage-backend.d.ts +14 -0
  143. package/dist/storage/backend/node-storage-backend.d.ts +11 -0
  144. package/dist/storage/btree.d.ts +34 -0
  145. package/dist/storage/buffer-pool.d.ts +17 -0
  146. package/dist/storage/chunk.d.ts +26 -0
  147. package/dist/storage/column.d.ts +38 -0
  148. package/dist/storage/data-type.d.ts +54 -0
  149. package/dist/storage/dictionary-column.d.ts +33 -0
  150. package/dist/storage/page-store/file-page-store.d.ts +13 -0
  151. package/dist/storage/page-store/memory-page-store.d.ts +9 -0
  152. package/dist/storage/sab-arena.d.ts +26 -0
  153. package/dist/storage/serializer.d.ts +6 -0
  154. package/dist/storage/spill-manager/fs-storage.d.ts +11 -0
  155. package/dist/storage/spill-manager/memory-storage.d.ts +10 -0
  156. package/dist/storage/spill-manager/spill-manager.d.ts +17 -0
  157. package/dist/storage/storage-constants.d.ts +3 -0
  158. package/dist/storage/table.d.ts +31 -0
  159. package/dist/storage/temp-space/memory-temp-space.d.ts +11 -0
  160. package/dist/storage/temp-space/temp-directory-manager.d.ts +14 -0
  161. package/dist/utils/bitmap.d.ts +11 -0
  162. package/dist/utils/hash.d.ts +1 -0
  163. package/dist/utils/lru-cache.d.ts +24 -0
  164. package/dist/utils/priority-queue.d.ts +18 -0
  165. package/dist/wasm/dispatch.d.ts +13 -0
  166. package/dist/wasm/fetch-byte-source.d.ts +2 -0
  167. package/dist/wasm/kernels/core-instance.d.ts +6 -0
  168. package/dist/wasm/kernels/kernel-factory.d.ts +8 -0
  169. package/dist/wasm/kernels/wasm-aggregate.d.ts +6 -0
  170. package/dist/wasm/kernels/wasm-arithmetic.d.ts +13 -0
  171. package/dist/wasm/kernels/wasm-filter-f64.d.ts +8 -0
  172. package/dist/wasm/kernels/wasm-filter.d.ts +5 -0
  173. package/dist/wasm/loader.d.ts +17 -0
  174. package/dist/wasm/node-byte-source.d.ts +1 -0
  175. package/dist/wasm/region-allocator.d.ts +23 -0
  176. package/dist/wasm/register-kernels.d.ts +1 -0
  177. package/dist/wasm/wasm-loader-base.d.ts +33 -0
  178. package/dist/wasm/wasm-types.d.ts +103 -0
  179. package/package.json +60 -0
@@ -0,0 +1,38 @@
1
+ import { DataChunk } from '../../storage/chunk.js';
2
+ import { JoinType } from '../../planner/logical-plan.js';
3
+ import { type ColumnValue } from '../../storage/data-type.js';
4
+ import type { CompiledExpr, EvalValue } from '../execution-types.js';
5
+ type JoinKey = EvalValue | EvalValue[];
6
+ interface JoinRow {
7
+ chunk: DataChunk;
8
+ idx: number;
9
+ key: JoinKey;
10
+ }
11
+ interface RowAdapterColumn {
12
+ get(): ColumnValue;
13
+ }
14
+ interface RowAdapter {
15
+ row: ColumnValue[] | null;
16
+ columns: RowAdapterColumn[];
17
+ setRow(r: ColumnValue[]): void;
18
+ }
19
+ export declare class MergeJoinOperator {
20
+ buildChunks: DataChunk[];
21
+ probeChunks: DataChunk[];
22
+ buildKeyExtractors: CompiledExpr[];
23
+ probeKeyExtractors: CompiledExpr[];
24
+ buildColCount: number;
25
+ probeColCount: number;
26
+ joinType: JoinType;
27
+ conditionEvaluator: CompiledExpr | null;
28
+ constructor(buildChunks: DataChunk[], probeChunks: DataChunk[], buildKeyExtractors: CompiledExpr[], probeKeyExtractors: CompiledExpr[], buildColCount: number, probeColCount: number, joinType?: JoinType, conditionEvaluator?: CompiledExpr | null);
29
+ execute(): Promise<DataChunk[]>;
30
+ _flattenAndExtractKeys(chunks: DataChunk[], extractors: CompiledExpr[]): JoinRow[];
31
+ _compareKeys(k1: JoinKey, k2: JoinKey): number;
32
+ _combineRow(bRow: JoinRow, pRow: JoinRow): ColumnValue[];
33
+ _extractProbeRow(rowObj: JoinRow): ColumnValue[];
34
+ _combineRowWithNulls(rowObj: JoinRow, isBuild: boolean): ColumnValue[];
35
+ _buildOutputChunk(outputRows: ColumnValue[][]): DataChunk | null;
36
+ createAdapter(): RowAdapter;
37
+ }
38
+ export {};
@@ -0,0 +1,28 @@
1
+ import { DataChunk } from '../../storage/chunk.js';
2
+ import type { ColumnValue } from '../../storage/data-type.js';
3
+ import { JoinType } from '../../planner/logical-plan.js';
4
+ import type { CompiledExpr } from '../execution-types.js';
5
+ type JoinRow = ColumnValue[];
6
+ interface RowAdapter {
7
+ chunk: DataChunk;
8
+ setRow(r: JoinRow): void;
9
+ }
10
+ export declare class NestedLoopJoinOperator {
11
+ outerChunks: DataChunk[];
12
+ innerChunks: DataChunk[];
13
+ outerColCount: number;
14
+ innerColCount: number;
15
+ joinType: JoinType;
16
+ conditionEvaluator: CompiledExpr | null;
17
+ constructor(outerChunks: DataChunk[], innerChunks: DataChunk[], outerColCount: number, innerColCount: number, joinType?: JoinType, conditionEvaluator?: CompiledExpr | null);
18
+ execute(): Promise<DataChunk[]>;
19
+ _flattenChunks(chunks: DataChunk[]): JoinRow[];
20
+ _combineRow(outerRow: JoinRow, innerRow: JoinRow): JoinRow;
21
+ _extractOuter(outerRow: JoinRow): JoinRow;
22
+ _outerWithNulls(outerRow: JoinRow): JoinRow;
23
+ _innerWithNulls(innerRow: JoinRow): JoinRow;
24
+ _outerWithMark(outerRow: JoinRow, markValue: boolean): JoinRow;
25
+ _buildOutputChunk(rows: JoinRow[]): DataChunk;
26
+ _createAdapter(): RowAdapter;
27
+ }
28
+ export {};
@@ -0,0 +1,20 @@
1
+ import { DataType } from '../../storage/data-type.js';
2
+ import { DataChunk } from '../../storage/chunk.js';
3
+ import type { BoundExpr, BoundColumnRefNode } from '../../binder/expression-binder.js';
4
+ import type { CompiledExpr, ColumnMapping } from '../execution-types.js';
5
+ interface ParallelDispatchLike {
6
+ canParallelize(op: string, dt: DataType, n: number): boolean;
7
+ }
8
+ export declare class ProjectionOperator {
9
+ expressions: BoundExpr[];
10
+ evaluators: CompiledExpr[];
11
+ resultTypes: DataType[] | null;
12
+ columnMapping: ColumnMapping | null;
13
+ parallelDispatch: ParallelDispatchLike | null;
14
+ colRefIndices: number[];
15
+ constructor(expressions: BoundExpr[], evaluators: CompiledExpr[], resultTypes: DataType[] | null | undefined, columnMapping: (ColumnMapping | null) | undefined, parallelDispatch: ParallelDispatchLike | null);
16
+ init(): Promise<void>;
17
+ process(chunk: DataChunk): Promise<DataChunk>;
18
+ _resolveColIdx(expr: BoundColumnRefNode): number;
19
+ }
20
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { DataChunk } from '../../storage/chunk.js';
2
+ import type { ExecSchema } from '../execution-types.js';
3
+ interface TableStorageLike {
4
+ getSchema(): ExecSchema;
5
+ scan(): AsyncGenerator<DataChunk>;
6
+ scanAll(): Promise<DataChunk[]>;
7
+ rowCount(): number;
8
+ }
9
+ export declare class ScanOperator {
10
+ table: TableStorageLike;
11
+ projectedColumns: number[] | null;
12
+ constructor(table: TableStorageLike, projectedColumns: number[] | null);
13
+ init(): Promise<void>;
14
+ scan(): AsyncGenerator<DataChunk>;
15
+ estimatedRows(): number;
16
+ }
17
+ export {};
@@ -0,0 +1,48 @@
1
+ import { DataChunk } from '../../storage/chunk.js';
2
+ import type { ColumnValue, DataType } from '../../storage/data-type.js';
3
+ import type { CompiledExpr } from '../execution-types.js';
4
+ interface SortKey {
5
+ eval: CompiledExpr;
6
+ direction: string;
7
+ }
8
+ interface SortRow {
9
+ row: ColumnValue[];
10
+ sortKeys: ColumnValue[];
11
+ }
12
+ interface SpillManagerLike {
13
+ appendChunk(id: string, chunk: DataChunk | null): Promise<void>;
14
+ readChunks(id: string): AsyncGenerator<DataChunk>;
15
+ clearAll(): Promise<void>;
16
+ }
17
+ export declare class SortOperator {
18
+ keyExtractors: SortKey[];
19
+ limit: number | null;
20
+ offset: number;
21
+ topN: number | null;
22
+ rows: SortRow[];
23
+ schema: DataType[] | null;
24
+ spillManager: SpillManagerLike;
25
+ runCount: number;
26
+ constructor(keyExtractors: SortKey[], limit: number | null, offset: number, spillManager: SpillManagerLike);
27
+ init(): Promise<void>;
28
+ consume(chunk: DataChunk): Promise<void>;
29
+ spillCurrentRun(): Promise<void>;
30
+ finalize(): Promise<DataChunk[]>;
31
+ chunkToItems(chunk: DataChunk): SortRow[];
32
+ rowsToChunk(items: SortRow[]): DataChunk;
33
+ compareRows(a: SortRow, b: SortRow): number;
34
+ }
35
+ export declare class LimitOperator {
36
+ limit: number;
37
+ offset: number;
38
+ seen: number;
39
+ emitted: number;
40
+ chunks: DataChunk[];
41
+ schema: DataType[] | null;
42
+ done: boolean;
43
+ constructor(limit: number, offset?: number);
44
+ init(): Promise<void>;
45
+ consume(chunk: DataChunk): Promise<void>;
46
+ finalize(): Promise<DataChunk[]>;
47
+ }
48
+ export {};
@@ -0,0 +1,30 @@
1
+ import { DataChunk } from '../../storage/chunk.js';
2
+ import { DataType, type ColumnValue } from '../../storage/data-type.js';
3
+ import type { BoundExpr } from '../../binder/expression-binder.js';
4
+ import type { CompiledExpr, ColumnMapping, EvalValue } from '../execution-types.js';
5
+ interface Accumulator {
6
+ add(val: EvalValue): void;
7
+ result(): ColumnValue;
8
+ }
9
+ interface AggregateDef {
10
+ name: string;
11
+ valueKey: string | null;
12
+ resultType: DataType;
13
+ createAccumulator: () => Accumulator;
14
+ extractValue: CompiledExpr;
15
+ _wasmColIndex?: number;
16
+ _sourceExpr: BoundExpr | null;
17
+ _columnMapping: ColumnMapping;
18
+ }
19
+ export declare class StreamAggregateOperator {
20
+ groupByExtractors: CompiledExpr[];
21
+ groupByTypes: DataType[];
22
+ aggregateDefs: AggregateDef[];
23
+ hasCachedValues: boolean;
24
+ constructor(groupByExtractors: CompiledExpr[], groupByTypes: DataType[], aggregateDefs: AggregateDef[]);
25
+ init(): Promise<void>;
26
+ _tryWasmUngrouped(chunks: DataChunk[]): Promise<DataChunk[] | null>;
27
+ execute(chunks: DataChunk[]): Promise<DataChunk[]>;
28
+ extractGroupKey(chunk: DataChunk, rowIdx: number): string;
29
+ }
30
+ export {};
@@ -0,0 +1,13 @@
1
+ import { DataChunk } from '../../storage/chunk.js';
2
+ import type { DataType } from '../../storage/data-type.js';
3
+ export declare class UnionOperator {
4
+ isAll: boolean;
5
+ seen: Set<string> | null;
6
+ schema: DataType[] | null;
7
+ _legacyChunks: DataChunk[];
8
+ constructor(isAll: boolean);
9
+ init(): Promise<void>;
10
+ process(chunk: DataChunk): Promise<DataChunk>;
11
+ consume(chunk: DataChunk): Promise<void>;
12
+ finalize(): Promise<DataChunk[]>;
13
+ }
@@ -0,0 +1,73 @@
1
+ import { DictionaryColumn } from '../../storage/dictionary-column.js';
2
+ import { Column } from '../../storage/column.js';
3
+ import { DataType } from '../../storage/data-type.js';
4
+ import { DataChunk } from '../../storage/chunk.js';
5
+ import type { BoundExpr } from '../../binder/expression-binder.js';
6
+ import { StageKind } from '../fragment-spec.js';
7
+ declare enum KeyKind {
8
+ INT = "int",
9
+ DICT = "dict"
10
+ }
11
+ interface AggDescriptor {
12
+ op: number;
13
+ colIdx: number;
14
+ }
15
+ interface AggState {
16
+ sums?: Float64Array;
17
+ counts?: Float64Array;
18
+ vals?: Float64Array;
19
+ has?: Uint8Array;
20
+ }
21
+ interface AvgState {
22
+ sum: number;
23
+ count: number;
24
+ }
25
+ type SlotState = number | AvgState | null;
26
+ interface VectorSpecSchemaColumn {
27
+ name: string;
28
+ dataType: DataType;
29
+ tableAlias?: string;
30
+ }
31
+ interface VectorSpecAggregate {
32
+ name: string;
33
+ distinct: boolean;
34
+ args: BoundExpr[];
35
+ }
36
+ interface VectorSpecStage {
37
+ kind: StageKind;
38
+ }
39
+ interface VectorSpec {
40
+ groupBy: BoundExpr[];
41
+ stages: VectorSpecStage[];
42
+ baseSchema: VectorSpecSchemaColumn[];
43
+ aggregates: VectorSpecAggregate[];
44
+ }
45
+ interface PartialGroup {
46
+ key: number | string | null;
47
+ groupValues: (number | string | null)[];
48
+ states: SlotState[];
49
+ }
50
+ export declare function createVectorAggregator(spec: VectorSpec): VectorGroupAggregator | null;
51
+ export declare class VectorGroupAggregator {
52
+ keyKind: KeyKind;
53
+ groupIdx: number;
54
+ aggs: AggDescriptor[];
55
+ capacity: number;
56
+ used: number;
57
+ slotKeys: (number | string | null)[];
58
+ nullSlot: number;
59
+ stringSlots: Map<string, number> | null;
60
+ denseBase: number;
61
+ dense: Int32Array;
62
+ state: AggState[];
63
+ constructor(keyKind: KeyKind, groupIdx: number, aggs: AggDescriptor[]);
64
+ clear(): void;
65
+ get groupCount(): number;
66
+ _allocSlot(key: number | string | null): number;
67
+ _nullSlot(): number;
68
+ _dictRemap(col: DictionaryColumn): Int32Array;
69
+ _ensureDenseRange(chunk: DataChunk, col: Column): boolean;
70
+ consume(chunk: DataChunk): boolean;
71
+ exportPartials(partitionCount: number): PartialGroup[][];
72
+ }
73
+ export {};
@@ -0,0 +1,22 @@
1
+ import { DataChunk } from '../../storage/chunk.js';
2
+ import type { ColumnValue } from '../../storage/data-type.js';
3
+ import type { BoundExpr, BoundWindowNode } from '../../binder/expression-binder.js';
4
+ import type { CompiledExpr, ColumnMapping, ExecSchema, EvalValue } from '../execution-types.js';
5
+ type CompileExpressionFn = (expr: BoundExpr, mapping: ColumnMapping) => CompiledExpr;
6
+ interface OrderKey {
7
+ eval: CompiledExpr;
8
+ direction: string;
9
+ }
10
+ export declare class WindowOperator {
11
+ windowExprs: BoundWindowNode[];
12
+ childSchema: ExecSchema;
13
+ childColumnMapping: ColumnMapping;
14
+ compileExpression: CompileExpressionFn;
15
+ constructor(windowExprs: BoundWindowNode[], childSchema: ExecSchema, childColumnMapping: ColumnMapping, compileExpressionFn: CompileExpressionFn);
16
+ execute(chunks: DataChunk[]): Promise<DataChunk[]>;
17
+ computeWindow(wExpr: BoundWindowNode, allRows: ColumnValue[][], chunks: DataChunk[]): EvalValue[];
18
+ partitionRows(allRows: ColumnValue[][], partitionEvals: CompiledExpr[], chunks: DataChunk[]): number[][];
19
+ sameOrderKey(idxA: number, idxB: number, orderKeys: OrderKey[], chunks: DataChunk[]): boolean;
20
+ compareValues(a: EvalValue, b: EvalValue): number;
21
+ }
22
+ export {};
@@ -0,0 +1,14 @@
1
+ export declare enum PhysicalNodeType {
2
+ TABLE_SCAN = "TableScan",
3
+ FILTER = "Filter",
4
+ PROJECT = "Project",
5
+ HASH_JOIN = "HashJoin",
6
+ HASH_AGGREGATE = "HashAggregate",
7
+ SORT = "Sort",
8
+ LIMIT = "Limit",
9
+ TOP_N = "TopN",
10
+ DISTINCT = "Distinct",
11
+ UNION = "Union",
12
+ MATERIALIZE = "Materialize",
13
+ RESULT_SINK = "ResultSink"
14
+ }
@@ -0,0 +1,28 @@
1
+ import type { Sink, SourceGenerator } from './execution-types.js';
2
+ export interface Pipeline {
3
+ id: number;
4
+ sink: Sink;
5
+ source: SourceGenerator | null;
6
+ dependencies: Set<number>;
7
+ dependents: Set<number>;
8
+ state: 'PENDING' | 'RUNNING' | 'DONE';
9
+ cancelled: boolean;
10
+ }
11
+ export declare class PipelineGraph {
12
+ pipelines: Map<number, Pipeline>;
13
+ nextId: number;
14
+ constructor();
15
+ createPipeline(sink: Sink): number;
16
+ addDependency(pipelineId: number, dependsOnId: number): void;
17
+ setSource(pipelineId: number, sourceGenerator: SourceGenerator): void;
18
+ getReadyPipelines(): Pipeline[];
19
+ markPipelineDone(pipelineId: number): void;
20
+ cancelPipeline(pipelineId: number): void;
21
+ isCancelled(pipelineId: number): boolean;
22
+ }
23
+ export declare class CancelToken {
24
+ cancelled: boolean;
25
+ constructor();
26
+ cancel(): void;
27
+ get isCancelled(): boolean;
28
+ }
@@ -0,0 +1,70 @@
1
+ import { type LogicalPlanNode, type LogicalJoinNode } from '../planner/logical-plan.js';
2
+ import { ResultSink } from './result-sink.js';
3
+ import type { ParallelJoinPrep, MakeBuildSide, MakeProbeOp, FragmentPoolLike as JoinFragmentPoolLike } from './builders/join-builder.js';
4
+ import type { FragmentPoolLike as AggFragmentPoolLike } from './builders/aggregate-builder.js';
5
+ import type { DataChunk } from '../storage/chunk.js';
6
+ import type { DataType } from '../storage/data-type.js';
7
+ import type { BoundAggregateNode, BoundExpr } from '../binder/expression-binder.js';
8
+ import type { CompiledPipeline, ExecSchema, ExecColumn, ColumnMapping } from './execution-types.js';
9
+ interface TableStorageLike {
10
+ rowCount(): number;
11
+ scan(): AsyncGenerator<DataChunk>;
12
+ getSchema(): ExecSchema;
13
+ }
14
+ type BTreeLike = object;
15
+ interface CatalogLike {
16
+ getTableStorage(name: string): TableStorageLike | null;
17
+ getIndexForColumn(table: string, column: string): BTreeLike | null;
18
+ }
19
+ interface TempManagerLike {
20
+ allocate(category: string, label: string): string;
21
+ }
22
+ interface SpillManagerLike {
23
+ appendChunk(id: string, chunk: DataChunk | null): Promise<void>;
24
+ readChunks(id: string): AsyncGenerator<DataChunk>;
25
+ clearAll(): Promise<void>;
26
+ }
27
+ interface StorageBackendLike {
28
+ createTempSpace(): object;
29
+ createPageStore(): object;
30
+ createSpillManager(handle: string): SpillManagerLike;
31
+ }
32
+ type WorkerPoolLike = object;
33
+ type ParallelDispatchLike = object;
34
+ type FragmentPoolLike = JoinFragmentPoolLike & AggFragmentPoolLike;
35
+ type DistributedContextLike = object;
36
+ interface ExecuteResult {
37
+ sink: ResultSink;
38
+ columnNames: string[];
39
+ }
40
+ export declare class QueryExecutor {
41
+ catalog: CatalogLike;
42
+ tempManager: TempManagerLike;
43
+ storageBackend: StorageBackendLike;
44
+ cteResults: Map<string, DataChunk[]>;
45
+ cteDefinitions: Map<string, LogicalPlanNode>;
46
+ workerPool: WorkerPoolLike | null;
47
+ parallelDispatch: ParallelDispatchLike | null;
48
+ fragmentPool: FragmentPoolLike | null;
49
+ _distributedContext: DistributedContextLike | null;
50
+ constructor(catalog: CatalogLike, tempManager: TempManagerLike, storageBackend?: StorageBackendLike | null);
51
+ setParallelContext(workerPool: WorkerPoolLike, parallelDispatch: ParallelDispatchLike, fragmentPool?: FragmentPoolLike | null): void;
52
+ setDistributedContext(ctx: DistributedContextLike): void;
53
+ _shouldParallelize(storage: TableStorageLike): boolean;
54
+ execute(logicalPlan: LogicalPlanNode, outputColumns: ExecColumn[], streaming?: boolean): Promise<ExecuteResult>;
55
+ executeStreaming(logicalPlan: LogicalPlanNode, outputColumns: ExecColumn[]): Promise<ExecuteResult>;
56
+ executePlan(logicalPlan: LogicalPlanNode, streaming?: boolean): Promise<ResultSink>;
57
+ buildPipeline(node: LogicalPlanNode): Promise<CompiledPipeline>;
58
+ resolveProjectedColumnIndexes(storageSchema: ExecSchema, planColumns: ExecColumn[] | null): number[] | null;
59
+ buildSchemaMapping(schema: ExecSchema, alias: string): ColumnMapping;
60
+ findCTEPlan(cteName: string): LogicalPlanNode | null;
61
+ _estimatePlanRows(planNode: LogicalPlanNode): number;
62
+ _executeSubPipeline(compiled: CompiledPipeline): Promise<DataChunk[]>;
63
+ _prepareParallelJoin(node: LogicalJoinNode, buildInput: CompiledPipeline, probeInput: CompiledPipeline, buildNode: LogicalPlanNode, probeNode: LogicalPlanNode, buildKeys: BoundExpr[], probeKeys: BoundExpr[], residualCondition: BoundExpr | null, combinedMapping: ColumnMapping): ParallelJoinPrep | null;
64
+ _runBufferedSerialJoin(makeBuildSide: MakeBuildSide, makeProbeOp: MakeProbeOp, buildChunks: DataChunk[], probeChunks: DataChunk[], node: LogicalJoinNode, probeColCount: number): Promise<DataChunk[]>;
65
+ normalizeExecType(dt: DataType | string): DataType;
66
+ normalizeAggResultType(agg: BoundAggregateNode | {
67
+ name?: string;
68
+ }): DataType;
69
+ }
70
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { DataChunk } from '../storage/chunk.js';
2
+ import type { ColumnValue } from '../storage/data-type.js';
3
+ export type ResultRow = Record<string, ColumnValue>;
4
+ export interface AsyncChunkSource {
5
+ [Symbol.asyncIterator](): AsyncIterator<DataChunk>;
6
+ }
7
+ export declare class QueryResult {
8
+ _columnNames: string[];
9
+ _sink: AsyncChunkSource;
10
+ constructor(columnNames: string[], sink: AsyncChunkSource);
11
+ get columns(): string[];
12
+ toArray(): Promise<ResultRow[]>;
13
+ [Symbol.asyncIterator](): AsyncGenerator<ResultRow>;
14
+ chunks(): AsyncGenerator<DataChunk>;
15
+ }
@@ -0,0 +1,26 @@
1
+ import type { DataChunk } from '../storage/chunk.js';
2
+ import type { Sink } from './execution-types.js';
3
+ export declare class ResultSink implements Sink {
4
+ _streaming: boolean;
5
+ _capacity: number;
6
+ _queue: (DataChunk | undefined)[];
7
+ _head: number;
8
+ _tail: number;
9
+ _count: number;
10
+ _totalRows: number;
11
+ _done: boolean;
12
+ _error: Error | null;
13
+ _producerResolve: (() => void) | null;
14
+ _consumerResolve: (() => void) | null;
15
+ _collected: DataChunk[];
16
+ constructor(streaming?: boolean);
17
+ init(): Promise<void>;
18
+ consume(chunk: DataChunk): Promise<void>;
19
+ finalize(): Promise<void>;
20
+ error(err: Error): void;
21
+ get totalRows(): number;
22
+ get chunks(): DataChunk[];
23
+ _dequeue(): DataChunk | undefined;
24
+ [Symbol.asyncIterator](): AsyncIterator<DataChunk>;
25
+ collect(): Promise<DataChunk[]>;
26
+ }
@@ -0,0 +1,8 @@
1
+ import type { PipelineGraph, Pipeline } from './pipeline.js';
2
+ export declare class TaskScheduler {
3
+ concurrency: number;
4
+ constructor(concurrency?: number);
5
+ schedule(pipelineGraph: PipelineGraph): Promise<void>;
6
+ executePipelines(pipelines: Pipeline[], graph: PipelineGraph): Promise<void>;
7
+ runPipelineSource(pipeline: Pipeline, graph: PipelineGraph): Promise<void>;
8
+ }
@@ -0,0 +1,32 @@
1
+ import { DataChunk } from '../storage/chunk.js';
2
+ import type { AnyColumn } from '../storage/chunk.js';
3
+ import type { BoundExpr } from '../binder/expression-binder.js';
4
+ import { DataType } from '../storage/data-type.js';
5
+ import type { EvalValue, CompiledExpr, ColumnMapping } from './execution-types.js';
6
+ interface VectorResult {
7
+ ref?: boolean;
8
+ colIdx?: number;
9
+ column?: AnyColumn;
10
+ constant?: boolean;
11
+ value?: EvalValue;
12
+ size?: number;
13
+ data?: EvalValue[];
14
+ }
15
+ type VectorFn = (chunk: DataChunk) => VectorResult | null;
16
+ interface BuildRef {
17
+ chunkIdx: number;
18
+ rowIdx: number;
19
+ }
20
+ export declare function compileVectorExpression(expr: BoundExpr | null, columnMapping: ColumnMapping | null): VectorFn | null;
21
+ export declare function vectorGet(result: VectorResult | null, chunk: DataChunk, i: number): EvalValue;
22
+ export declare function vectorizedFilter(chunk: DataChunk, scalarEvalFn: CompiledExpr): {
23
+ sv: Uint32Array;
24
+ count: number;
25
+ };
26
+ export declare function vectorizedHashProbe(probeChunk: DataChunk, probeKeyFn: CompiledExpr, hashTable: Map<string, BuildRef[]>, maxMatches?: number): {
27
+ buildRefs: BuildRef[];
28
+ probeIndices: number[];
29
+ };
30
+ export declare function buildJoinOutputDirect(buildChunks: DataChunk[], buildRefs: BuildRef[], probeChunk: DataChunk, probeIndices: number[], buildColCount: number, probeColCount: number): DataChunk;
31
+ export declare function vectorizedProject(chunk: DataChunk, evaluators: CompiledExpr[], expressions: (BoundExpr | null)[], resultTypes: DataType[] | null): DataChunk;
32
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { BoundExpr } from '../binder/expression-binder.js';
2
+ import type { DataChunk } from '../storage/chunk.js';
3
+ import type { ColumnMapping } from './execution-types.js';
4
+ type VecData = Float64Array | Int32Array;
5
+ export declare function isVectorizableExpr(expr: BoundExpr | null): boolean;
6
+ export declare function evalVectorized(expr: BoundExpr, chunk: DataChunk, columnMapping: ColumnMapping | null, size: number): Promise<VecData | number | null>;
7
+ export {};