Class

org.apache.spark.sql.catalyst.expressions.codegen

CodegenContext

Related Doc: package codegen

Permalink

class CodegenContext extends AnyRef

A context for codegen, tracking a list of objects that could be passed into generated Java function.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CodegenContext
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CodegenContext()

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final var INPUT_ROW: String

    Permalink

    The variable name of the input row in generated code.

  5. final val JAVA_BOOLEAN: String("boolean")

    Permalink
  6. final val JAVA_BYTE: String("byte")

    Permalink
  7. final val JAVA_DOUBLE: String("double")

    Permalink
  8. final val JAVA_FLOAT: String("float")

    Permalink
  9. final val JAVA_INT: String("int")

    Permalink
  10. final val JAVA_LONG: String("long")

    Permalink
  11. final val JAVA_SHORT: String("short")

    Permalink
  12. def addBufferedState(dataType: DataType, variableName: String, initCode: String): ExprCode

    Permalink

    Add buffer variable which stores data coming from an InternalRow.

    Add buffer variable which stores data coming from an InternalRow. This methods guarantees that the variable is safely stored, which is important for (potentially) byte array backed data types like: UTF8String, ArrayData, MapData & InternalRow.

  13. def addMutableState(javaType: String, variableName: String, initCode: String): Unit

    Permalink
  14. def addNewFunction(funcName: String, funcCode: String): Unit

    Permalink
  15. def addPartitionInitializationStatement(statement: String): Unit

    Permalink
  16. def addReferenceMinorObj(obj: Any, className: String = null): String

    Permalink

    Add an object to references.

    Add an object to references.

    Returns the code to access it.

    This is for minor objects not to store the object into field but refer it from the references field at the time of use because number of fields in class is limited so we should reduce it.

  17. def addReferenceObj(name: String, obj: Any, className: String = null): String

    Permalink

    Add an object to references, create a class member to access it.

    Add an object to references, create a class member to access it.

    Returns the name of class member.

  18. val addedFunctions: Map[String, String]

    Permalink

    Holding all the functions those will be added into generated class.

  19. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  20. def boxedType(dt: DataType): String

    Permalink
  21. def boxedType(jt: String): String

    Permalink

    Returns the boxed type in Java.

  22. def buildCodeBlocks(expressions: Seq[String]): Seq[String]

    Permalink

    Splits the generated code of expressions into multiple sequences of String based on a threshold of length of a String

    Splits the generated code of expressions into multiple sequences of String based on a threshold of length of a String

    expressions

    the codes to evaluate expressions.

  23. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. var copyResult: Boolean

    Permalink

    Whether should we copy the result rows or not.

    Whether should we copy the result rows or not.

    If any operator inside WholeStageCodegen generate multiple rows from a single row (for example, Join), this should be true.

    If an operator starts a new pipeline, this should be reset to false before calling consume().

  25. def createAndAddFunction(ev: ExprCode, dataType: DataType, baseFuncName: String): (String, String, String)

    Permalink

    Wrap the generated code of expression, which was created from a row object in INPUT_ROW, by a function.

    Wrap the generated code of expression, which was created from a row object in INPUT_ROW, by a function. ev.isNull and ev.value are passed by global variables

    ev

    the code to evaluate expressions.

    dataType

    the data type of ev.value.

    baseFuncName

    the split function name base.

  26. var currentVars: Seq[ExprCode]

    Permalink

    Holding a list of generated columns as input of current operator, will be used by BoundReference to generate code.

  27. def declareAddedFunctions(): String

    Permalink
  28. def declareMutableStates(): String

    Permalink
  29. def defaultValue(dt: DataType): String

    Permalink
  30. def defaultValue(jt: String): String

    Permalink

    Returns the representation of default value for a given Java Type.

  31. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  32. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  33. val equivalentExpressions: EquivalentExpressions

    Permalink

    Holds expressions that are equivalent.

    Holds expressions that are equivalent. Used to perform subexpression elimination during codegen.

    For expressions that appear more than once, generate additional code to prevent recomputing the value.

    For example, consider two expression generated from this SQL statement: SELECT (col1 + col2), (col1 + col2) / col3.

    equivalentExpressions will match the tree containing col1 + col2 and it will only be evaluated once.

  34. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  35. def freshName(name: String): String

    Permalink

    Returns a term name that is unique within this instance of a CodegenContext.

  36. var freshNamePrefix: String

    Permalink

    A prefix used to generate fresh name.

  37. def genComp(dataType: DataType, c1: String, c2: String): String

    Permalink

    Generates code for comparing two expressions.

    Generates code for comparing two expressions.

    dataType

    data type of the expressions

    c1

    name of the variable of expression 1's output

    c2

    name of the variable of expression 2's output

  38. def genEqual(dataType: DataType, c1: String, c2: String): String

    Permalink

    Generates code for equal expression in Java.

  39. def genGreater(dataType: DataType, c1: String, c2: String): String

    Permalink

    Generates code for greater of two expressions.

    Generates code for greater of two expressions.

    dataType

    data type of the expressions

    c1

    name of the variable of expression 1's output

    c2

    name of the variable of expression 2's output

  40. def generateExpressions(expressions: Seq[Expression], doSubexpressionElimination: Boolean = false): Seq[ExprCode]

    Permalink

    Generates code for expressions.

    Generates code for expressions. If doSubexpressionElimination is true, subexpression elimination will be performed. Subexpression elimination assumes that the code will for each expression will be combined in the expressions order.

  41. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  42. def getPlaceHolderToComments(): Map[String, String]

    Permalink

    get a map of the pair of a place holder and a corresponding comment

  43. def getValue(batch: String, row: String, dataType: DataType, ordinal: Int): String

    Permalink

    Returns the specialized code to access a value from a column vector for a given DataType.

  44. def getValue(input: String, dataType: DataType, ordinal: String): String

    Permalink

    Returns the specialized code to access a value from inputRow at ordinal.

  45. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  46. def initMutableStates(): String

    Permalink
  47. def initPartition(): String

    Permalink
  48. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  49. def isPrimitiveType(dt: DataType): Boolean

    Permalink
  50. def isPrimitiveType(jt: String): Boolean

    Permalink

    Returns true if the Java type has a special accessor and setter in InternalRow.

  51. def javaType(dt: DataType): String

    Permalink

    Returns the Java type for a DataType.

  52. val mutableStates: ArrayBuffer[(String, String, String)]

    Permalink

    Holding expressions' mutable states like MonotonicallyIncreasingID.count as a 3-tuple: java type, variable name, code to init it.

    Holding expressions' mutable states like MonotonicallyIncreasingID.count as a 3-tuple: java type, variable name, code to init it. As an example, ("int", "count", "count = 0;") will produce code:

    private int count;

    as a member variable, and add

    count = 0;

    to the constructor.

    They will be kept as member variables in generated classes like SpecificProjection.

  53. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  54. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  55. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  56. def nullSafeExec(nullable: Boolean, isNull: String)(execute: String): String

    Permalink

    Generates code to do null safe execution, i.e.

    Generates code to do null safe execution, i.e. only execute the code when the input is not null by adding null check if necessary.

    nullable

    used to decide whether we should add null check or not.

    isNull

    the code to check if the input is null.

    execute

    the code that should only be executed when the input is not null.

  57. val partitionInitializationStatements: ArrayBuffer[String]

    Permalink

    Code statements to initialize states that depend on the partition index.

    Code statements to initialize states that depend on the partition index. An integer partitionIndex will be made available within the scope.

  58. def primitiveTypeName(dt: DataType): String

    Permalink
  59. def primitiveTypeName(jt: String): String

    Permalink

    Returns the name used in accessor and setter for a Java primitive type.

  60. val primitiveTypes: Seq[String]

    Permalink

    List of java data types that have special accessors and setters in InternalRow.

  61. val references: ArrayBuffer[Any]

    Permalink

    Holding a list of objects that could be used passed into generated class.

  62. def registerComment(text: ⇒ String): String

    Permalink

    Register a comment and return the corresponding place holder

  63. def setColumn(row: String, dataType: DataType, ordinal: Int, value: String): String

    Permalink

    Returns the code to update a column in Row for a given DataType.

  64. def setValue(batch: String, row: String, dataType: DataType, ordinal: Int, value: String): String

    Permalink

    Returns the specialized code to set a given value in a column vector for a given DataType.

  65. def splitExpressions(expressions: Seq[String], funcName: String, arguments: Seq[(String, String)], returnType: String = "void", makeSplitFunction: (String) ⇒ String = identity, foldFunctions: (Seq[String]) ⇒ String = _.mkString("", ";\n", ";")): String

    Permalink

    Splits the generated code of expressions into multiple functions, because function has 64kb code size limit in JVM

    Splits the generated code of expressions into multiple functions, because function has 64kb code size limit in JVM

    expressions

    the codes to evaluate expressions.

    funcName

    the split function name base.

    arguments

    the list of (type, name) of the arguments of the split function.

    returnType

    the return type of the split function.

    makeSplitFunction

    makes split function body, e.g. add preparation or cleanup.

    foldFunctions

    folds the split function calls.

  66. def splitExpressions(row: String, expressions: Seq[String]): String

    Permalink

    Splits the generated code of expressions into multiple functions, because function has 64kb code size limit in JVM

    Splits the generated code of expressions into multiple functions, because function has 64kb code size limit in JVM

    row

    the variable name of row that is used by expressions

    expressions

    the codes to evaluate expressions.

  67. val subExprEliminationExprs: HashMap[Expression, SubExprEliminationState]

    Permalink
  68. val subexprFunctions: ArrayBuffer[String]

    Permalink
  69. def subexpressionEliminationForWholeStageCodegen(expressions: Seq[Expression]): SubExprCodes

    Permalink

    Checks and sets up the state and codegen for subexpression elimination.

    Checks and sets up the state and codegen for subexpression elimination. This finds the common subexpressions, generates the code snippets that evaluate those expressions and populates the mapping of common subexpressions to the generated code snippets. The generated code snippets will be returned and should be inserted into generated codes before these common subexpressions actually are used first time.

  70. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  71. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  72. def updateColumn(batch: String, row: String, dataType: DataType, ordinal: Int, ev: ExprCode, nullable: Boolean): String

    Permalink

    Returns the specialized code to set a given value in a column vector for a given DataType that could potentially be nullable.

  73. def updateColumn(row: String, dataType: DataType, ordinal: Int, ev: ExprCode, nullable: Boolean, isVectorized: Boolean = false): String

    Permalink

    Update a column in MutableRow from ExprCode.

    Update a column in MutableRow from ExprCode.

    isVectorized

    True if the underlying row is of type ColumnarBatch.Row, false otherwise

  74. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  75. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  76. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  77. def withSubExprEliminationExprs(newSubExprEliminationExprs: Map[Expression, SubExprEliminationState])(f: ⇒ Seq[ExprCode]): Seq[ExprCode]

    Permalink

    Perform a function which generates a sequence of ExprCodes with a given mapping between expressions and common expressions, instead of using the mapping in current context.

Inherited from AnyRef

Inherited from Any

Ungrouped