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

GenerateUnsafeProjection

GenerateUnsafeProjection

GenerateUnsafeProjection is a CodeGenerator that generates the bytecode for a UnsafeProjection for given expressions (i.e. CodeGenerator[Seq[Expression], UnsafeProjection]).

Tip

Enable DEBUG logging level for org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection logger to see what happens inside.

Add the following line to conf/log4j.properties:

Refer to Logging.

Generating UnsafeProjection — generate Method

generate canonicalize the input expressions followed by generating a JVM bytecode for a UnsafeProjection for the expressions.

Note

generate is used when:

canonicalize Method

canonicalize removes unnecessary Alias expressions.

Internally, canonicalize uses ExpressionCanonicalizer rule executor (that in turn uses just one CleanExpressions expression rule).

Generating JVM Bytecode For UnsafeProjection For Given Expressions (With Optional Subexpression Elimination) — create Method

  1. Calls the former create with subexpressionEliminationEnabled flag off

create first creates a CodegenContext and an Java source code for the input expressions.

create creates a code body with public java.lang.Object generate(Object[] references) method that creates a SpecificUnsafeProjection.

create creates a CodeAndComment with the code body and comment placeholders.

You should see the following DEBUG message in the logs:

Tip

Enable DEBUG logging level for org.apache.spark.sql.catalyst.expressions.codegen.CodeGenerator logger to see the message above.

create requests CodegenContext for references and requests the compiled class to create a SpecificUnsafeProjection for the input references that in the end is the final UnsafeProjection.

Note
(Single-argument) create is part of CodeGenerator Contract.

Creating ExprCode for Expressions (With Optional Subexpression Elimination) — createCode Method

createCode requests the input CodegenContext to generate a Java source code for code-generated evaluation of every expression in the input expressions.

createCode…​FIXME

Note

createCode is used when:

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

关注公众号:spark技术分享

联系我们联系我们

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

支付宝扫一扫打赏

微信扫一扫打赏