public class RexToLixTranslator extends Object
REX expressions to
linq4j expressions.| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
RexToLixTranslator.AlwaysNull
Thrown in the unusual (but not erroneous) situation where the expression
we are translating is the null literal but we have already checked that
it is not null.
|
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). |
| Modifier and Type | Field and Description |
|---|---|
(package private) RexBuilder |
builder |
private Function1<String,RexToLixTranslator.InputGetter> |
correlates |
private Map<? extends RexNode,Boolean> |
exprNullableMap |
private RexToLixTranslator.InputGetter |
inputGetter |
static Map<Method,SqlOperator> |
JAVA_TO_SQL_METHOD_MAP |
private BlockBuilder |
list |
private RexToLixTranslator |
parent |
private RexProgram |
program |
private Expression |
root |
(package private) JavaTypeFactory |
typeFactory |
| Modifier | Constructor and Description |
|---|---|
private |
RexToLixTranslator(RexProgram program,
JavaTypeFactory typeFactory,
Expression root,
RexToLixTranslator.InputGetter inputGetter,
BlockBuilder list) |
private |
RexToLixTranslator(RexProgram program,
JavaTypeFactory typeFactory,
Expression root,
RexToLixTranslator.InputGetter inputGetter,
BlockBuilder list,
Map<? extends RexNode,Boolean> exprNullableMap,
RexBuilder builder,
RexToLixTranslator parent) |
private |
RexToLixTranslator(RexProgram program,
JavaTypeFactory typeFactory,
Expression root,
RexToLixTranslator.InputGetter inputGetter,
BlockBuilder list,
Map<? extends RexNode,Boolean> exprNullableMap,
RexBuilder builder,
RexToLixTranslator parent,
Function1<String,RexToLixTranslator.InputGetter> correlates) |
private |
RexToLixTranslator(RexProgram program,
JavaTypeFactory typeFactory,
Expression root,
RexToLixTranslator.InputGetter inputGetter,
BlockBuilder list,
Map<RexNode,Boolean> exprNullableMap,
RexBuilder builder) |
| Modifier and Type | Method and Description |
|---|---|
static Expression |
convert(Expression operand,
Type toType) |
static Expression |
convert(Expression operand,
Type fromType,
Type toType) |
RexNode |
deref(RexNode expr)
Dereferences an expression if it is a
RexLocalRef. |
private static Method |
findMethod(Class<?> clazz,
String name,
Class... parameterTypes) |
static RexToLixTranslator |
forAggregation(JavaTypeFactory typeFactory,
BlockBuilder list,
RexToLixTranslator.InputGetter inputGetter)
Creates a translator for translating aggregate functions.
|
Expression |
getRoot() |
Expression |
handleNull(Expression input,
RexImpTable.NullAs nullAs)
Adapts an expression with "normal" result to one that adheres to
this particular policy.
|
(package private) static boolean |
isA(Type fromType,
Primitive primitive) |
protected Boolean |
isKnownNullable(RexNode node)
Walks parent translator chain and verifies if the expression is nullable.
|
boolean |
isNullable(RexNode e)
Returns whether an expression is nullable.
|
private Primitive |
javaPrimitive(RelDataType type) |
RelDataType |
nullifyType(RelDataType type,
boolean nullable) |
RexToLixTranslator |
setBlock(BlockBuilder block) |
RexToLixTranslator |
setCorrelates(Function1<String,RexToLixTranslator.InputGetter> correlates) |
RexToLixTranslator |
setNullable(Map<? extends RexNode,Boolean> nullable)
Creates a read-only copy of this translator that records that a given
expression is nullable.
|
RexToLixTranslator |
setNullable(RexNode e,
boolean nullable)
Creates a read-only copy of this translator that records that a given
expression is nullable.
|
(package private) Expression |
translate(RexNode expr) |
(package private) Expression |
translate(RexNode expr,
RexImpTable.NullAs nullAs) |
(package private) Expression |
translate(RexNode expr,
RexImpTable.NullAs nullAs,
Type storageType) |
(package private) Expression |
translate(RexNode expr,
Type storageType) |
private Expression |
translate0(RexNode expr,
RexImpTable.NullAs nullAs,
Type storageType)
Translates an expression that is not in the cache.
|
private Expression |
translateCall(RexCall call,
RexImpTable.NullAs nullAs)
Translates a call to an operator or function.
|
(package private) Expression |
translateCast(RelDataType sourceType,
RelDataType targetType,
Expression operand) |
static Expression |
translateCondition(RexProgram program,
JavaTypeFactory typeFactory,
BlockBuilder list,
RexToLixTranslator.InputGetter inputGetter,
Function1<String,RexToLixTranslator.InputGetter> correlates) |
Expression |
translateConstructor(List<RexNode> operandList,
SqlKind kind) |
List<Expression> |
translateList(List<? extends RexNode> operandList)
Translates the list of
RexNode, using the default output types. |
List<Expression> |
translateList(List<? extends RexNode> operandList,
List<? extends Type> storageTypes)
Translates the list of
RexNode, while optimizing for output
storage. |
List<Expression> |
translateList(List<RexNode> operandList,
RexImpTable.NullAs nullAs) |
List<Expression> |
translateList(List<RexNode> operandList,
RexImpTable.NullAs nullAs,
List<? extends Type> storageTypes) |
static Expression |
translateLiteral(RexLiteral literal,
RelDataType type,
JavaTypeFactory typeFactory,
RexImpTable.NullAs nullAs)
Translates a literal.
|
private Expression |
translateParameter(RexDynamicParam expr,
RexImpTable.NullAs nullAs,
Type storageType)
Translates a parameter.
|
static List<Expression> |
translateProjects(RexProgram program,
JavaTypeFactory typeFactory,
BlockBuilder list,
PhysType outputPhysType,
Expression root,
RexToLixTranslator.InputGetter inputGetter,
Function1<String,RexToLixTranslator.InputGetter> correlates)
Translates a
RexProgram to a sequence of expressions and
declarations. |
public static final Map<Method,SqlOperator> JAVA_TO_SQL_METHOD_MAP
final JavaTypeFactory typeFactory
final RexBuilder builder
private final RexProgram program
private final Expression root
private final RexToLixTranslator.InputGetter inputGetter
private final BlockBuilder list
private final RexToLixTranslator parent
private final Function1<String,RexToLixTranslator.InputGetter> correlates
private RexToLixTranslator(RexProgram program, JavaTypeFactory typeFactory, Expression root, RexToLixTranslator.InputGetter inputGetter, BlockBuilder list)
private RexToLixTranslator(RexProgram program, JavaTypeFactory typeFactory, Expression root, RexToLixTranslator.InputGetter inputGetter, BlockBuilder list, Map<RexNode,Boolean> exprNullableMap, RexBuilder builder)
private RexToLixTranslator(RexProgram program, JavaTypeFactory typeFactory, Expression root, RexToLixTranslator.InputGetter inputGetter, BlockBuilder list, Map<? extends RexNode,Boolean> exprNullableMap, RexBuilder builder, RexToLixTranslator parent)
private RexToLixTranslator(RexProgram program, JavaTypeFactory typeFactory, Expression root, RexToLixTranslator.InputGetter inputGetter, BlockBuilder list, Map<? extends RexNode,Boolean> exprNullableMap, RexBuilder builder, RexToLixTranslator parent, Function1<String,RexToLixTranslator.InputGetter> correlates)
public static List<Expression> translateProjects(RexProgram program, JavaTypeFactory typeFactory, BlockBuilder list, PhysType outputPhysType, Expression root, RexToLixTranslator.InputGetter inputGetter, Function1<String,RexToLixTranslator.InputGetter> correlates)
RexProgram to a sequence of expressions and
declarations.program - Program to be translatedtypeFactory - Type factorylist - List of statements, populated with declarationsoutputPhysType - Output type, or nullroot - Root expressioninputGetter - Generates expressions for inputscorrelates - Provider of references to the values of correlated
variablespublic static RexToLixTranslator forAggregation(JavaTypeFactory typeFactory, BlockBuilder list, RexToLixTranslator.InputGetter inputGetter)
Expression translate(RexNode expr)
Expression translate(RexNode expr, RexImpTable.NullAs nullAs)
Expression translate(RexNode expr, Type storageType)
Expression translate(RexNode expr, RexImpTable.NullAs nullAs, Type storageType)
Expression translateCast(RelDataType sourceType, RelDataType targetType, Expression operand)
public Expression handleNull(Expression input, RexImpTable.NullAs nullAs)
input - ExpressionnullAs - If false, if expression is definitely not null at
runtime. Therefore we can optimize. For example, we can cast to int
using x.intValue().private Expression translate0(RexNode expr, RexImpTable.NullAs nullAs, Type storageType)
expr - ExpressionnullAs - If false, if expression is definitely not null at
runtime. Therefore we can optimize. For example, we can cast to int
using x.intValue().public RexNode deref(RexNode expr)
RexLocalRef.private Expression translateCall(RexCall call, RexImpTable.NullAs nullAs)
private Expression translateParameter(RexDynamicParam expr, RexImpTable.NullAs nullAs, Type storageType)
public static Expression translateLiteral(RexLiteral literal, RelDataType type, JavaTypeFactory typeFactory, RexImpTable.NullAs nullAs)
RexToLixTranslator.AlwaysNull - if literal is null but nullAs is
RexImpTable.NullAs.NOT_POSSIBLE.public List<Expression> translateList(List<RexNode> operandList, RexImpTable.NullAs nullAs)
public List<Expression> translateList(List<RexNode> operandList, RexImpTable.NullAs nullAs, List<? extends Type> storageTypes)
public List<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<Expression> translateList(List<? extends RexNode> operandList, 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 Expression translateCondition(RexProgram program, JavaTypeFactory typeFactory, BlockBuilder list, RexToLixTranslator.InputGetter inputGetter, Function1<String,RexToLixTranslator.InputGetter> correlates)
public static Expression convert(Expression operand, Type toType)
public static Expression convert(Expression operand, Type fromType, Type toType)
public Expression translateConstructor(List<RexNode> operandList, SqlKind kind)
public boolean isNullable(RexNode e)
For example, WHERE a == b translates to
a != null && b != null && a.equals(b). When translating the
3rd part of the disjunction, we already know a and b are not null.
e - Expressionprotected Boolean isKnownNullable(RexNode node)
node - RexNode to check if it is nullable or notpublic RexToLixTranslator setNullable(RexNode e, boolean nullable)
public RexToLixTranslator setNullable(Map<? extends RexNode,Boolean> nullable)
public RexToLixTranslator setBlock(BlockBuilder block)
public RexToLixTranslator setCorrelates(Function1<String,RexToLixTranslator.InputGetter> correlates)
public RelDataType nullifyType(RelDataType type, boolean nullable)
private Primitive javaPrimitive(RelDataType type)
public Expression getRoot()
Copyright © 2012–2018 The Apache Software Foundation. All rights reserved.