package codegen
A collection of generators that build custom bytecode at runtime for performing the evaluation of catalyst expression.
- Alphabetic
- By Inheritance
- codegen
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- abstract class BaseMutableProjection extends MutableProjection
-
abstract
class
BaseProjection extends Projection
Java can not access Projection (in package object)
-
trait
Block extends TreeNode[Block] with JavaCode
A trait representing a block of java code.
-
case class
ByteCodeStats(maxMethodCodeSize: Int, maxConstPoolSize: Int, numInnerClasses: Int) extends Product with Serializable
Java bytecode statistics of a compiled class by Janino.
-
class
CodeAndComment extends Serializable
A wrapper for the source code to be compiled by CodeGenerator.
-
case class
CodeBlock(codeParts: Seq[String], blockInputs: Seq[JavaCode]) extends TreeNode[Block] with Block with Product with Serializable
A block of java code.
A block of java code. Including a sequence of code parts and some inputs to this block. The actual java code is generated by embedding the inputs into the code parts. Here we keep inputs of
JavaCodeinstead of simply folding them as a string of code, because we need to track expressions (ExprValue) in this code block. We need to be able to manipulate the expressions later without changing the behavior of this code block in some applications, e.g., method splitting. -
abstract
class
CodeGenerator[InType <: AnyRef, OutType <: AnyRef] extends Logging
A base class for generators of byte code to perform expression evaluation.
A base class for generators of byte code to perform expression evaluation. Includes a set of helpers for referring to Catalyst types and building trees that perform evaluation of individual expressions.
-
class
CodegenContext extends Logging
A context for codegen, tracking a list of objects that could be passed into generated Java function.
-
trait
CodegenFallback extends Expression
A trait that can be used to provide a fallback mode for expression code generation.
-
case class
ExprCode(code: Block, isNull: ExprValue, value: ExprValue) extends Product with Serializable
Java source for evaluating an Expression given a InternalRow of input.
Java source for evaluating an Expression given a InternalRow of input.
- code
The sequence of statements required to evaluate the expression. It should be empty string, if
isNullandvalueare already existed, or no code needed to evaluate them (literals).- isNull
A term that holds a boolean value representing whether the expression evaluated to null.
- value
A term for a (possibly primitive) value of the result of the evaluation. Not valid if
isNullis set totrue.
-
trait
ExprValue extends JavaCode
A typed java fragment that must be a valid java expression.
-
abstract
class
GeneratedClass extends AnyRef
A wrapper for generated class, defines a
generatemethod so that we can pass extra objects into generated class. -
case class
GlobalValue(value: String, javaType: Class[_]) extends ExprValue with Product with Serializable
A global variable java expression.
-
case class
Inline(codeString: String) extends JavaCode with Product with Serializable
A piece of java code snippet inlines all types of input arguments into a string without tracking any reference of
JavaCodeinstances. -
trait
JavaCode extends AnyRef
Trait representing an opaque fragments of java code.
-
class
LazilyGeneratedOrdering extends Ordering[InternalRow] with KryoSerializable
A lazily generated row ordering comparator.
-
class
LiteralValue extends ExprValue with Serializable
A literal java expression.
-
case class
SimpleExprValue(expr: String, javaType: Class[_]) extends ExprValue with Product with Serializable
A java expression fragment.
-
case class
SubExprCodes(codes: Seq[String], states: Map[Expression, SubExprEliminationState]) extends Product with Serializable
Codes and common subexpressions mapping used for subexpression elimination.
Codes and common subexpressions mapping used for subexpression elimination.
- codes
Strings representing the codes that evaluate common subexpressions.
- states
Foreach expression that is participating in subexpression elimination, the state to use.
-
case class
SubExprEliminationState(isNull: ExprValue, value: ExprValue) extends Product with Serializable
State used for subexpression elimination.
State used for subexpression elimination.
- isNull
A term that holds a boolean value representing whether the expression evaluated to null.
- value
A term for a value of a common sub-expression. Not valid if
isNullis set totrue.
-
final
class
UnsafeArrayWriter extends UnsafeWriter
A helper class to write data into global row buffer using
UnsafeArrayDataformat, used byorg.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection. - abstract class UnsafeRowJoiner extends AnyRef
-
final
class
UnsafeRowWriter extends UnsafeWriter
A helper class to write data into global row buffer using
UnsafeRowformat.A helper class to write data into global row buffer using
UnsafeRowformat.It will remember the offset of row buffer which it starts to write, and move the cursor of row buffer while writing. If new data(can be the input record if this is the outermost writer, or nested struct if this is an inner writer) comes, the starting cursor of row buffer may be changed, so we need to call
UnsafeRowWriter.resetRowWriterbefore writing, to update thestartingOffsetand clear out null bits.Note that if this is the outermost writer, which means we will always write from the very beginning of the global row buffer, we don't need to update
startingOffsetand can just callzeroOutNullBytesbefore writing new data. -
abstract
class
UnsafeWriter extends AnyRef
Base class for writing Unsafe* structures.
-
case class
VariableValue(variableName: String, javaType: Class[_]) extends ExprValue with Product with Serializable
A local variable java expression.
Value Members
- object Block
- object ByteCodeStats extends Serializable
-
object
CodeFormatter
An utility class that indents a block of code based on the curly braces and parentheses.
An utility class that indents a block of code based on the curly braces and parentheses. This is used to prettify generated code when in debug mode (or exceptions).
Written by Matei Zaharia.
- object CodeGenerator extends Logging
-
object
DumpByteCode
Dumps the bytecode from a class to the screen using javap.
- object EmptyBlock extends TreeNode[Block] with Block with Serializable with Product
- object ExprCode extends Serializable
- object ExprValue
-
object
ExpressionCanonicalizer extends RuleExecutor[Expression]
Canonicalizes an expression so those that differ only by names can reuse the same code.
- object FalseLiteral extends LiteralValue with Product with Serializable
-
object
GenerateMutableProjection extends CodeGenerator[Seq[Expression], MutableProjection]
Generates byte code that produces a InternalRow object that can update itself based on a new input InternalRow for a fixed set of Expressions.
Generates byte code that produces a InternalRow object that can update itself based on a new input InternalRow for a fixed set of Expressions. It exposes a
targetmethod, which is used to set the row that will be updated. The internal InternalRow object created internally is used only whentargetis not used. -
object
GenerateOrdering extends CodeGenerator[Seq[SortOrder], BaseOrdering] with Logging
Generates bytecode for an Ordering of rows for a given set of expressions.
-
object
GeneratePredicate extends CodeGenerator[Expression, BasePredicate]
Generates bytecode that evaluates a boolean Expression on a given input InternalRow.
-
object
GenerateSafeProjection extends CodeGenerator[Seq[Expression], Projection]
Generates byte code that produces a InternalRow object (not an UnsafeRow) that can update itself based on a new input InternalRow for a fixed set of Expressions.
-
object
GenerateUnsafeProjection extends CodeGenerator[Seq[Expression], UnsafeProjection]
Generates a Projection that returns an UnsafeRow.
Generates a Projection that returns an UnsafeRow.
It generates the code for all the expressions, computes the total length for all the columns (can be accessed via variables), and then copies the data into a scratch buffer space in the form of UnsafeRow (the scratch buffer will grow as needed).
- Note
The returned UnsafeRow will be pointed to a scratch buffer inside the projection.
-
object
GenerateUnsafeRowJoiner extends CodeGenerator[(StructType, StructType), UnsafeRowJoiner]
A code generator for concatenating two UnsafeRows into a single UnsafeRow.
A code generator for concatenating two UnsafeRows into a single UnsafeRow.
The high level algorithm is:
1. Concatenate the two bitsets together into a single one, taking padding into account. 2. Move fixed-length data. 3. Move variable-length data. 4. Update the offset position (i.e. the upper 32 bits in the fixed length part) for all variable-length data.
-
object
JavaCode
Utility functions for creating JavaCode fragments.
- object LazilyGeneratedOrdering extends Serializable
- object TrueLiteral extends LiteralValue with Product with Serializable