Class ClassGenerator<T>

java.lang.Object
org.apache.drill.exec.expr.ClassGenerator<T>

public class ClassGenerator<T> extends Object
  • Field Details

    • DEFAULT_SCALAR_MAP

      public static final GeneratorMapping DEFAULT_SCALAR_MAP
    • DEFAULT_CONSTANT_MAP

      public static final GeneratorMapping DEFAULT_CONSTANT_MAP
    • INNER_CLASS_FIELD_NAME

      public static final String INNER_CLASS_FIELD_NAME
      See Also:
    • clazz

      public final com.sun.codemodel.JDefinedClass clazz
  • Method Details

    • getDefaultMapping

      public static MappingSet getDefaultMapping()
    • getInnerGenerator

      public ClassGenerator<T> getInnerGenerator(String name)
    • getMappingSet

      public MappingSet getMappingSet()
    • setMappingSet

      public void setMappingSet(MappingSet mappings)
    • getCodeGenerator

      public CodeGenerator<T> getCodeGenerator()
    • getBlock

      public com.sun.codemodel.JBlock getBlock(String methodName)
    • getBlock

      public com.sun.codemodel.JBlock getBlock(ClassGenerator.BlockType type)
    • 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

      public com.sun.codemodel.JLabel getEvalBlockLabel(String prefix)
    • 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 from fieldId and initializes it using setup blocks.
      Parameters:
      batchName - expression for invoking getValueAccessorById method
      fieldId - metadata of the field that should be declared
      Returns:
      a newly generated class field
    • addExpr

    • addExpr

    • rotateBlock

      public void rotateBlock()
    • getModel

      public com.sun.codemodel.JCodeModel getModel()
    • getNextVar

      public String getNextVar()
    • getNextVar

      public String getNextVar(String prefix)
    • declareClassField

      public com.sun.codemodel.JVar declareClassField(String prefix, com.sun.codemodel.JType t)
    • 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 field
      t - the type of class field
      init - init expression
      function - 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>,org.apache.drill.shaded.guava.com.google.common.base.Function<DrillBuf,? extends ValueHolder>> getConstantVars()
    • declare

    • declare

      public ClassGenerator.HoldingContainer declare(TypeProtos.MajorType t, boolean includeNewInstance)
    • 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 type
      name - variable name
      includeNewInstance - whether to create new instance
      Returns:
      holder instance
    • getWorkspaceTypes

      public List<TypedFieldId> getWorkspaceTypes()
    • getWorkspaceVectors

      public Map<WorkspaceReference,com.sun.codemodel.JVar> 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

      public com.sun.codemodel.JType getHolderType(TypeProtos.MajorType t)