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

CodegenFallback

CodegenFallback Contract — Catalyst Expressions with Fallback Code Generation Mode

CodegenFallback is the contract of Catalyst expressions that do not support a Java code generation and want to fall back to interpreted mode (aka fallback mode).

CodegenFallback is used when CollapseCodegenStages physical optimization is requested to execute (and enforce whole-stage codegen requirements for Catalyst expressions).

Table 1. (Some Examples of) CodegenFallbacks
CodegenFallback Description

CurrentDate

CurrentTimestamp

Cube

JsonToStructs

Rollup

StructsToJson

Generating Java Source Code (ExprCode) For Code-Generated Expression Evaluation — doGenCode Method

Note
doGenCode is part of Expression Contract to generate a Java source code (ExprCode) for code-generated expression evaluation.

doGenCode requests the input CodegenContext to add itself to the references.

doGenCode walks down the expression tree to find Nondeterministic expressions and for every Nondeterministic expression does the following:

  1. Requests the input CodegenContext to add it to the references

  2. Requests the input CodegenContext to addPartitionInitializationStatement that is a Java code block as follows:

In the end, doGenCode generates a plain Java source code block that is one of the following code blocks per the nullable flag. doGenCode copies the input ExprCode with the code block added (as the code property).

赞(0) 打赏
未经允许不得转载:spark技术分享 » CodegenFallback
分享到: 更多 (0)

关注公众号:spark技术分享

联系我们联系我们

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

支付宝扫一扫打赏

微信扫一扫打赏