public class LoptSemiJoinOptimizer extends Object
| Modifier and Type | Class and Description |
|---|---|
private class |
LoptSemiJoinOptimizer.FactorCostComparator
Compares factors.
|
private static class |
LoptSemiJoinOptimizer.FemLocalIndex
Dummy class to allow code to compile.
|
private static class |
LoptSemiJoinOptimizer.LcsIndexOptimizer
Dummy class to allow code to compile.
|
private static class |
LoptSemiJoinOptimizer.LcsTable
Dummy class to allow code to compile.
|
private static class |
LoptSemiJoinOptimizer.LcsTableScan
Dummy class to allow code to compile.
|
private static class |
LoptSemiJoinOptimizer.LucidDbSpecialOperators
Dummy class to allow code to compile.
|
| Modifier and Type | Field and Description |
|---|---|
private RelNode[] |
chosenSemiJoins
Semijoins corresponding to each join factor, if they are going to be
filtered by semijoins.
|
private com.google.common.collect.Ordering<Integer> |
factorCostOrdering |
private RelMetadataQuery |
mq |
private Map<Integer,Map<Integer,SemiJoin>> |
possibleSemiJoins
Associates potential semijoins with each fact table factor.
|
private RexBuilder |
rexBuilder |
private static int |
THRESHOLD_SCORE |
| Constructor and Description |
|---|
LoptSemiJoinOptimizer(RelMetadataQuery mq,
LoptMultiJoin multiJoin,
RexBuilder rexBuilder) |
| Modifier and Type | Method and Description |
|---|---|
private RexNode |
adjustSemiJoinCondition(LoptMultiJoin multiJoin,
int leftAdjustment,
RexNode semiJoinCondition,
int leftIdx,
int rightIdx)
Modifies the semijoin condition to reflect the fact that the RHS is now
the second factor into a join and the LHS is the first
|
boolean |
chooseBestSemiJoin(LoptMultiJoin multiJoin)
Finds the optimal semijoin for filtering the least costly fact table from
among the remaining possible semijoins to choose from.
|
private double |
computeScore(RelNode factRel,
RelNode dimRel,
SemiJoin semiJoin)
Computes a score relevant to applying a set of semijoins on a fact table.
|
private SemiJoin |
findSemiJoinIndexByCost(LoptMultiJoin multiJoin,
List<RexNode> joinFilters,
int factIdx,
int dimIdx)
Given a list of possible filters on a fact table, determine if there is
an index that can be used, provided all the fact table keys originate
from the same underlying table.
|
RelNode |
getChosenSemiJoin(int factIdx) |
private int |
isSuitableFilter(LoptMultiJoin multiJoin,
RexNode joinFilter,
int factIdx)
Determines if a join filter can be used with a semijoin against a
specified fact table.
|
void |
makePossibleSemiJoins(LoptMultiJoin multiJoin)
Determines all possible semijoins that can be used by dimension tables to
filter fact tables.
|
private RexNode |
removeExtraFilters(List<Integer> keys,
int nFields,
RexNode condition)
Removes from an expression any sub-expressions that reference key values
that aren't contained in a key list passed in.
|
private void |
removeJoin(LoptMultiJoin multiJoin,
SemiJoin semiJoin,
int factIdx,
int dimIdx)
Determines whether a join of the dimension table in a semijoin can be
removed.
|
private void |
removePossibleSemiJoin(Map<Integer,SemiJoin> possibleDimensions,
Integer factIdx,
Integer dimIdx)
Removes a dimension table from a fact table's list of possible semijoins
|
private LoptSemiJoinOptimizer.LcsTable |
validateKeys(RelNode factRel,
List<Integer> leftKeys,
List<Integer> rightKeys,
List<Integer> actualLeftKeys)
Validates the candidate semijoin keys corresponding to the fact table.
|
private static final int THRESHOLD_SCORE
private final RexBuilder rexBuilder
private final RelMetadataQuery mq
private RelNode[] chosenSemiJoins
private Map<Integer,Map<Integer,SemiJoin>> possibleSemiJoins
private final com.google.common.collect.Ordering<Integer> factorCostOrdering
public LoptSemiJoinOptimizer(RelMetadataQuery mq, LoptMultiJoin multiJoin, RexBuilder rexBuilder)
public void makePossibleSemiJoins(LoptMultiJoin multiJoin)
multiJoin - join factors being optimizedprivate int isSuitableFilter(LoptMultiJoin multiJoin, RexNode joinFilter, int factIdx)
multiJoin - join factors being optimizedjoinFilter - filter to be analyzedfactIdx - index corresponding to the fact tableprivate SemiJoin findSemiJoinIndexByCost(LoptMultiJoin multiJoin, List<RexNode> joinFilters, int factIdx, int dimIdx)
multiJoin - join factors being optimizedjoinFilters - filters to be used on the fact tablefactIdx - index in join factors corresponding to the fact tabledimIdx - index in join factors corresponding to the dimension tableprivate RexNode adjustSemiJoinCondition(LoptMultiJoin multiJoin, int leftAdjustment, RexNode semiJoinCondition, int leftIdx, int rightIdx)
multiJoin - join factors being optimizedleftAdjustment - amount the left RexInputRefs need to be adjusted bysemiJoinCondition - condition to be adjustedleftIdx - index of the join factor corresponding to the LHS of the
semijoin,rightIdx - index of the join factor corresponding to the RHS of the
semijoinprivate LoptSemiJoinOptimizer.LcsTable validateKeys(RelNode factRel, List<Integer> leftKeys, List<Integer> rightKeys, List<Integer> actualLeftKeys)
factRel - fact table RelNodeleftKeys - fact table semijoin keysrightKeys - dimension table semijoin keysactualLeftKeys - the remaining valid fact table semijoin keysprivate RexNode removeExtraFilters(List<Integer> keys, int nFields, RexNode condition)
keys - join keys from one side of the joinnFields - number of fields in the side of the join for which the
keys correspondcondition - original expressionpublic boolean chooseBestSemiJoin(LoptMultiJoin multiJoin)
multiJoin - join factors being optimizedprivate double computeScore(RelNode factRel, RelNode dimRel, SemiJoin semiJoin)
factRel - fact table being filtereddimRel - dimension table that participates in semijoinsemiJoin - semijoin between fact and dimension tablesprivate void removeJoin(LoptMultiJoin multiJoin, SemiJoin semiJoin, int factIdx, int dimIdx)
multiJoin - join factors being optimizedsemiJoin - semijoin under considerationfactIdx - id of the fact table in the semijoindimIdx - id of the dimension table in the semijoinprivate void removePossibleSemiJoin(Map<Integer,SemiJoin> possibleDimensions, Integer factIdx, Integer dimIdx)
possibleDimensions - possible dimension tables associated with the
fact tablefactIdx - index corresponding to fact tabledimIdx - index corresponding to dimension tablepublic RelNode getChosenSemiJoin(int factIdx)
factIdx - index corresponding to the desired factorCopyright © 2012–2018 The Apache Software Foundation. All rights reserved.