public class RexToLixTranslator extends Object implements RexVisitor<RexToLixTranslator.Result>
REX expressions to
linq4j expressions.| Modifier and Type | Class and Description |
|---|---|
static interface |
RexToLixTranslator.InputGetter
Translates a field of an input to an expression.
|
static class |
RexToLixTranslator.InputGetterImpl
Implementation of
RexToLixTranslator.InputGetter that calls
PhysType.fieldReference(org.apache.calcite.linq4j.tree.Expression, int). |
static class |
RexToLixTranslator.Result
Result of translating a
RexNode. |
| Modifier and Type | Field and Description |
|---|---|
static Map<Method,SqlOperator> |
JAVA_TO_SQL_METHOD_MAP |
| Modifier and Type | Method and Description |
|---|---|
RexNode |
deref(RexNode expr)
Dereferences an expression if it is a
RexLocalRef. |
static RexToLixTranslator |
forAggregation(JavaTypeFactory typeFactory,
org.apache.calcite.linq4j.tree.BlockBuilder list,
@Nullable RexToLixTranslator.InputGetter inputGetter,
SqlConformance conformance)
Creates a translator for translating aggregate functions.
|
org.apache.calcite.linq4j.tree.Expression |
getRoot() |
boolean |
isNullable(RexNode e)
Returns whether an expression is nullable.
|
RexToLixTranslator |
setBlock(org.apache.calcite.linq4j.tree.BlockBuilder list) |
RexToLixTranslator |
setCorrelates(@Nullable org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates) |
static org.apache.calcite.linq4j.tree.Expression |
translateCondition(RexProgram program,
JavaTypeFactory typeFactory,
org.apache.calcite.linq4j.tree.BlockBuilder list,
RexToLixTranslator.InputGetter inputGetter,
org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates,
SqlConformance conformance) |
List<org.apache.calcite.linq4j.tree.Expression> |
translateList(List<? extends RexNode> operandList)
Translates the list of
RexNode, using the default output types. |
List<org.apache.calcite.linq4j.tree.Expression> |
translateList(List<? extends RexNode> operandList,
@Nullable List<? extends Type> storageTypes)
Translates the list of
RexNode, while optimizing for output
storage. |
List<org.apache.calcite.linq4j.tree.Expression> |
translateList(List<RexNode> operandList,
RexImpTable.NullAs nullAs) |
List<org.apache.calcite.linq4j.tree.Expression> |
translateList(List<RexNode> operandList,
RexImpTable.NullAs nullAs,
List<? extends Type> storageTypes) |
static org.apache.calcite.linq4j.tree.Expression |
translateLiteral(RexLiteral literal,
RelDataType type,
JavaTypeFactory typeFactory,
RexImpTable.NullAs nullAs)
Translates a literal.
|
static List<org.apache.calcite.linq4j.tree.Expression> |
translateProjects(RexProgram program,
JavaTypeFactory typeFactory,
SqlConformance conformance,
org.apache.calcite.linq4j.tree.BlockBuilder list,
@Nullable org.apache.calcite.linq4j.tree.BlockBuilder staticList,
@Nullable PhysType outputPhysType,
org.apache.calcite.linq4j.tree.Expression root,
RexToLixTranslator.InputGetter inputGetter,
@Nullable org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates)
Translates a
RexProgram to a sequence of expressions and
declarations. |
static List<org.apache.calcite.linq4j.tree.Expression> |
translateProjects(RexProgram program,
JavaTypeFactory typeFactory,
SqlConformance conformance,
org.apache.calcite.linq4j.tree.BlockBuilder list,
@Nullable PhysType outputPhysType,
org.apache.calcite.linq4j.tree.Expression root,
RexToLixTranslator.InputGetter inputGetter,
@Nullable org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates)
Deprecated.
|
static org.apache.calcite.linq4j.tree.Expression |
translateTableFunction(JavaTypeFactory typeFactory,
SqlConformance conformance,
org.apache.calcite.linq4j.tree.BlockBuilder list,
org.apache.calcite.linq4j.tree.Expression root,
RexCall rexCall,
org.apache.calcite.linq4j.tree.Expression inputEnumerable,
PhysType inputPhysType,
PhysType outputPhysType) |
RexToLixTranslator.Result |
visitCall(RexCall call)
Visit
RexCall. |
RexToLixTranslator.Result |
visitCorrelVariable(RexCorrelVariable correlVariable) |
RexToLixTranslator.Result |
visitDynamicParam(RexDynamicParam dynamicParam) |
RexToLixTranslator.Result |
visitFieldAccess(RexFieldAccess fieldAccess) |
RexToLixTranslator.Result |
visitInputRef(RexInputRef inputRef)
Visit
RexInputRef. |
RexToLixTranslator.Result |
visitLiteral(RexLiteral literal)
Visit
RexLiteral. |
RexToLixTranslator.Result |
visitLocalRef(RexLocalRef localRef) |
RexToLixTranslator.Result |
visitOver(RexOver over) |
RexToLixTranslator.Result |
visitPatternFieldRef(RexPatternFieldRef fieldRef) |
RexToLixTranslator.Result |
visitRangeRef(RexRangeRef rangeRef) |
RexToLixTranslator.Result |
visitSubQuery(RexSubQuery subQuery) |
RexToLixTranslator.Result |
visitTableInputRef(RexTableInputRef fieldRef) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvisitEach, visitList, visitListpublic static final Map<Method,SqlOperator> JAVA_TO_SQL_METHOD_MAP
public static List<org.apache.calcite.linq4j.tree.Expression> translateProjects(RexProgram program, JavaTypeFactory typeFactory, SqlConformance conformance, org.apache.calcite.linq4j.tree.BlockBuilder list, @Nullable org.apache.calcite.linq4j.tree.BlockBuilder staticList, @Nullable PhysType outputPhysType, org.apache.calcite.linq4j.tree.Expression root, RexToLixTranslator.InputGetter inputGetter, @Nullable org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates)
RexProgram to a sequence of expressions and
declarations.program - Program to be translatedtypeFactory - Type factoryconformance - SQL conformancelist - List of statements, populated with declarationsstaticList - List of member declarationsoutputPhysType - Output type, or nullroot - Root expressioninputGetter - Generates expressions for inputscorrelates - Provider of references to the values of correlated
variables@Deprecated public static List<org.apache.calcite.linq4j.tree.Expression> translateProjects(RexProgram program, JavaTypeFactory typeFactory, SqlConformance conformance, org.apache.calcite.linq4j.tree.BlockBuilder list, @Nullable PhysType outputPhysType, org.apache.calcite.linq4j.tree.Expression root, RexToLixTranslator.InputGetter inputGetter, @Nullable org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates)
public static org.apache.calcite.linq4j.tree.Expression translateTableFunction(JavaTypeFactory typeFactory, SqlConformance conformance, org.apache.calcite.linq4j.tree.BlockBuilder list, org.apache.calcite.linq4j.tree.Expression root, RexCall rexCall, org.apache.calcite.linq4j.tree.Expression inputEnumerable, PhysType inputPhysType, PhysType outputPhysType)
public static RexToLixTranslator forAggregation(JavaTypeFactory typeFactory, org.apache.calcite.linq4j.tree.BlockBuilder list, @Nullable RexToLixTranslator.InputGetter inputGetter, SqlConformance conformance)
public RexNode deref(RexNode expr)
RexLocalRef.public static org.apache.calcite.linq4j.tree.Expression translateLiteral(RexLiteral literal, RelDataType type, JavaTypeFactory typeFactory, RexImpTable.NullAs nullAs)
ControlFlowException - if literal is null but nullAs is
RexImpTable.NullAs.NOT_POSSIBLE.public List<org.apache.calcite.linq4j.tree.Expression> translateList(List<RexNode> operandList, RexImpTable.NullAs nullAs)
public List<org.apache.calcite.linq4j.tree.Expression> translateList(List<RexNode> operandList, RexImpTable.NullAs nullAs, List<? extends Type> storageTypes)
public List<org.apache.calcite.linq4j.tree.Expression> translateList(List<? extends RexNode> operandList)
RexNode, using the default output types.
This might be suboptimal in terms of additional box-unbox when you use
the translation later.
If you know the java class that will be used to store the results, use
translateList(java.util.List, java.util.List)
version.operandList - list of RexNodes to translatepublic List<org.apache.calcite.linq4j.tree.Expression> translateList(List<? extends RexNode> operandList, @Nullable List<? extends Type> storageTypes)
RexNode, while optimizing for output
storage.
For instance, if the result of translation is going to be stored in
Object[], and the input is Object[] as well,
then translator will avoid casting, boxing, etc.operandList - list of RexNodes to translatestorageTypes - hints of the java classes that will be used
to store translation results. Use null to use
default storage typepublic static org.apache.calcite.linq4j.tree.Expression translateCondition(RexProgram program, JavaTypeFactory typeFactory, org.apache.calcite.linq4j.tree.BlockBuilder list, RexToLixTranslator.InputGetter inputGetter, org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates, SqlConformance conformance)
public boolean isNullable(RexNode e)
e - Expressionpublic RexToLixTranslator setBlock(org.apache.calcite.linq4j.tree.BlockBuilder list)
public RexToLixTranslator setCorrelates(@Nullable org.apache.calcite.linq4j.function.Function1<String,RexToLixTranslator.InputGetter> correlates)
public org.apache.calcite.linq4j.tree.Expression getRoot()
public RexToLixTranslator.Result visitInputRef(RexInputRef inputRef)
RexInputRef. If it has never been visited
under current storage type before, RexToLixTranslator
generally produces three lines of code.
For example, when visiting a column (named commission) in
table Employee, the generated code snippet is:
final Employee current =(Employee) inputEnumerator.current();
final Integer input_value = current.commission;
final boolean input_isNull = input_value == null;
visitInputRef in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitLocalRef(RexLocalRef localRef)
visitLocalRef in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitLiteral(RexLiteral literal)
RexLiteral. If it has never been visited before,
RexToLixTranslator will generate two lines of code. For example,
when visiting a primitive int (10), the generated code snippet is:
final int literal_value = 10;
final boolean literal_isNull = false;
visitLiteral in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitCall(RexCall call)
RexCall. For most SqlOperators, we can get the implementor
from RexImpTable. Several operators (e.g., CaseWhen) with special semantics
need to be implemented separately.visitCall in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitDynamicParam(RexDynamicParam dynamicParam)
visitDynamicParam in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitFieldAccess(RexFieldAccess fieldAccess)
visitFieldAccess in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitOver(RexOver over)
visitOver in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitCorrelVariable(RexCorrelVariable correlVariable)
visitCorrelVariable in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitRangeRef(RexRangeRef rangeRef)
visitRangeRef in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitSubQuery(RexSubQuery subQuery)
visitSubQuery in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitTableInputRef(RexTableInputRef fieldRef)
visitTableInputRef in interface RexVisitor<RexToLixTranslator.Result>public RexToLixTranslator.Result visitPatternFieldRef(RexPatternFieldRef fieldRef)
visitPatternFieldRef in interface RexVisitor<RexToLixTranslator.Result>Copyright © 2012-2022 Apache Software Foundation. All Rights Reserved.