|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.relopt.RelOptRule net.sf.farrago.fennel.rel.FennelNestedLoopJoinRule
public class FennelNestedLoopJoinRule
FennelNestedLoopJoinRule is a rule for converting a JoinRel
with a
join condition into a FennelNestedLoopJoinRel
. The nested loop join
is executed by creating a temporary index on the right join input and using
join keys from the left input to do lookups against that index.
Any sargable join predicates that aren't part of the index lookup are
processed by a FennelReshapeRel
. And then finally, any remaining join
predicates are processed by a Calc node.
Field Summary | |
---|---|
static FennelNestedLoopJoinRule |
instance
|
Fields inherited from class org.eigenbase.relopt.RelOptRule |
---|
ANY, description, operands |
Constructor Summary | |
---|---|
private |
FennelNestedLoopJoinRule()
Creates a FennelNestedLoopJoinRule. |
Method Summary | |
---|---|
private RelNode |
convertInput(RelTraitSet origTraits,
RelNode inputRel)
Converts an input so its traits include FENNEL_EXEC_CONVENTION |
private void |
createJoinKeyParameters(FennelRelImplementor implementor,
List<Integer> joinKeys,
Map<Integer,FennelRelParamId> joinKeyParamMap)
Creates a new dynamic parameter for each new join key encountered |
private RelNode |
createNestedLoopRel(JoinRel origJoinRel,
RelNode leftRel,
RelNode rightRel,
boolean swapped,
List<Integer> outputProj,
JoinRelType joinType,
List<Integer> indexCols,
List<Integer> indexOperands,
CompOperatorEnum indexOp,
List<Integer> filterCol,
List<Integer> filterOperand,
CompOperatorEnum filterOp,
RexNode residualCondition)
Creates a nested loop join tree with the appropriate inputs. |
private FennelReshapeRel |
createReshapeRel(RelNode leftRel,
RelNode reshapeInput,
Map<Integer,FennelRelParamId> joinKeyParamMap,
List<Integer> filterCols,
List<Integer> filterOperands,
CompOperatorEnum filterOp,
List<Integer> residualRefs,
RexNode residualCondition,
Map<Integer,Integer> residualRefMap)
Creates a FennelReshapeRel for applying simple join filters that can't be applied as part of the temp index lookup |
private RelNode |
createResidualFilter(RelDataTypeField[] joinFields,
int nLeftFields,
RelNode filterInput,
RexNode residualCondition,
RelNode rightRel,
Map<Integer,Integer> residualRefMap)
Creates RelNodes to apply remaining filters |
private RelNode |
createSecondInput(RelNode leftRel,
RelNode rightRel,
List<Integer> indexCols,
List<Integer> indexOperands,
CompOperatorEnum indexOp,
Map<Integer,FennelRelParamId> joinKeyParamMap,
FennelRelParamId rootPageIdParamId,
List<Integer> filterCol,
List<Integer> filterOperand,
CompOperatorEnum filterOp,
List<Integer> residualRefs,
RexNode residualCondition)
Creates the second input into the nested loop join tree that processes the RHS input. |
private FennelTempIdxSearchRel |
createTempIdxLookup(RelNode rightRel,
List<Integer> indexCols,
List<Integer> indexOperands,
CompOperatorEnum indexOp,
Map<Integer,FennelRelParamId> joinKeyParamMap,
FennelRelParamId rootPageIdParamId)
Creates a temporary index lookup RelNode |
private RelNode |
createThirdInput(RelNode rightRel,
List<Integer> indexCols,
FennelRelParamId rootPageIdParamId)
Creates the third input into the nested loop join, which builds the temporary index on the right join input |
private void |
findLeftInputRefs(RexNode residualCondition,
int nLeftFields,
List<Integer> leftInputRefs)
Locates all references to the left input in an expression representing the portion of the join condition that must be processed by a Calc node |
CallingConvention |
getOutConvention()
Returns the calling convention of the result of firing this rule, null if not known. |
private RexNode |
getPredicates(RelNode[] joinInputs,
RexNode joinCondition,
List<Integer> indexCols,
List<Integer> indexOperands,
List<CompOperatorEnum> indexOp,
List<Integer> filterCol,
List<Integer> filterOperand,
List<CompOperatorEnum> filterOp,
List<Integer> outputProj)
Locates from the join condition all equi-join predicates and a single range predicate for use with a temporary index and then if possible, an additional range predicate for a FennelReshapeRel |
private void |
mapSqlOpToCompOp(List<SqlOperator> sqlOpList,
List<CompOperatorEnum> compOpList)
|
void |
onMatch(RelOptRuleCall call)
Receives notification about a rule match. |
Methods inherited from class org.eigenbase.relopt.RelOptRule |
---|
convert, equals, equals, getOperand, getOperands, getOutTrait, hashCode, matches, mergeTraitsAndConvert, mergeTraitsAndConvert, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final FennelNestedLoopJoinRule instance
Constructor Detail |
---|
private FennelNestedLoopJoinRule()
Method Detail |
---|
public CallingConvention getOutConvention()
RelOptRule
getOutConvention
in class RelOptRule
public void onMatch(RelOptRuleCall call)
RelOptRule
call.rels
holds the set of relational
expressions which match the operands to the rule;
call.rels[0]
is the root expression.
Typically a rule would check that the nodes are valid matches, creates
a new expression, then calls back RelOptRuleCall.transformTo(org.eigenbase.rel.RelNode)
to
register the expression.
onMatch
in class RelOptRule
call
- Rule callRelOptRule.matches(RelOptRuleCall)
private RelNode createNestedLoopRel(JoinRel origJoinRel, RelNode leftRel, RelNode rightRel, boolean swapped, List<Integer> outputProj, JoinRelType joinType, List<Integer> indexCols, List<Integer> indexOperands, CompOperatorEnum indexOp, List<Integer> filterCol, List<Integer> filterOperand, CompOperatorEnum filterOp, RexNode residualCondition)
In the new tree, the first input is the left join input. The left join input is assumed to have been casted, as needed, to match the right join input.
The right input does all the necessary lookups and filtering on the right input by reading dynamic parameters corresponding to the left input.
An optional third input creates the temporary index used in join lookups if a temporary index is to be used
origJoinRel
- original join treeleftRel
- left input into the new joinrightRel
- right input into the new joinswapped
- true if the original inputs were swappedoutputProj
- required projection of join result (post-swap, if
inputs have been swapped)joinType
- join typeindexCols
- list of column offsets from the RHS input that are to be
indexedindexOperands
- list of column offsets from the LHS input that will
be used as index lookup keysindexOp
- the operator to be used in the index lookupfilterCol
- the column offset from the RHS input that can be applied
in FennelReshapeRelfilterOperand
- the LHS input that filterCol is compared againstfilterOp
- comparison operator that will be applied in
FennelReshapeRelresidualCondition
- remaining filter that must be applied in a Calc
node
private RexNode getPredicates(RelNode[] joinInputs, RexNode joinCondition, List<Integer> indexCols, List<Integer> indexOperands, List<CompOperatorEnum> indexOp, List<Integer> filterCol, List<Integer> filterOperand, List<CompOperatorEnum> filterOp, List<Integer> outputProj)
joinInputs
- join inputsjoinCondition
- the join conditionindexCols
- returns list of column offsets from the right join input
that are to be indexedindexOperands
- returns list of column offsets from the left join
input that will be used as index lookup keysindexOp
- returns the operator to be used in the index lookupfilterCol
- returns the column offset corresponding to RHS input
that can be filtered in FennelReshapeRelfilterOperand
- returns the column offset corresponding to LHS input
that filterCol is compared againstfilterOp
- returns the comparison operator that will be applied in
FennelReshapeRel
private void mapSqlOpToCompOp(List<SqlOperator> sqlOpList, List<CompOperatorEnum> compOpList)
private RelNode convertInput(RelTraitSet origTraits, RelNode inputRel)
origTraits
- traits of the original inputinputRel
- the input
private void createJoinKeyParameters(FennelRelImplementor implementor, List<Integer> joinKeys, Map<Integer,FennelRelParamId> joinKeyParamMap)
implementor
- FennelRelImplementorjoinKeys
- list of join keys for which we want to create dynamic
parameters; if a dynamic parameter has already been created for a key,
don't create another onejoinKeyParamMap
- mapping from join keys to dynamic parameters; used
to keep track of which keys already have corresponding dynamic parametersprivate void findLeftInputRefs(RexNode residualCondition, int nLeftFields, List<Integer> leftInputRefs)
residualCondition
- remaining join condition to be processed by Calc
nodenLeftFields
- number of fields in the left join inputleftInputRefs
- list of column offsets corresponding to left input
referencesprivate RelNode createSecondInput(RelNode leftRel, RelNode rightRel, List<Integer> indexCols, List<Integer> indexOperands, CompOperatorEnum indexOp, Map<Integer,FennelRelParamId> joinKeyParamMap, FennelRelParamId rootPageIdParamId, List<Integer> filterCol, List<Integer> filterOperand, CompOperatorEnum filterOp, List<Integer> residualRefs, RexNode residualCondition)
leftRel
- left input into the new joinrightRel
- right input into the new joinindexCols
- list of column offsets from the RHS input that are to be
indexedindexOperands
- list of column offsets from the LHS input that will
be used as index lookup keysindexOp
- the operator to be used in the index lookupjoinKeyParamMap
- mapping from LHS inputs to dynamic parametersrootPageIdParamId
- dynamic parameter corresponding to the
rootPageId of the temp indexfilterCol
- the column offset from the RHS input that can be applied
in FennelReshapeRelfilterOperand
- the LHS input that filterCol is compared againstfilterOp
- comparison operator that will be applied in
FennelReshapeRelresidualRefs
- LHS inputs that must be processed in the Calc noderesidualCondition
- remaining filter that must be applied in a Calc
node
private FennelTempIdxSearchRel createTempIdxLookup(RelNode rightRel, List<Integer> indexCols, List<Integer> indexOperands, CompOperatorEnum indexOp, Map<Integer,FennelRelParamId> joinKeyParamMap, FennelRelParamId rootPageIdParamId)
rightRel
- right input into the new joinindexCols
- list of column offsets from the RHS input that are to be
indexedindexOperands
- list of column offsets from the LHS input that will
be used as index lookup keysindexOp
- the operator to be used in the index lookupjoinKeyParamMap
- mapping from LHS inputs to dynamic parametersrootPageIdParamId
- dynamic parameter corresponding to the
rootPageId of the temp index
private FennelReshapeRel createReshapeRel(RelNode leftRel, RelNode reshapeInput, Map<Integer,FennelRelParamId> joinKeyParamMap, List<Integer> filterCols, List<Integer> filterOperands, CompOperatorEnum filterOp, List<Integer> residualRefs, RexNode residualCondition, Map<Integer,Integer> residualRefMap)
leftRel
- left join inputreshapeInput
- input into FennelReshapeReljoinKeyParamMap
- mapping from LHS inputs to dynamic parametersfilterCols
- the column offset from the RHS input that can be
applied in FennelReshapeRelfilterOperands
- the LHS input that filterCol is compared againstfilterOp
- comparison operator that will be applied in
FennelReshapeRelresidualRefs
- LHS inputs that must be processed in Calc noderesidualCondition
- remaining filter that must be applied in a Calc
noderesidualRefMap
- map used to keep track of where each residual
reference will appear in the output for the ReshapeRel; the map is
populated within this method
private RelNode createResidualFilter(RelDataTypeField[] joinFields, int nLeftFields, RelNode filterInput, RexNode residualCondition, RelNode rightRel, Map<Integer,Integer> residualRefMap)
joinFields
- fields from join of the left and right inputsnLeftFields
- number of fields in the left inputfilterInput
- input to be filteredresidualCondition
- filter to be appliedrightRel
- right join inputresidualRefMap
- map used to keep track of where each residual
reference will appear in the output for the ReshapeRel
private RelNode createThirdInput(RelNode rightRel, List<Integer> indexCols, FennelRelParamId rootPageIdParamId)
rightRel
- right join inputindexCols
- columns to be indexedrootPageIdParamId
- dynamic parameter corresponding to the root of
the temporary index
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |