|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.farrago.fennel.rel.CalcRelSplitter
public abstract class CalcRelSplitter
CalcRelSplitter operates on a CalcRel
with multiple RexCall
sub-expressions that cannot all be implemented by a single concrete RelNode
.
For example, the Java and Fennel calculator do not implement an identical set of operators. The CalcRel can be used to split a single CalcRel with mixed Java- and Fennel-only operators into a tree of CalcRel object that can each be individually implemented by either Java or Fennel.and splits it into several CalcRel instances.
Currently the splitter is only capable of handling two "rel types". That is, it can deal with Java vs. Fennel CalcRels, but not Java vs. Fennel vs. some other type of CalcRel.
See FarragoAutoCalcRule
for an example of how this class is used.
Nested Class Summary | |
---|---|
private static class |
CalcRelSplitter.CannotImplement
Control exception for CalcRelSplitter.ImplementTester . |
private static class |
CalcRelSplitter.HighestUsageFinder
Builds an array of the highest level which contains an expression which uses each expression as an input. |
private static class |
CalcRelSplitter.ImplementTester
Visitor which returns whether an expression can be implemented in a given type of relational expression. |
private static class |
CalcRelSplitter.InputToCommonExprConverter
Shuttle which converts every reference to an input field in an expression to a reference to a common sub-expression. |
private static class |
CalcRelSplitter.MaxInputFinder
Finds the highest level used by any of the inputs of a given expression. |
static class |
CalcRelSplitter.RelType
|
Field Summary | |
---|---|
private RelNode |
child
|
private RelOptCluster |
cluster
|
private RexProgram |
program
|
private CalcRelSplitter.RelType[] |
relTypes
|
private static Logger |
ruleTracer
|
private RelTraitSet |
traits
|
private RelDataTypeFactory |
typeFactory
|
Constructor Summary | |
---|---|
CalcRelSplitter(CalcRel calc,
CalcRelSplitter.RelType[] relTypes)
Constructs a CalcRelSplitter. |
Method Summary | |
---|---|
protected boolean |
canImplement(CalcRel rel,
String relTypeName)
Returns whether a relational expression can be implemented solely in a given CalcRelSplitter.RelType . |
private int |
chooseLevels(RexNode[] exprs,
int conditionOrdinal,
int[] exprLevels,
int[] levelTypeOrdinals)
Figures out which expressions to calculate at which level. |
private static int |
count(boolean[] booleans)
Returns the number of bits set in an array. |
private RexProgram |
createProgramForLevel(int level,
RelDataType inputRowType,
RexNode[] allExprs,
int[] exprLevels,
int[] inputExprOrdinals,
int[] projectExprOrdinals,
int conditionExprOrdinal,
RelDataType outputRowType)
Creates a program containing the expressions for a given level. |
(package private) RelNode |
execute()
|
private static int |
firstSet(boolean[] booleans)
Returns the index of the first set bit in an array. |
private int[] |
identityArray(int length)
|
private static int |
indexOf(int value,
int[] map)
Searches for a value in a map, and returns the position where it was found, or -1. |
private void |
traceLevelExpressions(RexNode[] exprs,
int[] exprLevels,
int[] levelTypeOrdinals,
int levelCount)
Traces the given array of level expression lists at the finer level. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger ruleTracer
private final RexProgram program
private final RelDataTypeFactory typeFactory
private final CalcRelSplitter.RelType[] relTypes
private final RelOptCluster cluster
private final RelTraitSet traits
private final RelNode child
Constructor Detail |
---|
CalcRelSplitter(CalcRel calc, CalcRelSplitter.RelType[] relTypes)
calc
- CalcRel to splitrelTypes
- Array of rel types, e.g. {Java, Fennel}. Must be
distinct.Method Detail |
---|
RelNode execute()
private int chooseLevels(RexNode[] exprs, int conditionOrdinal, int[] exprLevels, int[] levelTypeOrdinals)
exprs
- Array of expressionsconditionOrdinal
- Ordinal of the condition expression, or -1 if no
conditionexprLevels
- Level ordinal for each expression (output)levelTypeOrdinals
- The type of each level (output)private int[] identityArray(int length)
private RexProgram createProgramForLevel(int level, RelDataType inputRowType, RexNode[] allExprs, int[] exprLevels, int[] inputExprOrdinals, int[] projectExprOrdinals, int conditionExprOrdinal, RelDataType outputRowType)
The expression list of the program will consist of all entries in the
expression list allExprs[i]
for which the corresponding
level ordinal exprLevels[i]
is equal to level
.
Expressions are mapped according to inputExprOrdinals
.
level
- Level ordinalinputRowType
- Input row typeallExprs
- Array of all expressionsexprLevels
- Array of the level ordinal of each expressioninputExprOrdinals
- Ordinals in the expression list of input
expressions. Input expression i
will be found at position
inputExprOrdinals[i]
.projectExprOrdinals
- Ordinals of the expressions to be output this
level.conditionExprOrdinal
- Ordinal of the expression to form the
condition for this level, or -1 if there is no condition.outputRowType
- Output row type
private void traceLevelExpressions(RexNode[] exprs, int[] exprLevels, int[] levelTypeOrdinals, int levelCount)
exprs
- Array expressionsexprLevels
- For each expression, the ordinal of its levellevelTypeOrdinals
- For each level, the ordinal of its reltype in
the relTypes
arraylevelCount
- The number of levelsprivate static int count(boolean[] booleans)
private static int firstSet(boolean[] booleans)
private static int indexOf(int value, int[] map)
value
- Value to search formap
- Map to search in
protected boolean canImplement(CalcRel rel, String relTypeName)
CalcRelSplitter.RelType
.
rel
- Calculation relational expressionrelTypeName
- Name of a CalcRelSplitter.RelType
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |