Class: VariableMapper
Defined in: packages/core/src/visitors/variable-mapper.ts:43
Translates identifiers used in the query plan into numerical indices. The executor may then represent a scope using an array instead of a map.
Extended by
Implements
PlanVisitor<void,VariableMapperCtx>
Constructors
Constructor
new VariableMapper(
vmap):VariableMapper
Defined in: packages/core/src/visitors/variable-mapper.ts:44
Parameters
| Parameter | Type | Description |
|---|---|---|
vmap | Record<string, PlanVisitor<void, VariableMapperCtx>> | Per-language visitor map used for recursive descent. |
Returns
VariableMapper
Properties
vmap
protectedvmap:Record<string,PlanVisitor<void,VariableMapperCtx>>
Defined in: packages/core/src/visitors/variable-mapper.ts:46
Per-language visitor map used for recursive descent.
Methods
mapVariables()
mapVariables(
plan):VariableMapperCtx
Defined in: packages/core/src/visitors/variable-mapper.ts:54
Traverses plan and returns a fully populated VariableMapperCtx in which every
named identifier has been replaced with a numeric index. The resulting context is
passed to Executor.execute to drive array-based scope lookups.
Parameters
| Parameter | Type |
|---|---|
plan | PlanOperator |
Returns
removeFromCurrScope()
protectedremoveFromCurrScope(attr,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:107
Removes an identifier from the current scope. For example, a projection may drop an attribute, and it should no longer be visible in the current scope. Instead, a previously shadowed variable may now be visible.
Parameters
| Parameter | Type |
|---|---|
attr | ASTIdentifier |
ctx | VariableMapperCtx |
Returns
void
setTranslations()
protectedsetTranslations(operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:141
Snapshots the current scope stack into ctx.translations for operator, recording
both the operator's own scope (top of stack) and the merged external view.
Parameters
| Parameter | Type |
|---|---|
operator | PlanOperator |
ctx | VariableMapperCtx |
Returns
void
translate()
protectedtranslate(attr,ctx,depth?):ASTIdentifier
Defined in: packages/core/src/visitors/variable-mapper.ts:75
Translates an identifier into a numerical index. Sometimes it may be necessary to specify depth as 1 and shadow existing translations. Other times, it may be necessary to first add new scope and THEN set depth to 1 (and force a new translation). For example, when a projection writes new content into an existing variable, this might conflict with, e.g., projection concats upstream that depend on that variable
Parameters
| Parameter | Type | Default value |
|---|---|---|
attr | ASTIdentifier | undefined |
ctx | VariableMapperCtx | undefined |
depth | number | ctx.scopeStack.length |
Returns
translateArray()
protectedtranslateArray(array,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:112
Translates each ASTIdentifier in array in place; recurses into operators.
Parameters
| Parameter | Type |
|---|---|
array | OpOrId[] |
ctx | VariableMapperCtx |
Returns
void
union()
protectedunion(a, ...bs):VariableMap
Defined in: packages/core/src/visitors/variable-mapper.ts:124
Returns a new VariableMap containing all entries from a and every map in bs, with later maps winning on collision.
Parameters
| Parameter | Type |
|---|---|
a | VariableMap |
...bs | VariableMap[] |
Returns
visitAggregate()
visitAggregate(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:340
Parameters
| Parameter | Type |
|---|---|
operator | AggregateCall |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitBidirectionalRecursion()
visitBidirectionalRecursion(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:483
Parameters
| Parameter | Type |
|---|---|
operator | BidirectionalRecursion |
ctx | VariableMapperCtx |
Returns
void
Implementation of
PlanVisitor.visitBidirectionalRecursion
visitCalculation()
visitCalculation(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:238
Parameters
| Parameter | Type |
|---|---|
operator | Calculation |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitCartesianProduct()
visitCartesianProduct(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:266
Parameters
| Parameter | Type |
|---|---|
operator | CartesianProduct |
ctx | VariableMapperCtx |
Returns
void
Implementation of
PlanVisitor.visitCartesianProduct
visitConditional()
visitConditional(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:245
Parameters
| Parameter | Type |
|---|---|
operator | Conditional |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitDifference()
visitDifference(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:400
Parameters
| Parameter | Type |
|---|---|
operator | Difference |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitDistinct()
visitDistinct(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:403
Parameters
| Parameter | Type |
|---|---|
operator | Distinct |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitFnCall()
visitFnCall(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:224
Parameters
| Parameter | Type |
|---|---|
operator | FnCall |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitGroupBy()
visitGroupBy(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:353
Parameters
| Parameter | Type |
|---|---|
operator | GroupBy |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitIndexedRecursion()
visitIndexedRecursion(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:463
Parameters
| Parameter | Type |
|---|---|
operator | IndexedRecursion |
ctx | VariableMapperCtx |
Returns
void
Implementation of
PlanVisitor.visitIndexedRecursion
visitIndexScan()
visitIndexScan(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:456
Parameters
| Parameter | Type |
|---|---|
operator | IndexScan |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitIntersection()
visitIntersection(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:397
Parameters
| Parameter | Type |
|---|---|
operator | Intersection |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitItemFnSource()
visitItemFnSource(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:421
Parameters
| Parameter | Type |
|---|---|
operator | ItemFnSource |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitItemSource()
visitItemSource(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:221
Parameters
| Parameter | Type |
|---|---|
operator | ItemSource |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitJoin()
visitJoin(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:281
Parameters
| Parameter | Type |
|---|---|
operator | Join |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitLimit()
visitLimit(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:373
Parameters
| Parameter | Type |
|---|---|
operator | Limit |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitLiteral()
visitLiteral(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:235
Parameters
| Parameter | Type |
|---|---|
operator | Literal |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitMapFromItem()
visitMapFromItem(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:315
Parameters
| Parameter | Type |
|---|---|
operator | MapFromItem |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitMapToItem()
visitMapToItem(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:309
Parameters
| Parameter | Type |
|---|---|
operator | MapToItem |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitNullSource()
visitNullSource(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:417
Parameters
| Parameter | Type |
|---|---|
operator | NullSource |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitOrderBy()
visitOrderBy(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:329
Parameters
| Parameter | Type |
|---|---|
operator | OrderBy |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitProjection()
visitProjection(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:159
Parameters
| Parameter | Type |
|---|---|
operator | Projection |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitProjectionConcat()
visitProjectionConcat(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:287
Parameters
| Parameter | Type |
|---|---|
operator | ProjectionConcat |
ctx | VariableMapperCtx |
Returns
void
Implementation of
PlanVisitor.visitProjectionConcat
visitProjectionIndex()
visitProjectionIndex(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:321
Parameters
| Parameter | Type |
|---|---|
operator | ProjectionIndex |
ctx | VariableMapperCtx |
Returns
void
Implementation of
PlanVisitor.visitProjectionIndex
visitQuantifier()
visitQuantifier(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:452
Parameters
| Parameter | Type |
|---|---|
operator | Quantifier |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitRecursion()
visitRecursion(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:150
Parameters
| Parameter | Type |
|---|---|
operator | Recursion |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitSelection()
visitSelection(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:206
Parameters
| Parameter | Type |
|---|---|
operator | Selection |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitSetOp()
protectedvisitSetOp(operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:377
Parameters
| Parameter | Type |
|---|---|
operator | SetOperator |
ctx | VariableMapperCtx |
Returns
void
visitTupleFnSource()
visitTupleFnSource(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:432
Parameters
| Parameter | Type |
|---|---|
operator | TupleFnSource |
ctx | VariableMapperCtx |
Returns
void
Implementation of
PlanVisitor.visitTupleFnSource
visitTupleSource()
visitTupleSource(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:211
Parameters
| Parameter | Type |
|---|---|
operator | TupleSource |
ctx | VariableMapperCtx |
Returns
void
Implementation of
visitUnion()
visitUnion(
operator,ctx):void
Defined in: packages/core/src/visitors/variable-mapper.ts:394
Parameters
| Parameter | Type |
|---|---|
operator | Union |
ctx | VariableMapperCtx |
Returns
void