package udf
- Alphabetic
- Public
- All
Type Members
-
case class
BB(instructionTable: SortedMap[Int, Instruction]) extends Logging with Product with Serializable
A Basic Block (BB) is a set of instructions defined by instructionTable, where each entry in this table is a mapping of offset to Instruction.
A Basic Block (BB) is a set of instructions defined by instructionTable, where each entry in this table is a mapping of offset to Instruction.
The case class also provides some helpers, most importantly the propagateState helper which generates a map of BB to State.
-
case class
CFG(basicBlocks: List[BB], predecessor: Map[BB, List[BB]], successor: Map[BB, List[(Int, BB)]]) extends Product with Serializable
The Control Flow Graph object.
The Control Flow Graph object.
-
case class
CatalystExpressionBuilder(function: AnyRef) extends Logging with Product with Serializable
CatalystExpressionBuilder
CatalystExpressionBuilder
This compiles a scala lambda expression into a catalyst expression.
Here are the high-level steps:
1) Use SerializedLambda and javaassist to get a reflection based interface to
functionthis is done in LambdaReflection2) Obtain the Control Flow Graph (CFG) using the reflection interface obtained above.
3) Get catalyst
Expressionsbased on the basic blocks BB obtained in the CFG and simplify before replacing in the Spark Logical Plan.- function
the original Scala UDF provided by the user
- case class GpuScalaUDFLogical(udf: ScalaUDF) extends Expression with ShimExpression with Logging with Product with Serializable
- case class Instruction(opcode: Int, operand: Int, instructionStr: String) extends Logging with Product with Serializable
- class LambdaReflection extends AnyRef
- case class LogicalPlanRules() extends Rule[LogicalPlan] with Logging with Product with Serializable
- class Plugin extends (SparkSessionExtensions) ⇒ Unit with Logging
-
case class
State(locals: IndexedSeq[Expression], stack: List[Expression] = List(), cond: Expression = Literal.TrueLiteral, expr: Option[Expression] = None) extends Product with Serializable
State is used as the main representation of block state, as we walk the bytecode.
State is used as the main representation of block state, as we walk the bytecode.
Given a set of instructions, we will use State variables to track what happens to the stack.
The final State generated is later used to simplify expressions.
Example 1: { return 0 }
This is in java byte code: iconst 0 ireturn
iconst 0 => pushes 0 to stack ireturn => pops and returns
Example 2: { return 2 + 2 + 1 }
1) State(locals, empty stack, no condition, expr?) // expr ==it is no expression
iconst 2 NOTE: 2 is literal here so is 1 2) State(locals, 2::Nil, no condition, expr is still empty)
iconst 2 3) State(locals, 2::2::Nil, no condiiton...)
iadd (pop 2 and 2 + push 4 into stack) 4) State(locals, Add(2, 2)::Nil, no condition, expr is still empoty)
iconst 1 5) State(locals, 1::Add(2,2)::Nil, ..)
iadd (pop 1 and 4 + push 5 into sack) 6) Add(1, Add(2,2)) :: Nil
ireturn (pop 5 from stack) 7) return Add...
State == Add stack == lhs/rhs
Value Members
-
object
CFG extends Serializable
Companion object to generate a CFG instance given a LambdaReflection
-
object
CatalystExpressionBuilder extends Logging with Serializable
CatalystExpressionBuilder helper object, contains a function that is used to simplify a directly translated catalyst expression (from bytecode) into something simpler that the remaining catalyst optimizations can handle.
-
object
Instruction extends Serializable
Ultimately, every opcode will have to be covered here.
- object LambdaReflection
- object State extends Serializable