|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eigenbase.rel.metadata.RelMdUtil
public class RelMdUtil
RelMdUtil provides utility methods used by the metadata provider methods.
Nested Class Summary | |
---|---|
private static class |
RelMdUtil.CardOfProjExpr
|
Field Summary | |
---|---|
static SqlFunction |
artificialSelectivityFunc
|
Constructor Summary | |
---|---|
RelMdUtil()
|
Method Summary | |
---|---|
static boolean |
areColumnsDefinitelyUnique(RelNode rel,
BitSet colMask)
Returns true if the columns represented in a bit mask are definitely known to form a unique column set. |
static boolean |
areColumnsDefinitelyUnique(RelNode rel,
List<RexInputRef> columnRefs)
|
static boolean |
areColumnsDefinitelyUniqueWhenNullsFiltered(RelNode rel,
BitSet colMask)
Returns true if the columns represented in a bit mask are definitely known to form a unique column set, when nulls have been filtered from the columns. |
static boolean |
areColumnsDefinitelyUniqueWhenNullsFiltered(RelNode rel,
List<RexInputRef> columnRefs)
|
static Boolean |
areColumnsUnique(RelNode rel,
List<RexInputRef> columnRefs)
|
static Boolean |
areColumnsUniqueWhenNullsFiltered(RelNode rel,
List<RexInputRef> columnRefs)
|
static double |
capInfinity(Double d)
Caps a double value at Double.MAX_VALUE if it's currently infinity |
static Double |
cardOfProjExpr(ProjectRelBase rel,
RexNode expr)
Computes the cardinality of a particular expression from the projection list |
static double |
computeSemiJoinSelectivity(RelNode factRel,
RelNode dimRel,
List<Integer> factKeyList,
List<Integer> dimKeyList)
Computes the selectivity of a semijoin filter if it is applied on a fact table. |
static double |
computeSemiJoinSelectivity(RelNode factRel,
RelNode dimRel,
SemiJoinRel rel)
Computes the selectivity of a semijoin filter if it is applied on a fact table. |
static double |
computeSemiJoinSelectivity(SemiJoinRel rel)
Computes the selectivity of a semijoin filter if it is applied on a fact table. |
static RexNode |
findEquiJoinCols(RelNode leftChild,
RelNode rightChild,
RexNode predicate,
BitSet leftJoinCols,
BitSet rightJoinCols)
Locates the columns corresponding to equijoins within a joinrel. |
static Double |
getJoinDistinctRowCount(RelNode joinRel,
JoinRelType joinType,
BitSet groupKey,
RexNode predicate)
Computes the number of distinct rows for a set of keys returned from a join |
static Double |
getJoinPopulationSize(RelNode joinRel,
BitSet groupKey)
Computes the population size for a set of keys returned from a join |
static double |
getSelectivityValue(RexNode artificialSelecFuncNode)
Returns the selectivity value stored in the rexnode |
static double |
guessSelectivity(RexNode predicate)
Returns default estimates for selectivities, in the absence of stats. |
static double |
guessSelectivity(RexNode predicate,
boolean artificialOnly)
Returns default estimates for selectivities, in the absence of stats. |
static RexNode |
makeSemiJoinSelectivityRexNode(SemiJoinRel rel)
Creates a RexNode that stores a selectivity value corresponding to the selectivity of a semijoin. |
static RexNode |
minusPreds(RexBuilder rexBuilder,
RexNode pred1,
RexNode pred2)
Takes the difference between two predicates, removing from the first any predicates also in the second |
static Double |
numDistinctVals(Double domainSize,
Double numSelected)
Returns the number of distinct values provided numSelected are selected where there are domainSize distinct values. |
static void |
setAggChildKeys(BitSet groupKey,
AggregateRelBase aggRel,
BitSet childKey)
Takes a bitmap representing a set of input references and extracts the ones that reference the group by columns in an aggregate |
static BitSet |
setBitKeys(List<Integer> keys)
Sets a bitmap corresponding to a list of keys. |
static void |
setLeftRightBitmaps(BitSet groupKey,
BitSet leftMask,
BitSet rightMask,
int nFieldsOnLeft)
Separates a bitmask representing a join into masks representing the left and right inputs into the join |
static void |
splitCols(RexNode[] projExprs,
BitSet groupKey,
BitSet baseCols,
BitSet projCols)
Forms two bitmaps by splitting the columns in a bitmap according to whether or not the column references the child input or is an expression |
static RexNode |
unionPreds(RexBuilder rexBuilder,
RexNode pred1,
RexNode pred2)
AND's two predicates together, either of which may be null, removing redundant filters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final SqlFunction artificialSelectivityFunc
Constructor Detail |
---|
public RelMdUtil()
Method Detail |
---|
public static RexNode makeSemiJoinSelectivityRexNode(SemiJoinRel rel)
rel
- the semijoin of interest
public static double getSelectivityValue(RexNode artificialSelecFuncNode)
artificialSelecFuncNode
- rexnode containing the selectivity value
public static double computeSemiJoinSelectivity(SemiJoinRel rel)
rel
- semijoin rel
public static double computeSemiJoinSelectivity(RelNode factRel, RelNode dimRel, SemiJoinRel rel)
factRel
- fact table participating in the semijoindimRel
- dimension table participating in the semijoinrel
- semijoin rel
public static double computeSemiJoinSelectivity(RelNode factRel, RelNode dimRel, List<Integer> factKeyList, List<Integer> dimKeyList)
factRel
- fact table participating in the semijoindimRel
- dimension table participating in the semijoinfactKeyList
- LHS keys used in the filterdimKeyList
- RHS keys used in the filter
public static boolean areColumnsDefinitelyUnique(RelNode rel, BitSet colMask)
rel
- the relnode that the column mask correponds tocolMask
- bit mask containing columns that will be tested for
uniqueness
public static Boolean areColumnsUnique(RelNode rel, List<RexInputRef> columnRefs)
public static boolean areColumnsDefinitelyUnique(RelNode rel, List<RexInputRef> columnRefs)
public static boolean areColumnsDefinitelyUniqueWhenNullsFiltered(RelNode rel, BitSet colMask)
rel
- the relnode that the column mask correponds tocolMask
- bit mask containing columns that will be tested for
uniqueness
public static Boolean areColumnsUniqueWhenNullsFiltered(RelNode rel, List<RexInputRef> columnRefs)
public static boolean areColumnsDefinitelyUniqueWhenNullsFiltered(RelNode rel, List<RexInputRef> columnRefs)
public static BitSet setBitKeys(List<Integer> keys)
keys
- list of keys
public static void setLeftRightBitmaps(BitSet groupKey, BitSet leftMask, BitSet rightMask, int nFieldsOnLeft)
groupKey
- original bitmaskleftMask
- left bitmask to be setrightMask
- right bitmask to be setnFieldsOnLeft
- number of fields in the left inputpublic static Double numDistinctVals(Double domainSize, Double numSelected)
Note that in the case where domainSize == numSelected, it's not true that the return value should be domainSize. If you pick 100 random values between 1 and 100, you'll most likely end up with fewer than 100 distinct values, because you'll pick some values more than once.
domainSize
- number of distinct values in the domainnumSelected
- number selected from the domain
public static double capInfinity(Double d)
d
- the Double object
public static double guessSelectivity(RexNode predicate)
predicate
- predicate for which selectivity will be computed; null
means true, so gives selectity of 1.0
public static double guessSelectivity(RexNode predicate, boolean artificialOnly)
predicate
- predicate for which selectivity will be computed; null
means true, so gives selectity of 1.0artificialOnly
- return only the selectivity contribution from
artificial nodes
public static RexNode findEquiJoinCols(RelNode leftChild, RelNode rightChild, RexNode predicate, BitSet leftJoinCols, BitSet rightJoinCols)
leftChild
- left input into the joinrightChild
- right input into the joinpredicate
- join predicateleftJoinCols
- bitmap that will be set with the columns on the LHS
of the join that participate in equijoinsrightJoinCols
- bitmap that will be set with the columns on the RHS
of the join that participate in equijoins
RexLiteral
true, but never nullpublic static RexNode unionPreds(RexBuilder rexBuilder, RexNode pred1, RexNode pred2)
rexBuilder
- rexBuilder used to construct AND'd RexNodepred1
- first predicatepred2
- second predicate
public static RexNode minusPreds(RexBuilder rexBuilder, RexNode pred1, RexNode pred2)
rexBuilder
- rexBuilder used to construct AND'd RexNodepred1
- first predicatepred2
- second predicate
public static void setAggChildKeys(BitSet groupKey, AggregateRelBase aggRel, BitSet childKey)
groupKey
- the original bitmapaggRel
- the aggregatechildKey
- sets bits from groupKey corresponding to group by columnspublic static void splitCols(RexNode[] projExprs, BitSet groupKey, BitSet baseCols, BitSet projCols)
projExprs
- groupKey
- bitmap whose columns will be splitbaseCols
- bitmap representing columns from the child inputprojCols
- bitmap representing non-child columnspublic static Double cardOfProjExpr(ProjectRelBase rel, RexNode expr)
rel
- RelNode corresponding to the projectexpr
- projection expression
public static Double getJoinPopulationSize(RelNode joinRel, BitSet groupKey)
joinRel
- the join relgroupKey
- keys to compute the population for
public static Double getJoinDistinctRowCount(RelNode joinRel, JoinRelType joinType, BitSet groupKey, RexNode predicate)
joinRel
- RelNode representing the joinjoinType
- type of joingroupKey
- keys that the distinct row count will be computed forpredicate
- join predicate
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |