@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,43 @@
|
|
|
1
|
+
import { DataChunk } from '../../storage/chunk.js';
|
|
2
|
+
import type { ColumnValue } from '../../storage/data-type.js';
|
|
3
|
+
export declare const StrategyType: {
|
|
4
|
+
HASH: string;
|
|
5
|
+
RANGE: string;
|
|
6
|
+
ROUND_ROBIN: string;
|
|
7
|
+
};
|
|
8
|
+
export type StrategyTypeValue = (typeof StrategyType)[keyof typeof StrategyType];
|
|
9
|
+
export interface HashPartitionOptions {
|
|
10
|
+
seed?: number;
|
|
11
|
+
}
|
|
12
|
+
export type PartitionChunkResult = Map<number, DataChunk>;
|
|
13
|
+
export declare class PartitionStrategy {
|
|
14
|
+
get type(): StrategyTypeValue;
|
|
15
|
+
partitionFor(_key: ColumnValue, _partitionCount: number): number;
|
|
16
|
+
partitionChunk(_chunk: DataChunk, _keyColumnIndex: number, _partitionCount: number): PartitionChunkResult;
|
|
17
|
+
protected _scatterByAssignments(chunk: DataChunk, assignments: Uint32Array, partCount: number): PartitionChunkResult;
|
|
18
|
+
}
|
|
19
|
+
export declare class HashPartitionStrategy extends PartitionStrategy {
|
|
20
|
+
_seed: number;
|
|
21
|
+
constructor(options?: HashPartitionOptions);
|
|
22
|
+
get type(): StrategyTypeValue;
|
|
23
|
+
partitionFor(key: ColumnValue, partitionCount: number): number;
|
|
24
|
+
partitionChunk(chunk: DataChunk, keyColumnIndex: number, partitionCount: number): PartitionChunkResult;
|
|
25
|
+
_normalizeKey(key: ColumnValue): string;
|
|
26
|
+
}
|
|
27
|
+
export declare class RangePartitionStrategy extends PartitionStrategy {
|
|
28
|
+
_boundaries: ColumnValue[];
|
|
29
|
+
constructor(boundaries: ColumnValue[]);
|
|
30
|
+
get type(): StrategyTypeValue;
|
|
31
|
+
get boundaries(): ColumnValue[];
|
|
32
|
+
partitionFor(key: ColumnValue): number;
|
|
33
|
+
partitionChunk(chunk: DataChunk, keyColumnIndex: number, _partitionCount: number): PartitionChunkResult;
|
|
34
|
+
_binarySearch(key: ColumnValue): number;
|
|
35
|
+
_compare(a: ColumnValue, b: ColumnValue): number;
|
|
36
|
+
}
|
|
37
|
+
export declare class RoundRobinPartitionStrategy extends PartitionStrategy {
|
|
38
|
+
get type(): StrategyTypeValue;
|
|
39
|
+
partitionFor(rowIndex: ColumnValue, partitionCount: number): number;
|
|
40
|
+
partitionChunk(chunk: DataChunk, _keyColumnIndex: number, partitionCount: number): PartitionChunkResult;
|
|
41
|
+
}
|
|
42
|
+
declare function murmur3(key: ColumnValue, seed: number): number;
|
|
43
|
+
export { murmur3 };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { LogicalPlanNode, LogicalScanNode, LogicalIndexScanNode, LogicalJoinNode, LogicalExchangeNode, LogicalMergeExchangeNode, LogicalPartialAggregateNode, LogicalFinalAggregateNode } from '../../planner/logical-plan.js';
|
|
2
|
+
import { Fragment, FragmentPlan } from './fragment.js';
|
|
3
|
+
import { ExchangePlacement } from './exchange-placement.js';
|
|
4
|
+
import { PartitionPruner } from '../partition/partition-pruner.js';
|
|
5
|
+
import type { NodeId, PartitionId, FragmentizeContext, DistributedScanSchemaColumn, JoinShuffleKeyIndices, FragmentProcessResult, GatherPlacementResult } from '../distributed-types.js';
|
|
6
|
+
import type { BoundExpr } from '../../binder/expression-binder.js';
|
|
7
|
+
interface ColumnRefLike {
|
|
8
|
+
kind?: string;
|
|
9
|
+
tableAlias?: string;
|
|
10
|
+
columnName?: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
}
|
|
13
|
+
interface NodeLike {
|
|
14
|
+
nodeId: NodeId;
|
|
15
|
+
}
|
|
16
|
+
interface PartitionTableInfoLike {
|
|
17
|
+
partitionCount: number;
|
|
18
|
+
partitionKey: string | null;
|
|
19
|
+
}
|
|
20
|
+
interface PartitionMapLike {
|
|
21
|
+
getTableInfo(tableName: string): PartitionTableInfoLike | null;
|
|
22
|
+
getNodesForPartition(tableName: string, partitionId: PartitionId): NodeId[];
|
|
23
|
+
}
|
|
24
|
+
interface ClusterManagerLike {
|
|
25
|
+
localNode: NodeLike;
|
|
26
|
+
getWorkerNodes(): NodeLike[];
|
|
27
|
+
}
|
|
28
|
+
interface TableStorageLike {
|
|
29
|
+
getSchema(): DistributedScanSchemaColumn[];
|
|
30
|
+
}
|
|
31
|
+
interface CatalogLike {
|
|
32
|
+
getTableStorage(tableName: string): TableStorageLike | null | undefined;
|
|
33
|
+
}
|
|
34
|
+
interface StatisticsEntryLike {
|
|
35
|
+
rowCount?: number;
|
|
36
|
+
avgRowWidth?: number;
|
|
37
|
+
}
|
|
38
|
+
export declare class DistributedPlanner {
|
|
39
|
+
_partitionMap: PartitionMapLike;
|
|
40
|
+
_clusterManager: ClusterManagerLike;
|
|
41
|
+
_exchangePlacement: ExchangePlacement;
|
|
42
|
+
_pruner: PartitionPruner;
|
|
43
|
+
_catalog: CatalogLike | null;
|
|
44
|
+
_fragments: Fragment[];
|
|
45
|
+
constructor(partitionMap: PartitionMapLike, clusterManager: ClusterManagerLike, statisticsMap: Map<string, StatisticsEntryLike>, catalog?: CatalogLike | null);
|
|
46
|
+
fragmentize(logicalPlan: LogicalPlanNode): FragmentPlan;
|
|
47
|
+
_placeGathers(node: LogicalPlanNode): GatherPlacementResult;
|
|
48
|
+
_isPushableSubtree(node: LogicalPlanNode): boolean;
|
|
49
|
+
_findPartitionedScan(node: LogicalPlanNode): LogicalPlanNode | null;
|
|
50
|
+
_buildBroadcastJoin(node: LogicalJoinNode): GatherPlacementResult | null;
|
|
51
|
+
_isShufflePushableJoin(node: LogicalJoinNode): boolean;
|
|
52
|
+
_buildShuffleJoin(node: LogicalJoinNode): GatherPlacementResult | null;
|
|
53
|
+
_extractShuffleKeyIndices(condition: BoundExpr | null, leftSchema: DistributedScanSchemaColumn[], rightSchema: DistributedScanSchemaColumn[]): JoinShuffleKeyIndices | null;
|
|
54
|
+
_colIndexInSchema(ref: ColumnRefLike, schema: DistributedScanSchemaColumn[]): number;
|
|
55
|
+
_isColocatedPushableJoin(node: LogicalJoinNode): boolean;
|
|
56
|
+
_isScanFilterSubtree(node: LogicalPlanNode): boolean;
|
|
57
|
+
_joinOutputSchema(node: LogicalJoinNode): DistributedScanSchemaColumn[];
|
|
58
|
+
_deriveSubtreeSchema(node: LogicalPlanNode): DistributedScanSchemaColumn[];
|
|
59
|
+
_scanOutputSchema(node: LogicalScanNode): DistributedScanSchemaColumn[];
|
|
60
|
+
_processNode(node: LogicalPlanNode, context: FragmentizeContext): FragmentProcessResult;
|
|
61
|
+
_processScan(node: LogicalScanNode | LogicalIndexScanNode, context: FragmentizeContext): FragmentProcessResult;
|
|
62
|
+
_processJoin(node: LogicalJoinNode, context: FragmentizeContext): FragmentProcessResult;
|
|
63
|
+
_processPartialAggregate(node: LogicalPartialAggregateNode, context: FragmentizeContext): FragmentProcessResult;
|
|
64
|
+
_processFinalAggregate(node: LogicalFinalAggregateNode, context: FragmentizeContext): FragmentProcessResult;
|
|
65
|
+
_processExchange(node: LogicalExchangeNode, context: FragmentizeContext): FragmentProcessResult;
|
|
66
|
+
_processMergeExchange(node: LogicalMergeExchangeNode, context: FragmentizeContext): FragmentProcessResult;
|
|
67
|
+
_processGeneric(node: LogicalPlanNode, context: FragmentizeContext): FragmentProcessResult;
|
|
68
|
+
_findFilterAbove(_node: LogicalPlanNode): BoundExpr | null;
|
|
69
|
+
_selectNodesForPartitions(tableName: string, partitionIds: Set<PartitionId>, workerNodes: NodeLike[]): NodeId[];
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LogicalJoinNode, LogicalAggregateNode, LogicalSortNode } from '../../planner/logical-plan.js';
|
|
2
|
+
import type { JoinExchangePlacement, AggregateExchange, SortExchange, JoinShuffleKeys, PartitionTableInfo } from '../distributed-types.js';
|
|
3
|
+
interface PartitionMapLike {
|
|
4
|
+
getTableInfo(table: string): PartitionTableInfo | null;
|
|
5
|
+
}
|
|
6
|
+
interface TableStatisticsLike {
|
|
7
|
+
rowCount: number;
|
|
8
|
+
}
|
|
9
|
+
type StatisticsMapLike = Map<string, TableStatisticsLike>;
|
|
10
|
+
export declare class ExchangePlacement {
|
|
11
|
+
_partitionMap: PartitionMapLike;
|
|
12
|
+
_statisticsMap: StatisticsMapLike;
|
|
13
|
+
constructor(partitionMap: PartitionMapLike, statisticsMap?: StatisticsMapLike);
|
|
14
|
+
determineJoinExchange(joinNode: LogicalJoinNode): JoinExchangePlacement;
|
|
15
|
+
determineAggregateExchange(aggNode: LogicalAggregateNode): AggregateExchange;
|
|
16
|
+
determineSortExchange(sortNode: LogicalSortNode): SortExchange;
|
|
17
|
+
_extractShuffleKeys(joinNode: LogicalJoinNode): JoinShuffleKeys;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
2
|
+
import type { NodeId, FragmentId, ExchangeInput, OutputPartitioning, FragmentDispatchJSON, ExchangeType as ExchangeTypeEnum, FragmentState as FragmentStateEnum } from '../distributed-types.js';
|
|
3
|
+
export declare const ExchangeType: Record<string, ExchangeTypeEnum>;
|
|
4
|
+
export declare const FragmentState: Record<string, FragmentStateEnum>;
|
|
5
|
+
export declare function resetFragmentIdCounter(): void;
|
|
6
|
+
export interface FragmentInit {
|
|
7
|
+
planRoot: LogicalPlanNode;
|
|
8
|
+
targetNodes?: NodeId[];
|
|
9
|
+
exchangeInputs?: ExchangeInput[];
|
|
10
|
+
outputPartitioning?: OutputPartitioning | null;
|
|
11
|
+
estimatedCardinality?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class Fragment {
|
|
14
|
+
fragmentId: FragmentId;
|
|
15
|
+
planRoot: LogicalPlanNode;
|
|
16
|
+
targetNodes: NodeId[];
|
|
17
|
+
exchangeInputs: ExchangeInput[];
|
|
18
|
+
outputPartitioning: OutputPartitioning | null;
|
|
19
|
+
estimatedCardinality: number;
|
|
20
|
+
state: FragmentStateEnum;
|
|
21
|
+
retryCount: number;
|
|
22
|
+
error: string | null;
|
|
23
|
+
assignedNode: NodeId | null;
|
|
24
|
+
constructor({ planRoot, targetNodes, exchangeInputs, outputPartitioning, estimatedCardinality }: FragmentInit);
|
|
25
|
+
isLeaf(): boolean;
|
|
26
|
+
isRoot(): boolean;
|
|
27
|
+
markDispatched(nodeId: NodeId): void;
|
|
28
|
+
markRunning(): void;
|
|
29
|
+
markCompleted(): void;
|
|
30
|
+
markFailed(error: string | null): void;
|
|
31
|
+
markCancelled(): void;
|
|
32
|
+
canRetry(maxRetries: number): boolean;
|
|
33
|
+
toJSON(): FragmentDispatchJSON;
|
|
34
|
+
}
|
|
35
|
+
export declare class FragmentPlan {
|
|
36
|
+
fragments: Fragment[];
|
|
37
|
+
rootFragmentId: FragmentId;
|
|
38
|
+
_fragmentMap: Map<FragmentId, Fragment>;
|
|
39
|
+
constructor(fragments: Fragment[], rootFragmentId: FragmentId);
|
|
40
|
+
getFragment(fragmentId: FragmentId): Fragment | null;
|
|
41
|
+
getRootFragment(): Fragment | null;
|
|
42
|
+
getLeafFragments(): Fragment[];
|
|
43
|
+
topologicalOrder(): Fragment[];
|
|
44
|
+
getReadyFragments(): Fragment[];
|
|
45
|
+
allCompleted(): boolean;
|
|
46
|
+
hasFailed(): boolean;
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DataType } from '../../storage/data-type.js';
|
|
2
|
+
import { Column } from '../../storage/column.js';
|
|
3
|
+
import { DictionaryColumn } from '../../storage/dictionary-column.js';
|
|
4
|
+
import { DataChunk, type AnyColumn } from '../../storage/chunk.js';
|
|
5
|
+
export declare class ChunkCodec {
|
|
6
|
+
encode(chunk: DataChunk): Buffer;
|
|
7
|
+
decode(buffer: Buffer): DataChunk;
|
|
8
|
+
_writeBitmap(buf: Buffer, offset: number, col: AnyColumn, bitmapWords: number): number;
|
|
9
|
+
_readBitmapInto(col: AnyColumn, buf: Buffer, rowCount: number): number;
|
|
10
|
+
_encodeColumn(col: AnyColumn, rowCount: number): Buffer;
|
|
11
|
+
_encodeRegularColumn(col: Column, rowCount: number): Buffer;
|
|
12
|
+
_encodeVarcharColumn(col: Column, rowCount: number): Buffer;
|
|
13
|
+
_encodeDictionaryColumn(col: DictionaryColumn, rowCount: number): Buffer;
|
|
14
|
+
_decodeColumn(buf: Buffer, dataType: DataType, isDictionary: boolean, rowCount: number): AnyColumn;
|
|
15
|
+
_decodeFixedColumn(buf: Buffer, dataType: DataType, rowCount: number): Column;
|
|
16
|
+
_decodeVarcharColumn(buf: Buffer, rowCount: number): Column;
|
|
17
|
+
_decodeDictionaryColumn(buf: Buffer, rowCount: number): DictionaryColumn;
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Agent } from 'http';
|
|
2
|
+
import type { IncomingMessage, ServerResponse, Server, OutgoingHttpHeaders } from 'http';
|
|
3
|
+
import { Transport } from './transport.js';
|
|
4
|
+
import type { NodeId, ChannelId, NodeAddress, ChunkReceivedCallback, PendingChunk, ControlMessage, ControlMessageCallback, FragmentDispatchJSON, FragmentReceivedCallback, NodeRegistration, HeartbeatMessage } from '../distributed-types.js';
|
|
5
|
+
export interface HttpTransportOptions {
|
|
6
|
+
port?: number;
|
|
7
|
+
nodeId?: NodeId | null;
|
|
8
|
+
}
|
|
9
|
+
export type RegisterCallback = (registration: NodeRegistration) => void;
|
|
10
|
+
export type HeartbeatCallback = (message: HeartbeatMessage) => void;
|
|
11
|
+
type BodyCallback = (body: Buffer) => void;
|
|
12
|
+
export declare class HttpTransport extends Transport {
|
|
13
|
+
_port: number;
|
|
14
|
+
_nodeId: NodeId | null;
|
|
15
|
+
_server: Server | null;
|
|
16
|
+
_nodes: Map<NodeId, NodeAddress>;
|
|
17
|
+
_chunkListeners: Map<ChannelId, ChunkReceivedCallback>;
|
|
18
|
+
_pendingChunks: Map<ChannelId, PendingChunk[]>;
|
|
19
|
+
_controlCallbacks: ControlMessageCallback[];
|
|
20
|
+
_fragmentCallbacks: FragmentReceivedCallback[];
|
|
21
|
+
_registerCallbacks: RegisterCallback[];
|
|
22
|
+
_heartbeatCallbacks: HeartbeatCallback[];
|
|
23
|
+
_agents: Map<string, Agent>;
|
|
24
|
+
constructor(options?: HttpTransportOptions);
|
|
25
|
+
start(): Promise<void>;
|
|
26
|
+
stop(): Promise<void>;
|
|
27
|
+
registerNode(nodeId: NodeId, host: string, port: number): void;
|
|
28
|
+
sendChunk(targetNodeId: NodeId, channelId: ChannelId, encodedChunk: Buffer): Promise<void>;
|
|
29
|
+
onChunkReceived(channelId: ChannelId, callback: ChunkReceivedCallback): void;
|
|
30
|
+
removeChunkListener(channelId: ChannelId): void;
|
|
31
|
+
sendFragment(targetNodeId: NodeId, fragment: FragmentDispatchJSON): Promise<void>;
|
|
32
|
+
sendControl(targetNodeId: NodeId, message: ControlMessage): Promise<void>;
|
|
33
|
+
sendRegister(targetNodeId: NodeId, registration: NodeRegistration): Promise<void>;
|
|
34
|
+
onControlMessage(callback: ControlMessageCallback): void;
|
|
35
|
+
onFragmentReceived(callback: FragmentReceivedCallback): void;
|
|
36
|
+
onRegister(callback: RegisterCallback): void;
|
|
37
|
+
onHeartbeat(callback: HeartbeatCallback): void;
|
|
38
|
+
sendHeartbeat(targetNodeId: NodeId, message: HeartbeatMessage): Promise<void>;
|
|
39
|
+
_handleRequest(req: IncomingMessage, res: ServerResponse): void;
|
|
40
|
+
_handleExchangeData(channelId: ChannelId, body: Buffer, req: IncomingMessage, res: ServerResponse): void;
|
|
41
|
+
_handleFragmentExecute(body: Buffer, res: ServerResponse): void;
|
|
42
|
+
_handleControl(body: Buffer, res: ServerResponse): void;
|
|
43
|
+
_handleHeartbeat(body: Buffer, res: ServerResponse): void;
|
|
44
|
+
_handleRegister(body: Buffer, res: ServerResponse): void;
|
|
45
|
+
_collectBody(req: IncomingMessage, callback: BodyCallback): void;
|
|
46
|
+
_post(target: NodeAddress, path: string, body: Buffer, headers?: OutgoingHttpHeaders): Promise<Buffer>;
|
|
47
|
+
_getAgent(target: NodeAddress): Agent;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NodeId, ChannelId, ChunkReceivedCallback, FragmentDispatchJSON, ControlMessage, ControlMessageCallback, FragmentReceivedCallback } from '../distributed-types.js';
|
|
2
|
+
export declare class Transport {
|
|
3
|
+
start(): Promise<void>;
|
|
4
|
+
stop(): Promise<void>;
|
|
5
|
+
sendChunk(targetNodeId: NodeId, channelId: ChannelId, encodedChunk: Buffer): Promise<void>;
|
|
6
|
+
onChunkReceived(channelId: ChannelId, callback: ChunkReceivedCallback): void;
|
|
7
|
+
removeChunkListener(channelId: ChannelId): void;
|
|
8
|
+
sendFragment(targetNodeId: NodeId, fragment: FragmentDispatchJSON): Promise<void>;
|
|
9
|
+
sendControl(targetNodeId: NodeId, message: ControlMessage): Promise<void>;
|
|
10
|
+
onControlMessage(callback: ControlMessageCallback): void;
|
|
11
|
+
onFragmentReceived(callback: FragmentReceivedCallback): void;
|
|
12
|
+
registerNode(nodeId: NodeId, host: string, port: number): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { defaultFunctionRegistry } from '../catalog/function-registry.js';
|
|
2
|
+
import { Table } from '../storage/table.js';
|
|
3
|
+
import { Optimizer } from '../optimizer/optimizer.js';
|
|
4
|
+
import { QueryExecutor } from '../execution/query-executor.js';
|
|
5
|
+
import { QueryResult } from '../execution/query-result.js';
|
|
6
|
+
import { StatisticsCache } from '../catalog/statistics-cache.js';
|
|
7
|
+
import type { LogicalPlanNode } from '../planner/logical-plan.js';
|
|
8
|
+
import { DataFrame } from '../dataframe/dataframe.js';
|
|
9
|
+
import type { Statement, QueryStmt, CreateTableStmtNode, DropTableStmtNode } from '../parser/ast.js';
|
|
10
|
+
import type { BoundQuery, OutputColumn } from '../binder/binder.js';
|
|
11
|
+
import type { Catalog } from '../catalog/catalog.js';
|
|
12
|
+
import type { ColumnSchema, ColumnValue } from '../storage/data-type.js';
|
|
13
|
+
import type { TableStatistics } from '../catalog/statistics.js';
|
|
14
|
+
import type { OptimizationPass } from '../optimizer/pass.js';
|
|
15
|
+
import type { Transport } from '../distributed/transport/transport.js';
|
|
16
|
+
type StatisticsMap = Map<string, TableStatistics>;
|
|
17
|
+
type DDLStmt = CreateTableStmtNode | DropTableStmtNode;
|
|
18
|
+
interface StorageBackendLike {
|
|
19
|
+
createTempSpace(): TempManagerLike;
|
|
20
|
+
createPageStore(handle: string): PageStoreLike;
|
|
21
|
+
}
|
|
22
|
+
interface TempManagerLike {
|
|
23
|
+
allocate(category: string, label: string): string;
|
|
24
|
+
cleanup(): void;
|
|
25
|
+
}
|
|
26
|
+
type PageStoreLike = ConstructorParameters<typeof Table>[2];
|
|
27
|
+
type StorageBackendFactory = (options: QueryEngineOptions) => StorageBackendLike | null | undefined;
|
|
28
|
+
interface QueryEngineOptions {
|
|
29
|
+
storageBackend?: StorageBackendLike;
|
|
30
|
+
statistics?: StatisticsMap | null;
|
|
31
|
+
}
|
|
32
|
+
interface SqlFrame {
|
|
33
|
+
name: string;
|
|
34
|
+
columns: ColumnSchema[];
|
|
35
|
+
plan: LogicalPlanNode;
|
|
36
|
+
cteMap?: Map<string, LogicalPlanNode> | null;
|
|
37
|
+
}
|
|
38
|
+
interface SqlOptions {
|
|
39
|
+
frames?: SqlFrame[];
|
|
40
|
+
}
|
|
41
|
+
interface DistributedClusterConfig {
|
|
42
|
+
nodeId?: string;
|
|
43
|
+
host?: string;
|
|
44
|
+
port?: number;
|
|
45
|
+
role?: string;
|
|
46
|
+
capacity?: number;
|
|
47
|
+
transport?: Transport;
|
|
48
|
+
}
|
|
49
|
+
interface DistributedContext {
|
|
50
|
+
clusterManager: object;
|
|
51
|
+
partitionMap: object;
|
|
52
|
+
transport: Transport;
|
|
53
|
+
coordinator: object;
|
|
54
|
+
localNode: {
|
|
55
|
+
port: number;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
interface DistributedPassEntry {
|
|
59
|
+
method: 'insertPassAfter' | 'registerPass';
|
|
60
|
+
args: [string, OptimizationPass] | [OptimizationPass];
|
|
61
|
+
}
|
|
62
|
+
interface WorkerPoolLike {
|
|
63
|
+
init(): Promise<void>;
|
|
64
|
+
shutdown(): Promise<void>;
|
|
65
|
+
}
|
|
66
|
+
interface FragmentPoolLike {
|
|
67
|
+
close(): Promise<void>;
|
|
68
|
+
}
|
|
69
|
+
interface CompiledDDL {
|
|
70
|
+
ddl: DDLStmt;
|
|
71
|
+
plan?: undefined;
|
|
72
|
+
}
|
|
73
|
+
interface CompiledQuery {
|
|
74
|
+
ddl?: undefined;
|
|
75
|
+
plan: LogicalPlanNode;
|
|
76
|
+
outputColumns: OutputColumn[];
|
|
77
|
+
cteMap: Map<string, LogicalPlanNode>;
|
|
78
|
+
isExplain: boolean;
|
|
79
|
+
isAnalyze: boolean;
|
|
80
|
+
}
|
|
81
|
+
type CompileResult = CompiledDDL | CompiledQuery;
|
|
82
|
+
interface DDLResult {
|
|
83
|
+
rows: Record<string, ColumnValue>[];
|
|
84
|
+
columns: string[];
|
|
85
|
+
message?: string;
|
|
86
|
+
}
|
|
87
|
+
interface RunRowsResult {
|
|
88
|
+
rows: Record<string, ColumnValue>[];
|
|
89
|
+
columns: string[];
|
|
90
|
+
}
|
|
91
|
+
export declare function setDefaultStorageBackend(factory: StorageBackendFactory): void;
|
|
92
|
+
export declare class QueryEngine {
|
|
93
|
+
catalog: Catalog;
|
|
94
|
+
functionRegistry: typeof defaultFunctionRegistry;
|
|
95
|
+
storageBackend: StorageBackendLike;
|
|
96
|
+
tempManager: TempManagerLike;
|
|
97
|
+
executor: QueryExecutor;
|
|
98
|
+
wasmEnabled: boolean;
|
|
99
|
+
_dfIdCounter: number;
|
|
100
|
+
precomputedStats: StatisticsMap | null;
|
|
101
|
+
statsCache: StatisticsCache;
|
|
102
|
+
optimizer: Optimizer;
|
|
103
|
+
_statsCollected?: boolean;
|
|
104
|
+
_distributedPasses?: DistributedPassEntry[];
|
|
105
|
+
_activeCancel?: AbortController | null;
|
|
106
|
+
workerPool?: WorkerPoolLike | null;
|
|
107
|
+
fragmentPool?: FragmentPoolLike | null;
|
|
108
|
+
parallelEnabled?: boolean;
|
|
109
|
+
distributed?: DistributedContext;
|
|
110
|
+
constructor(catalog: Catalog, options?: QueryEngineOptions);
|
|
111
|
+
_nextDfId(): number;
|
|
112
|
+
close(): void;
|
|
113
|
+
collectStatistics(): Promise<StatisticsMap | null>;
|
|
114
|
+
createOptimizer(statistics: StatisticsMap | null): Optimizer;
|
|
115
|
+
parseSQL(sql: string): Statement;
|
|
116
|
+
bind(ast: QueryStmt): BoundQuery;
|
|
117
|
+
plan(boundQuery: BoundQuery): LogicalPlanNode;
|
|
118
|
+
optimize(logicalPlan: LogicalPlanNode): LogicalPlanNode;
|
|
119
|
+
compile(sql: string): Promise<CompileResult>;
|
|
120
|
+
optimizeCTEMap(cteMap: Map<string, LogicalPlanNode>): Map<string, LogicalPlanNode>;
|
|
121
|
+
_applyDistributedPasses(optimizer: Optimizer, passes: DistributedPassEntry[]): void;
|
|
122
|
+
_ensureStatistics(): Promise<void>;
|
|
123
|
+
table(name: string): DataFrame;
|
|
124
|
+
createDataFrame(rows: Record<string, ColumnValue>[] | ColumnValue[][], declaredSchema?: ColumnSchema[] | null): DataFrame;
|
|
125
|
+
sql(sqlString: string, options?: SqlOptions): DataFrame;
|
|
126
|
+
_formatPlan(plan: LogicalPlanNode): Promise<string>;
|
|
127
|
+
_explainPlanResult(plan: LogicalPlanNode): Promise<RunRowsResult>;
|
|
128
|
+
_runPlan(plan: LogicalPlanNode, outputColumns: OutputColumn[], streaming?: boolean, cteMap?: Map<string, LogicalPlanNode> | null): Promise<QueryResult>;
|
|
129
|
+
run(sql: string): Promise<DDLResult | RunRowsResult>;
|
|
130
|
+
cancel(): void;
|
|
131
|
+
executeDDL(ddl: DDLStmt): Promise<DDLResult>;
|
|
132
|
+
executeCreateTable(stmt: CreateTableStmtNode): Promise<DDLResult>;
|
|
133
|
+
createTableAsSelect(tableName: string, query: QueryStmt): Promise<DDLResult>;
|
|
134
|
+
executeDropTable(stmt: DropTableStmtNode): DDLResult;
|
|
135
|
+
stream(sql: string): Promise<DDLResult | RunRowsResult | QueryResult>;
|
|
136
|
+
buildIndexes(): Promise<void>;
|
|
137
|
+
enableWasm(): Promise<void>;
|
|
138
|
+
enableParallel(): Promise<boolean>;
|
|
139
|
+
enableDistributed(clusterConfig?: DistributedClusterConfig): Promise<object>;
|
|
140
|
+
shutdown(): Promise<void>;
|
|
141
|
+
}
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { QueryEngine } from './engine/query-engine.js';
|
|
2
|
+
import { Catalog } from './catalog/catalog.js';
|
|
3
|
+
import type { ColumnSchema, ColumnValue } from './storage/data-type.js';
|
|
4
|
+
export type RowInput = Record<string, ColumnValue> | ColumnValue[];
|
|
5
|
+
type QueryEngineOptions = ConstructorParameters<typeof QueryEngine>[1];
|
|
6
|
+
export type CreateEngineOptions = QueryEngineOptions & {
|
|
7
|
+
catalog?: Catalog;
|
|
8
|
+
};
|
|
9
|
+
export declare function createEngine(options?: CreateEngineOptions): QueryEngine;
|
|
10
|
+
export declare function registerTable(engine: QueryEngine, name: string, rows: RowInput[], declaredSchema?: ColumnSchema[] | null): ColumnSchema[];
|
|
11
|
+
export declare function registerStreamingTable(engine: QueryEngine, name: string, schemaOrBatches: ColumnSchema[] | null | AsyncIterable<RowInput[]>, maybeBatches?: AsyncIterable<RowInput[]>): Promise<ColumnSchema[]>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LogicalPlanNode, LogicalAggregateNode, LogicalPartialAggregateNode, LogicalFinalAggregateNode } from '../../planner/logical-plan.js';
|
|
2
|
+
import { buildFragmentSpec } from '../fragment-spec.js';
|
|
3
|
+
import { DataType } from '../../storage/data-type.js';
|
|
4
|
+
import type { DataChunk } from '../../storage/chunk.js';
|
|
5
|
+
import { BoundExprKind } from '../../binder/expression-binder.js';
|
|
6
|
+
import type { BoundExpr } from '../../binder/expression-binder.js';
|
|
7
|
+
import type { CompiledPipeline, ExecSchema } from '../execution-types.js';
|
|
8
|
+
type BuiltFragmentSpec = NonNullable<ReturnType<typeof buildFragmentSpec>>;
|
|
9
|
+
type FragmentSpec = BuiltFragmentSpec['spec'];
|
|
10
|
+
interface AggDescriptor {
|
|
11
|
+
kind?: BoundExprKind;
|
|
12
|
+
name?: string;
|
|
13
|
+
func?: string;
|
|
14
|
+
distinct?: boolean;
|
|
15
|
+
args?: BoundExpr[];
|
|
16
|
+
outputName?: string;
|
|
17
|
+
}
|
|
18
|
+
interface TableStorageLike {
|
|
19
|
+
scan(): AsyncGenerator<DataChunk>;
|
|
20
|
+
getSchema(): ExecSchema;
|
|
21
|
+
rowCount(): number;
|
|
22
|
+
}
|
|
23
|
+
interface CatalogLike {
|
|
24
|
+
getTableStorage(table: string): TableStorageLike | null;
|
|
25
|
+
}
|
|
26
|
+
export interface FragmentPoolLike {
|
|
27
|
+
runAggregate(spec: FragmentSpec, columnIndexes: number[], chunks: DataChunk[], options: {
|
|
28
|
+
spillDir?: string;
|
|
29
|
+
}): Promise<DataChunk[]>;
|
|
30
|
+
}
|
|
31
|
+
interface TempManagerLike {
|
|
32
|
+
allocate(kind: string, label: string): string;
|
|
33
|
+
}
|
|
34
|
+
interface ExecutorLike {
|
|
35
|
+
buildPipeline(node: LogicalPlanNode): Promise<CompiledPipeline>;
|
|
36
|
+
catalog: CatalogLike;
|
|
37
|
+
tempManager: TempManagerLike;
|
|
38
|
+
fragmentPool: FragmentPoolLike | null;
|
|
39
|
+
normalizeExecType(dt: string): DataType;
|
|
40
|
+
normalizeAggResultType(agg: AggDescriptor): DataType;
|
|
41
|
+
_executeSubPipeline(compiled: CompiledPipeline): Promise<DataChunk[]>;
|
|
42
|
+
}
|
|
43
|
+
export declare function buildAggregate(executor: ExecutorLike, node: LogicalAggregateNode): Promise<CompiledPipeline>;
|
|
44
|
+
export declare function buildPartialAggregate(executor: ExecutorLike, node: LogicalPartialAggregateNode): Promise<CompiledPipeline>;
|
|
45
|
+
export declare function buildFinalAggregate(executor: ExecutorLike, node: LogicalFinalAggregateNode): Promise<CompiledPipeline>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DataChunk } from '../../storage/chunk.js';
|
|
2
|
+
import type { PipelineGraph } from '../pipeline.js';
|
|
3
|
+
import type { ColumnMapping, CompiledPipeline, ExecSchema } from '../execution-types.js';
|
|
4
|
+
export declare function combinedMappingOf(...schemas: ExecSchema[]): ColumnMapping;
|
|
5
|
+
export declare function registerBufferedChild(graph: PipelineGraph, currentPipelineId: number, compiled: CompiledPipeline): DataChunk[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataChunk } from '../../storage/chunk.js';
|
|
2
|
+
import type { ColumnMapping, CompiledPipeline, ExecSchema } from '../execution-types.js';
|
|
3
|
+
import type { LogicalPlanNode, LogicalCTEAnchorNode, LogicalCTEScanNode, LogicalMaterializeNode, LogicalDependentJoinNode } from '../../planner/logical-plan.js';
|
|
4
|
+
interface CTEResult {
|
|
5
|
+
chunks: DataChunk[];
|
|
6
|
+
schema: ExecSchema;
|
|
7
|
+
columnMapping: ColumnMapping;
|
|
8
|
+
}
|
|
9
|
+
interface ExecutorLike {
|
|
10
|
+
buildPipeline(node: LogicalPlanNode): Promise<CompiledPipeline>;
|
|
11
|
+
buildSchemaMapping(schema: ExecSchema, alias: string): ColumnMapping;
|
|
12
|
+
findCTEPlan(name: string): LogicalPlanNode | null;
|
|
13
|
+
cteResults: Map<string, CTEResult>;
|
|
14
|
+
cteDefinitions: Map<string, LogicalPlanNode>;
|
|
15
|
+
}
|
|
16
|
+
export declare function buildCTEAnchor(executor: ExecutorLike, node: LogicalCTEAnchorNode): Promise<CompiledPipeline>;
|
|
17
|
+
export declare function buildCTEScan(executor: ExecutorLike, node: LogicalCTEScanNode): Promise<CompiledPipeline>;
|
|
18
|
+
export declare function buildMaterialize(executor: ExecutorLike, node: LogicalMaterializeNode): Promise<CompiledPipeline>;
|
|
19
|
+
export declare function buildDependentJoin(executor: ExecutorLike, node: LogicalDependentJoinNode): Promise<CompiledPipeline>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { DataChunk } from '../../storage/chunk.js';
|
|
2
|
+
import type { LogicalPlanNode, LogicalExchangeNode, LogicalMergeExchangeNode, LogicalExchangeReceiveNode } from '../../planner/logical-plan.js';
|
|
3
|
+
import type { CompiledPipeline } from '../execution-types.js';
|
|
4
|
+
import type { Transport } from '../../distributed/transport/transport.js';
|
|
5
|
+
interface ExchangeConfig {
|
|
6
|
+
transport: Transport;
|
|
7
|
+
sourceNodes: string[];
|
|
8
|
+
channelId: string;
|
|
9
|
+
exchangeType?: string;
|
|
10
|
+
}
|
|
11
|
+
interface MergeExchangeConfig {
|
|
12
|
+
transport: Transport;
|
|
13
|
+
sourceNodes: string[];
|
|
14
|
+
channelId: string;
|
|
15
|
+
}
|
|
16
|
+
interface DistributedContextLike {
|
|
17
|
+
role: string;
|
|
18
|
+
getExchangeConfig(node: LogicalExchangeNode): ExchangeConfig;
|
|
19
|
+
getMergeExchangeConfig(node: LogicalMergeExchangeNode): MergeExchangeConfig;
|
|
20
|
+
}
|
|
21
|
+
interface ChunkReceiverLike {
|
|
22
|
+
generate(): AsyncGenerator<DataChunk>;
|
|
23
|
+
cleanup(): void;
|
|
24
|
+
}
|
|
25
|
+
interface ExecutorLike {
|
|
26
|
+
buildPipeline(node: LogicalPlanNode): Promise<CompiledPipeline>;
|
|
27
|
+
_distributedContext: DistributedContextLike | null;
|
|
28
|
+
_exchangeReceivers: Map<number, ChunkReceiverLike> | null;
|
|
29
|
+
}
|
|
30
|
+
export declare function buildExchange(executor: ExecutorLike, node: LogicalExchangeNode): Promise<CompiledPipeline>;
|
|
31
|
+
export declare function buildMergeExchange(executor: ExecutorLike, node: LogicalMergeExchangeNode): Promise<CompiledPipeline>;
|
|
32
|
+
export declare function buildExchangeReceive(executor: ExecutorLike, node: LogicalExchangeReceiveNode): Promise<CompiledPipeline>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { LogicalJoinNode, LogicalPlanNode } from '../../planner/logical-plan.js';
|
|
2
|
+
import { HashJoinBuild, HashJoinProbe } from '../operators/hash-join.js';
|
|
3
|
+
import type { Stage, JoinSpec } from '../fragment-spec.js';
|
|
4
|
+
import { DataType } from '../../storage/data-type.js';
|
|
5
|
+
import type { BoundExpr } from '../../binder/expression-binder.js';
|
|
6
|
+
import type { ColumnInfo } from '../../binder/scope.js';
|
|
7
|
+
import type { DataChunk } from '../../storage/chunk.js';
|
|
8
|
+
import type { ColumnMapping, CompiledPipeline, ExecSchema } from '../execution-types.js';
|
|
9
|
+
type SpillManagerLike = ConstructorParameters<typeof HashJoinBuild>[3];
|
|
10
|
+
export type MakeBuildSide = () => HashJoinBuild;
|
|
11
|
+
export type MakeProbeOp = (buildSide: HashJoinBuild) => HashJoinProbe;
|
|
12
|
+
interface JoinSideSpec {
|
|
13
|
+
schema: ExecSchema;
|
|
14
|
+
baseSchema: ExecSchema;
|
|
15
|
+
stages: Stage[];
|
|
16
|
+
}
|
|
17
|
+
export interface JoinSide {
|
|
18
|
+
spec: JoinSideSpec;
|
|
19
|
+
storage: TableStorageLike | null;
|
|
20
|
+
columnIndexes: number[] | null;
|
|
21
|
+
}
|
|
22
|
+
export interface ParallelJoinPrep {
|
|
23
|
+
spec: JoinSpec;
|
|
24
|
+
buildSide: JoinSide;
|
|
25
|
+
probeSide: JoinSide;
|
|
26
|
+
}
|
|
27
|
+
interface JoinOutputTypes {
|
|
28
|
+
build: DataType[];
|
|
29
|
+
probe: DataType[];
|
|
30
|
+
}
|
|
31
|
+
interface JoinStreamSide {
|
|
32
|
+
chunks: DataChunk[];
|
|
33
|
+
columnIndexes: number[] | null;
|
|
34
|
+
}
|
|
35
|
+
export interface FragmentPoolLike {
|
|
36
|
+
runJoinStream(spec: JoinSpec, buildSide: JoinStreamSide, probeSide: JoinStreamSide, outputTypes: JoinOutputTypes): AsyncGenerator<DataChunk>;
|
|
37
|
+
}
|
|
38
|
+
interface TempManagerLike {
|
|
39
|
+
allocate(category: string, label: string): string;
|
|
40
|
+
}
|
|
41
|
+
interface StorageBackendLike {
|
|
42
|
+
createSpillManager(handle: string): SpillManagerLike;
|
|
43
|
+
}
|
|
44
|
+
interface TableStorageLike {
|
|
45
|
+
scan(): AsyncGenerator<DataChunk>;
|
|
46
|
+
getSchema(): ExecSchema;
|
|
47
|
+
}
|
|
48
|
+
interface CatalogLike {
|
|
49
|
+
getTableStorage(table: string): TableStorageLike | null;
|
|
50
|
+
}
|
|
51
|
+
interface ExecutorLike {
|
|
52
|
+
buildPipeline(node: LogicalPlanNode): Promise<CompiledPipeline>;
|
|
53
|
+
buildSchemaMapping(schema: ExecSchema, alias: string): ColumnMapping;
|
|
54
|
+
resolveProjectedColumnIndexes(storageSchema: ExecSchema, planColumns: ColumnInfo[] | null): number[] | null;
|
|
55
|
+
catalog: CatalogLike;
|
|
56
|
+
tempManager: TempManagerLike;
|
|
57
|
+
storageBackend: StorageBackendLike;
|
|
58
|
+
fragmentPool: FragmentPoolLike | null;
|
|
59
|
+
_estimatePlanRows(node: LogicalPlanNode): number;
|
|
60
|
+
_prepareParallelJoin(node: LogicalJoinNode, buildInput: CompiledPipeline, probeInput: CompiledPipeline, buildNode: LogicalPlanNode, probeNode: LogicalPlanNode, buildKeys: BoundExpr[], probeKeys: BoundExpr[], residualCondition: BoundExpr | null, combinedMapping: ColumnMapping): ParallelJoinPrep | null;
|
|
61
|
+
_runBufferedSerialJoin(makeBuildSide: MakeBuildSide, makeProbeOp: MakeProbeOp, buildChunks: DataChunk[], probeChunks: DataChunk[], node: LogicalJoinNode, probeColCount: number): Promise<DataChunk[]>;
|
|
62
|
+
_executeSubPipeline(compiled: CompiledPipeline): Promise<DataChunk[]>;
|
|
63
|
+
}
|
|
64
|
+
export declare function buildJoin(executor: ExecutorLike, node: LogicalJoinNode): Promise<CompiledPipeline>;
|
|
65
|
+
export declare function prepareParallelJoin(executor: ExecutorLike, node: LogicalJoinNode, buildInput: CompiledPipeline, probeInput: CompiledPipeline, buildNode: LogicalPlanNode, probeNode: LogicalPlanNode, buildKeys: BoundExpr[], probeKeys: BoundExpr[], residualCondition: BoundExpr | null, combinedMapping: ColumnMapping): ParallelJoinPrep | null;
|
|
66
|
+
export declare function runBufferedSerialJoin(makeBuildSide: MakeBuildSide, makeProbeOp: MakeProbeOp, buildChunks: DataChunk[], probeChunks: DataChunk[], node: LogicalJoinNode, probeColCount: number): Promise<DataChunk[]>;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { FilterOperator } from '../operators/filter.js';
|
|
2
|
+
import { SortOperator } from '../operators/sort.js';
|
|
3
|
+
import type { DataType } from '../../storage/data-type.js';
|
|
4
|
+
import type { ColumnMapping, CompiledPipeline, ExecSchema } from '../execution-types.js';
|
|
5
|
+
import type { LogicalPlanNode, LogicalFilterNode, LogicalProjectNode, LogicalSortNode, LogicalTopNNode, LogicalLimitNode, LogicalDistinctNode, LogicalUnionNode, LogicalWindowNode } from '../../planner/logical-plan.js';
|
|
6
|
+
type ParallelDispatchLike = ConstructorParameters<typeof FilterOperator>[3];
|
|
7
|
+
type SpillManagerLike = ConstructorParameters<typeof SortOperator>[3];
|
|
8
|
+
interface TempManagerLike {
|
|
9
|
+
allocate(category: string, label: string): string;
|
|
10
|
+
}
|
|
11
|
+
interface StorageBackendLike {
|
|
12
|
+
createSpillManager(handle: string): SpillManagerLike;
|
|
13
|
+
}
|
|
14
|
+
interface ExecutorLike {
|
|
15
|
+
buildPipeline(node: LogicalPlanNode): Promise<CompiledPipeline>;
|
|
16
|
+
buildSchemaMapping(schema: ExecSchema, alias: string): ColumnMapping;
|
|
17
|
+
normalizeExecType(dt: DataType | string): DataType;
|
|
18
|
+
parallelDispatch: ParallelDispatchLike;
|
|
19
|
+
tempManager: TempManagerLike;
|
|
20
|
+
storageBackend: StorageBackendLike;
|
|
21
|
+
}
|
|
22
|
+
export declare function buildFilter(executor: ExecutorLike, node: LogicalFilterNode): Promise<CompiledPipeline>;
|
|
23
|
+
export declare function buildProject(executor: ExecutorLike, node: LogicalProjectNode): Promise<CompiledPipeline>;
|
|
24
|
+
export declare function buildSort(executor: ExecutorLike, node: LogicalSortNode): Promise<CompiledPipeline>;
|
|
25
|
+
export declare function buildTopN(executor: ExecutorLike, node: LogicalTopNNode): Promise<CompiledPipeline>;
|
|
26
|
+
export declare function buildLimit(executor: ExecutorLike, node: LogicalLimitNode): Promise<CompiledPipeline>;
|
|
27
|
+
export declare function buildDistinct(executor: ExecutorLike, node: LogicalDistinctNode): Promise<CompiledPipeline>;
|
|
28
|
+
export declare function buildUnion(executor: ExecutorLike, node: LogicalUnionNode): Promise<CompiledPipeline>;
|
|
29
|
+
export declare function buildWindow(executor: ExecutorLike, node: LogicalWindowNode): Promise<CompiledPipeline>;
|
|
30
|
+
export {};
|