Package org.apache.drill.exec.expr
Class ClassGenerator<T>
java.lang.Object
org.apache.drill.exec.expr.ClassGenerator<T>
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
static enum
static class
Represents a (Nullable)?(Type)Holder instance. -
Field Summary
Modifier and TypeFieldDescriptionfinal com.sun.codemodel.JDefinedClass
static final GeneratorMapping
static final GeneratorMapping
static final String
-
Method Summary
Modifier and TypeMethodDescriptionprotected com.sun.codemodel.JBlock
Creates an inner braced and indented block for evaluation of the expression.declare
(TypeProtos.MajorType t, boolean includeNewInstance) declare
(TypeProtos.MajorType t, String name, boolean includeNewInstance) Adds a local variable declaration based on given name and type.org.apache.calcite.util.Pair<Integer,
com.sun.codemodel.JVar> declareClassConstField
(String prefix, com.sun.codemodel.JType t, com.sun.codemodel.JExpression init, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ? extends ValueHolder> function) Declare a constant field for the class.org.apache.calcite.util.Pair<Integer,
com.sun.codemodel.JVar> declareClassConstField
(String prefix, com.sun.codemodel.JType t, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ? extends ValueHolder> function) com.sun.codemodel.JVar
declareClassField
(String prefix, com.sun.codemodel.JType t) com.sun.codemodel.JVar
declareClassField
(String prefix, com.sun.codemodel.JType t, com.sun.codemodel.JExpression init) com.sun.codemodel.JVar
declareVectorValueSetupAndMember
(String batchName, TypedFieldId fieldId) com.sun.codemodel.JVar
declareVectorValueSetupAndMember
(DirectExpression batchName, TypedFieldId fieldId) Creates class variable for the value vector using metadata fromfieldId
and initializes it using setup blocks.com.sun.codemodel.JBlock
com.sun.codemodel.JBlock
com.sun.codemodel.JBlock
Map<org.apache.calcite.util.Pair<Integer,
com.sun.codemodel.JVar>, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ? extends ValueHolder>> static MappingSet
com.sun.codemodel.JBlock
com.sun.codemodel.JLabel
getEvalBlockLabel
(String prefix) com.sun.codemodel.JType
getInnerGenerator
(String name) com.sun.codemodel.JCodeModel
getModel()
getNextVar
(String prefix) com.sun.codemodel.JBlock
com.sun.codemodel.JBlock
Map<WorkspaceReference,
com.sun.codemodel.JVar> void
nestEvalBlock
(com.sun.codemodel.JBlock block) void
Prepare the generated class for use as a plain-old Java class (to be compiled by a compiler and directly loaded without a byte-code merge.void
void
setMappingSet
(MappingSet mappings) void
-
Field Details
-
DEFAULT_SCALAR_MAP
-
DEFAULT_CONSTANT_MAP
-
INNER_CLASS_FIELD_NAME
- See Also:
-
clazz
public final com.sun.codemodel.JDefinedClass clazz
-
-
Method Details
-
getDefaultMapping
-
getInnerGenerator
-
getMappingSet
-
setMappingSet
-
getCodeGenerator
-
getBlock
-
getBlock
-
getSetupBlock
public com.sun.codemodel.JBlock getSetupBlock() -
getEvalBlock
public com.sun.codemodel.JBlock getEvalBlock() -
getResetBlock
public com.sun.codemodel.JBlock getResetBlock() -
getCleanupBlock
public com.sun.codemodel.JBlock getCleanupBlock() -
nestEvalBlock
public void nestEvalBlock(com.sun.codemodel.JBlock block) -
unNestEvalBlock
public void unNestEvalBlock() -
getEvalBlockLabel
-
createInnerEvalBlock
protected com.sun.codemodel.JBlock createInnerEvalBlock()Creates an inner braced and indented block for evaluation of the expression.- Returns:
- a newly created inner eval block
-
declareVectorValueSetupAndMember
public com.sun.codemodel.JVar declareVectorValueSetupAndMember(String batchName, TypedFieldId fieldId) -
declareVectorValueSetupAndMember
public com.sun.codemodel.JVar declareVectorValueSetupAndMember(DirectExpression batchName, TypedFieldId fieldId) Creates class variable for the value vector using metadata fromfieldId
and initializes it using setup blocks.- Parameters:
batchName
- expression for invokinggetValueAccessorById
methodfieldId
- metadata of the field that should be declared- Returns:
- a newly generated class field
-
addExpr
-
addExpr
public ClassGenerator.HoldingContainer addExpr(LogicalExpression ex, ClassGenerator.BlkCreateMode mode) -
rotateBlock
public void rotateBlock() -
getModel
public com.sun.codemodel.JCodeModel getModel() -
getNextVar
-
getNextVar
-
declareClassField
-
declareClassField
public com.sun.codemodel.JVar declareClassField(String prefix, com.sun.codemodel.JType t, com.sun.codemodel.JExpression init) -
declareClassConstField
public org.apache.calcite.util.Pair<Integer,com.sun.codemodel.JVar> declareClassConstField(String prefix, com.sun.codemodel.JType t, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ? extends ValueHolder> function) -
declareClassConstField
public org.apache.calcite.util.Pair<Integer,com.sun.codemodel.JVar> declareClassConstField(String prefix, com.sun.codemodel.JType t, com.sun.codemodel.JExpression init, org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ? extends ValueHolder> function) Declare a constant field for the class. The class field innerClassField will be created if innerClassGenerator exists.- Parameters:
prefix
- the prefix name of class fieldt
- the type of class fieldinit
- init expressionfunction
- holds the constant value which returns a value holder must be set to the class field when the class instance created.- Returns:
- the depth of nested class, class field
-
getConstantVars
public Map<org.apache.calcite.util.Pair<Integer,com.sun.codemodel.JVar>, getConstantVars()org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf, ? extends ValueHolder>> -
declare
-
declare
-
declare
public ClassGenerator.HoldingContainer declare(TypeProtos.MajorType t, String name, boolean includeNewInstance) Adds a local variable declaration based on given name and type.- Parameters:
t
- major typename
- variable nameincludeNewInstance
- whether to create new instance- Returns:
- holder instance
-
getWorkspaceTypes
-
getWorkspaceVectors
-
preparePlainJava
public void preparePlainJava()Prepare the generated class for use as a plain-old Java class (to be compiled by a compiler and directly loaded without a byte-code merge. Three additions are necessary:- The class must extend its template as we won't merge byte codes.
- A constructor is required to call the __DRILL_INIT__ method. If this is a nested class, then the constructor must include parameters defined by the base class.
- For each nested class, create a method that creates an instance of that nested class using a well-defined name. This method overrides the base class method defined for this purpose.
-
getHolderType
-