-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-8443][SQL] Split GenerateMutableProjection Codegen due to JVM Code Size Limits #7076
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 1 commit
9405680
1b5aa7e
adef95a
b7a7635
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,7 +46,7 @@ object GenerateMutableProjection extends CodeGenerator[Seq[Expression], () => Mu | |
| ${ctx.setColumn("mutableRow", e.dataType, i, evaluationCode.primitive)}; | ||
| """ | ||
| } | ||
| val partitionedProjectionCode = projectionCode.foldLeft(List.empty[String]) { | ||
| val projectionBlocks = projectionCode.foldLeft(List.empty[String]) { | ||
| (acc, code) => | ||
| acc match { | ||
| case Nil => List(code) | ||
|
|
@@ -58,19 +58,24 @@ object GenerateMutableProjection extends CodeGenerator[Seq[Expression], () => Mu | |
| code::acc | ||
| } | ||
| } | ||
| } | ||
| .zipWithIndex | ||
| .map { | ||
| case (body, i) => | ||
| s""" | ||
| private void apply$i(InternalRow i) { | ||
| $body | ||
| } | ||
| """ | ||
| } | ||
| val projectionCalls = ((partitionedProjectionCode.length - 1) to 0 by -1) | ||
| .map(i => s"apply$i(i);") | ||
| .mkString("\n") | ||
| val (projectionFuns, projectionCalls) = { | ||
| // inline execution if codesize limit was not broken | ||
| if (projectionBlocks.length == 1) { | ||
| ("", projectionBlocks.head) | ||
| } else { | ||
| ( | ||
| projectionBlocks.zipWithIndex.map { case (body, i) => | ||
| s""" | ||
| |private void apply$i(InternalRow i) { | ||
| | $body | ||
| |} | ||
| """.stripMargin | ||
| }.mkString, | ||
|
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. Similarly, should this be
Contributor
Author
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. Similar to above. The lines of
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. SGTM. |
||
| ((projectionBlocks.length - 1) to 0 by -1).map(i => s"apply$i(i);").mkString("\n") | ||
| ) | ||
| } | ||
| } | ||
| val mutableStates = ctx.mutableStates.map { case (javaType, variableName, initialValue) => | ||
| s"private $javaType $variableName = $initialValue;" | ||
| }.mkString("\n ") | ||
|
|
@@ -100,7 +105,7 @@ object GenerateMutableProjection extends CodeGenerator[Seq[Expression], () => Mu | |
| return (InternalRow) mutableRow; | ||
| } | ||
|
|
||
| ${partitionedProjectionCode.mkString("\n")} | ||
| $projectionFuns | ||
|
|
||
| public Object apply(Object _i) { | ||
| InternalRow i = (InternalRow) _i; | ||
|
|
||
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.
would be great if you can rewrite the code to make it slightly less functional here. I'd actually prefer a more imperative version here