-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-9058][SQL] Split projectionCode if it is too large for JVM #7418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ object GenerateMutableProjection extends CodeGenerator[Seq[Expression], () => Mu | |
|
|
||
| protected def create(expressions: Seq[Expression]): (() => MutableProjection) = { | ||
| val ctx = newCodeGenContext() | ||
| val projectionCode = expressions.zipWithIndex.map { case (e, i) => | ||
| val projectionCodes = expressions.zipWithIndex.map { case (e, i) => | ||
| val evaluationCode = e.gen(ctx) | ||
| evaluationCode.code + | ||
| s""" | ||
|
|
@@ -45,10 +45,32 @@ object GenerateMutableProjection extends CodeGenerator[Seq[Expression], () => Mu | |
| else | ||
| ${ctx.setColumn("mutableRow", e.dataType, i, evaluationCode.primitive)}; | ||
| """ | ||
| }.mkString("\n") | ||
| } | ||
|
|
||
| val projectionCodeSegments = projectionCodes.grouped(50).toSeq.map(_.mkString("\n")) | ||
|
|
||
| val (projectionCode, projectionFuncs) = if (projectionCodeSegments.length == 1) { | ||
| (projectionCodeSegments(0), "") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, right! Here. Thanks for explanation. |
||
| } else { | ||
| val pCode = (0 until projectionCodeSegments.length).map { i => | ||
| s"projectSeg$i(_i);" | ||
| }.mkString("\n") | ||
|
|
||
| val pFuncs = (0 until projectionCodeSegments.length).map { i => | ||
| s""" | ||
| public void projectSeg$i(Object _i) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make it
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the codegen aim to inline the execution, probably we'd better not to increase the overhead for type casting. |
||
| InternalRow i = (InternalRow) _i; | ||
| ${projectionCodeSegments(i)} | ||
| } | ||
| """ | ||
| }.mkString("\n") | ||
| (pCode, pFuncs) | ||
| } | ||
|
|
||
| val mutableStates = ctx.mutableStates.map { case (javaType, variableName, initialValue) => | ||
| s"private $javaType $variableName = $initialValue;" | ||
| }.mkString("\n ") | ||
|
|
||
| val code = s""" | ||
| public Object generate($exprType[] expr) { | ||
| return new SpecificProjection(expr); | ||
|
|
@@ -75,6 +97,8 @@ object GenerateMutableProjection extends CodeGenerator[Seq[Expression], () => Mu | |
| return (InternalRow) mutableRow; | ||
| } | ||
|
|
||
| $projectionFuncs | ||
|
|
||
| public Object apply(Object _i) { | ||
| InternalRow i = (InternalRow) _i; | ||
| $projectionCode | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you decide this number '50' for the JVM code size limitation?