Package org.apache.drill.exec.expr
Class ClassGenerator<T>
java.lang.Object
org.apache.drill.exec.expr.ClassGenerator<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic classRepresents a (Nullable)?(Type)Holder instance. -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal com.sun.codemodel.JDefinedClassstatic final GeneratorMappingstatic final GeneratorMappingstatic final String -
Method Summary
Modifier and TypeMethodDescriptionprotected com.sun.codemodel.JBlockCreates 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.google.common.base.Function<DrillBuf, ? extends ValueHolder> function) org.apache.calcite.util.Pair<Integer, com.sun.codemodel.JVar> declareClassConstField(String prefix, com.sun.codemodel.JType t, com.sun.codemodel.JExpression init, com.google.common.base.Function<DrillBuf, ? extends ValueHolder> function) Declare a constant field for the class.com.sun.codemodel.JVardeclareClassField(String prefix, com.sun.codemodel.JType t) com.sun.codemodel.JVardeclareClassField(String prefix, com.sun.codemodel.JType t, com.sun.codemodel.JExpression init) com.sun.codemodel.JVardeclareVectorValueSetupAndMember(String batchName, TypedFieldId fieldId) com.sun.codemodel.JVardeclareVectorValueSetupAndMember(DirectExpression batchName, TypedFieldId fieldId) Creates class variable for the value vector using metadata fromfieldIdand initializes it using setup blocks.com.sun.codemodel.JBlockcom.sun.codemodel.JBlockcom.sun.codemodel.JBlockMap<org.apache.calcite.util.Pair<Integer, com.sun.codemodel.JVar>, com.google.common.base.Function<DrillBuf, ? extends ValueHolder>> static MappingSetcom.sun.codemodel.JBlockcom.sun.codemodel.JLabelgetEvalBlockLabel(String prefix) com.sun.codemodel.JTypegetInnerGenerator(String name) com.sun.codemodel.JCodeModelgetModel()getNextVar(String prefix) com.sun.codemodel.JBlockcom.sun.codemodel.JBlockMap<WorkspaceReference, com.sun.codemodel.JVar> voidnestEvalBlock(com.sun.codemodel.JBlock block) voidPrepare 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.voidvoidsetMappingSet(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 fromfieldIdand initializes it using setup blocks.- Parameters:
batchName- expression for invokinggetValueAccessorByIdmethodfieldId- 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, 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, 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()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
-