public class CodeGenerator extends Object implements org.apache.calcite.rex.RexVisitor<GeneratedExpression>
Function
s.
Constructor and Description |
---|
CodeGenerator(TableConfig config)
A code generator for generating Flink input formats.
|
CodeGenerator(TableConfig config,
boolean nullableInput,
TypeInformation<Object> input,
int[] inputPojoFieldMapping)
A code generator for generating unary Flink
Function s with one input. |
CodeGenerator(TableConfig config,
boolean nullableInput,
TypeInformation<Object> input1,
scala.Option<TypeInformation<Object>> input2,
scala.Option<int[]> input1PojoFieldMapping,
scala.Option<int[]> input2PojoFieldMapping) |
Modifier and Type | Method and Description |
---|---|
String |
addReusableArray(Class<?> clazz,
int size)
Adds a reusable array to the member area of the generated
Function . |
String[] |
addReusableConstructor(scala.collection.Seq<Class<?>> parameterTypes)
Adds a reusable constructor statement with the given parameter types.
|
String |
addReusableDate()
Adds a reusable date to the beginning of the SAM of the generated
Function . |
String |
addReusableDecimal(BigDecimal decimal)
Adds a reusable
BigDecimal to the member area of the generated Function . |
String |
addReusableFunction(UserDefinedFunction function)
Adds a reusable
UserDefinedFunction to the member area of the generated Function . |
String |
addReusableLocalTime()
Adds a reusable local time to the beginning of the SAM of the generated
Function . |
String |
addReusableLocalTimestamp()
Adds a reusable local timestamp to the beginning of the SAM of the generated
Function . |
void |
addReusableOutRecord(TypeInformation<?> ti)
Adds a reusable output record to the member area of the generated
Function . |
String |
addReusablePrivateFieldAccess(Class<?> clazz,
String fieldName)
Adds a reusable
Field to the member area of the generated Function . |
String |
addReusableTime()
Adds a reusable time to the beginning of the SAM of the generated
Function . |
String |
addReusableTimestamp()
Adds a reusable timestamp to the beginning of the SAM of the generated
Function . |
String |
collectorTerm() |
GeneratedExpression |
generateConverterResultExpression(TypeInformation<?> returnType,
scala.collection.Seq<String> resultFieldNames)
Generates an expression that converts the first input (and second input) into the given type.
|
scala.Tuple2<scala.collection.Seq<GeneratedExpression>,scala.collection.Seq<GeneratedExpression>> |
generateCorrelateAccessExprs()
Generates an expression from the left input and the right table function.
|
GeneratedExpression |
generateExpression(org.apache.calcite.rex.RexNode rex)
Generates an expression from a RexNode.
|
<T extends Function> |
generateFunction(String name,
Class<T> clazz,
String bodyCode,
TypeInformation<Object> returnType)
Generates a
Function that can be passed to Java
compiler. |
GeneratedExpression |
generateInputFieldUnboxing(TypeInformation<?> fieldType,
String fieldTerm)
Converts the external boxed format to an internal mostly primitive field representation.
|
GeneratedExpression |
generateNonNullLiteral(TypeInformation<?> literalType,
String literalCode) |
GeneratedExpression |
generateOutputFieldBoxing(GeneratedExpression expr)
Converts the internal mostly primitive field representation to an external boxed format.
|
GeneratedExpression |
generateResultExpression(scala.collection.Seq<GeneratedExpression> fieldExprs,
TypeInformation<?> returnType,
scala.collection.Seq<String> resultFieldNames)
Generates an expression from a sequence of other expressions.
|
GeneratedExpression |
generateResultExpression(TypeInformation<?> returnType,
scala.collection.Seq<String> resultFieldNames,
scala.collection.Seq<org.apache.calcite.rex.RexNode> rexNodes)
Generates an expression from a sequence of RexNode.
|
GeneratedExpression |
generateSymbol(Enum<?> enum_) |
GeneratedCollector |
generateTableFunctionCollector(String name,
String bodyCode,
TypeInformation<Object> collectedType)
Generates a
TableFunctionCollector that can be passed to Java compiler. |
<T> GeneratedFunction<GenericInputFormat<T>> |
generateValuesInputFormat(String name,
scala.collection.Seq<String> records,
TypeInformation<Object> returnType)
Generates a values input format that can be passed to Java compiler.
|
String |
input1Term() |
String |
input2Term() |
boolean |
nullCheck() |
String |
outRecordTerm() |
String |
reuseConstructorCode(String className) |
String |
reuseInitCode() |
String |
reuseInputUnboxingCode() |
String |
reuseMemberCode() |
String |
reusePerRecordCode() |
GeneratedExpression |
visitCall(org.apache.calcite.rex.RexCall call) |
GeneratedExpression |
visitCorrelVariable(org.apache.calcite.rex.RexCorrelVariable correlVariable) |
GeneratedExpression |
visitDynamicParam(org.apache.calcite.rex.RexDynamicParam dynamicParam) |
GeneratedExpression |
visitFieldAccess(org.apache.calcite.rex.RexFieldAccess rexFieldAccess) |
GeneratedExpression |
visitInputRef(org.apache.calcite.rex.RexInputRef inputRef) |
GeneratedExpression |
visitLiteral(org.apache.calcite.rex.RexLiteral literal) |
GeneratedExpression |
visitLocalRef(org.apache.calcite.rex.RexLocalRef localRef) |
GeneratedExpression |
visitOver(org.apache.calcite.rex.RexOver over) |
GeneratedExpression |
visitRangeRef(org.apache.calcite.rex.RexRangeRef rangeRef) |
GeneratedExpression |
visitSubQuery(org.apache.calcite.rex.RexSubQuery subQuery) |
public CodeGenerator(TableConfig config, boolean nullableInput, TypeInformation<Object> input1, scala.Option<TypeInformation<Object>> input2, scala.Option<int[]> input1PojoFieldMapping, scala.Option<int[]> input2PojoFieldMapping)
public CodeGenerator(TableConfig config, boolean nullableInput, TypeInformation<Object> input, int[] inputPojoFieldMapping)
Function
s with one input.
config
- configuration that determines runtime behaviornullableInput
- input(s) can be null.input
- type information about the input of the FunctioninputPojoFieldMapping
- additional mapping information necessary if input is a
POJO (POJO types have no deterministic field order).public CodeGenerator(TableConfig config)
config
- configuration that determines runtime behaviorpublic String reuseMemberCode()
public String reuseInitCode()
public String reusePerRecordCode()
public String reuseInputUnboxingCode()
public String reuseConstructorCode(String className)
public String input1Term()
public String input2Term()
public String collectorTerm()
public String outRecordTerm()
public boolean nullCheck()
public GeneratedExpression generateExpression(org.apache.calcite.rex.RexNode rex)
rex
- Calcite row expressionpublic <T extends Function> GeneratedFunction<T> generateFunction(String name, Class<T> clazz, String bodyCode, TypeInformation<Object> returnType)
Function
that can be passed to Java
compiler.
name
- Class name of the Function. Must not be unique but has to be a valid Java class
identifier.clazz
- Flink Function to be generated.bodyCode
- code contents of the SAM (Single Abstract Method). Inputs, collector, or
output record can be accessed via the given term methods.returnType
- expected return typepublic <T> GeneratedFunction<GenericInputFormat<T>> generateValuesInputFormat(String name, scala.collection.Seq<String> records, TypeInformation<Object> returnType)
name
- Class name of the input format. Must not be unique but has to be a
valid Java class identifier.records
- code for creating recordsreturnType
- expected return typepublic GeneratedCollector generateTableFunctionCollector(String name, String bodyCode, TypeInformation<Object> collectedType)
TableFunctionCollector
that can be passed to Java compiler.
name
- Class name of the table function collector. Must not be unique but has to be a
valid Java class identifier.bodyCode
- body code for the collector methodcollectedType
- The type information of the element collected by the collectorpublic GeneratedExpression generateConverterResultExpression(TypeInformation<?> returnType, scala.collection.Seq<String> resultFieldNames)
outRecordTerm
).
returnType
- conversion target type. Inputs and output must have the same arity.resultFieldNames
- result field names necessary for a mapping to POJO fields.public scala.Tuple2<scala.collection.Seq<GeneratedExpression>,scala.collection.Seq<GeneratedExpression>> generateCorrelateAccessExprs()
public GeneratedExpression generateResultExpression(TypeInformation<?> returnType, scala.collection.Seq<String> resultFieldNames, scala.collection.Seq<org.apache.calcite.rex.RexNode> rexNodes)
outRecordTerm
).
returnType
- conversion target type. Type must have the same arity than rexNodes.resultFieldNames
- result field names necessary for a mapping to POJO fields.rexNodes
- sequence of RexNode to be convertedpublic GeneratedExpression generateResultExpression(scala.collection.Seq<GeneratedExpression> fieldExprs, TypeInformation<?> returnType, scala.collection.Seq<String> resultFieldNames)
outRecordTerm
).
fieldExprs
- field expressions to be convertedreturnType
- conversion target type. Type must have the same arity than fieldExprs.resultFieldNames
- result field names necessary for a mapping to POJO fields.public GeneratedExpression visitInputRef(org.apache.calcite.rex.RexInputRef inputRef)
visitInputRef
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitFieldAccess(org.apache.calcite.rex.RexFieldAccess rexFieldAccess)
visitFieldAccess
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitLiteral(org.apache.calcite.rex.RexLiteral literal)
visitLiteral
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitCorrelVariable(org.apache.calcite.rex.RexCorrelVariable correlVariable)
visitCorrelVariable
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitLocalRef(org.apache.calcite.rex.RexLocalRef localRef)
visitLocalRef
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitRangeRef(org.apache.calcite.rex.RexRangeRef rangeRef)
visitRangeRef
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitDynamicParam(org.apache.calcite.rex.RexDynamicParam dynamicParam)
visitDynamicParam
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitCall(org.apache.calcite.rex.RexCall call)
visitCall
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitOver(org.apache.calcite.rex.RexOver over)
visitOver
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression visitSubQuery(org.apache.calcite.rex.RexSubQuery subQuery)
visitSubQuery
in interface org.apache.calcite.rex.RexVisitor<GeneratedExpression>
public GeneratedExpression generateNonNullLiteral(TypeInformation<?> literalType, String literalCode)
public GeneratedExpression generateSymbol(Enum<?> enum_)
public GeneratedExpression generateInputFieldUnboxing(TypeInformation<?> fieldType, String fieldTerm)
fieldType
- type of fieldfieldTerm
- expression term of field to be unboxedpublic GeneratedExpression generateOutputFieldBoxing(GeneratedExpression expr)
expr
- expression to be boxedpublic void addReusableOutRecord(TypeInformation<?> ti)
Function
.
The passed TypeInformation
defines the type class to be instantiated.
ti
- type information of type class to be instantiated during runtimepublic String addReusablePrivateFieldAccess(Class<?> clazz, String fieldName)
Field
to the member area of the generated Function
.
The field can be used for accessing POJO fields more efficiently during runtime, however,
the field does not have to be public.
clazz
- class of containing fieldfieldName
- name of field to be extracted and instantiated during runtimepublic String addReusableDecimal(BigDecimal decimal)
BigDecimal
to the member area of the generated Function
.
decimal
- decimal object to be instantiated during runtimepublic String addReusableFunction(UserDefinedFunction function)
UserDefinedFunction
to the member area of the generated Function
.
The UserDefinedFunction
must have a default constructor, however, it does not have
to be public.
function
- UserDefinedFunction
object to be instantiated during runtimepublic String[] addReusableConstructor(scala.collection.Seq<Class<?>> parameterTypes)
parameterTypes
- The parameter types to construct the functionpublic String addReusableArray(Class<?> clazz, int size)
Function
.public String addReusableTimestamp()
Function
.public String addReusableLocalTimestamp()
Function
.public String addReusableTime()
Function
.public String addReusableLocalTime()
Function
.public String addReusableDate()
Function
.Copyright © 2014–2017 The Apache Software Foundation. All rights reserved.