关注 spark技术分享,
撸spark源码 玩spark最佳实践

CodegenContext

CodegenContext

CodegenContext is…​FIXME

CodegenContext takes no input parameters.

CodegenContext is created when:

CodegenContext stores expressions that don’t support codegen.

Table 1. CodegenContext’s Internal Properties (e.g. Registries, Counters and Flags)
Name Description

classFunctions

Mutable Scala Map with function names, their Java source code and a class name

New entries are added when CodegenContext is requested to addClass and addNewFunctionToClass

Used when CodegenContext is requested to declareAddedFunctions

equivalentExpressions

Expressions are added and then fetched as equivalent sets when CodegenContext is requested to subexpressionElimination (for generateExpressions with subexpression elimination enabled)

currentVars

The list of generated columns as input of current operator

INPUT_ROW

The variable name of the input row of the current operator

placeHolderToComments

Placeholders and their comments

Used when…​FIXME

references

References that are used to generate classes in the following code generators:

subExprEliminationExprs

SubExprEliminationStates by Expression

Used when…​FIXME

subexprFunctions

Names of the functions that…​FIXME

Generating Java Source Code For Code-Generated Evaluation of Multiple Expressions (With Optional Subexpression Elimination) — generateExpressions Method

(only with subexpression elimination enabled) generateExpressions does subexpressionElimination of the input expressions.

In the end, generateExpressions requests every expressions to generate the Java source code for code-generated (non-interpreted) expression evaluation.

Note

generateExpressions is used when:

addReferenceObj Method

addReferenceObj…​FIXME

Note
addReferenceObj is used when…​FIXME

subexpressionEliminationForWholeStageCodegen Method

subexpressionEliminationForWholeStageCodegen…​FIXME

Note
subexpressionEliminationForWholeStageCodegen is used exclusively when HashAggregateExec is requested to generate a Java source code for whole-stage consume path (with grouping keys or not).

Adding Function to Generated Class — addNewFunction Method

addNewFunction…​FIXME

Note
addNewFunction is used when…​FIXME

subexpressionElimination Internal Method

subexpressionElimination requests EquivalentExpressions to addExprTree for every expression (in the input expressions).

subexpressionElimination requests EquivalentExpressions for the equivalent sets of expressions with at least two equivalent expressions (aka common expressions).

For every equivalent expression set, subexpressionElimination does the following:

  1. Takes the first expression and requests it to generate a Java source code for the expression tree

  2. addNewFunction and adds it to subexprFunctions

  3. Creates a SubExprEliminationState and adds it with every common expression in the equivalent expression set to subExprEliminationExprs

Note
subexpressionElimination is used exclusively when CodegenContext is requested to generateExpressions (with subexpression elimination enabled).

Adding Mutable State — addMutableState Method

addMutableState…​FIXME

Note
addMutableState is used when…​FIXME

Adding Immutable State (Unless Exists Already) — addImmutableStateIfNotExists Method

addImmutableStateIfNotExists…​FIXME

Note
addImmutableStateIfNotExists is used when…​FIXME

freshName Method

freshName…​FIXME

Note
freshName is used when…​FIXME

addNewFunctionToClass Internal Method

addNewFunctionToClass…​FIXME

Note
addNewFunctionToClass is used when…​FIXME

addClass Internal Method

addClass…​FIXME

Note
addClass is used when…​FIXME

declareAddedFunctions Method

declareAddedFunctions…​FIXME

Note
declareAddedFunctions is used when…​FIXME

declareMutableStates Method

declareMutableStates…​FIXME

Note
declareMutableStates is used when…​FIXME

initMutableStates Method

initMutableStates…​FIXME

Note
initMutableStates is used when…​FIXME

initPartition Method

initPartition…​FIXME

Note
initPartition is used when…​FIXME

emitExtraCode Method

emitExtraCode…​FIXME

Note
emitExtraCode is used when…​FIXME

addPartitionInitializationStatement Method

addPartitionInitializationStatement…​FIXME

Note
addPartitionInitializationStatement is used when…​FIXME
赞(0) 打赏
未经允许不得转载:spark技术分享 » CodegenContext
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏