Skip to content

Conversation

@kiszk
Copy link
Member

@kiszk kiszk commented Nov 18, 2017

What changes were proposed in this pull request?

This PR changes elt code generation to place generated code for expression for arguments into separated methods if these size could be large.
This PR resolved the case of elt with a lot of argument

How was this patch tested?

Added new test cases into StringExpressionsSuite

@SparkQA
Copy link

SparkQA commented Nov 18, 2017

Test build #83979 has finished for PR 19778 at commit 06b103e.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 18, 2017

Test build #83980 has finished for PR 19778 at commit feecef0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.


ev.copy(index.code + "\n" +
s"""
final int $indexVal = ${index.value};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

${index.code}
final int $indexVal = ${index.value};
...

"""
} else {
var fullFuncName = ""
cases.reverse.zipWithIndex.map { case (s, index) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to make it more imperative:

var prevFunc = "null"
for (case <- cases) {
  val funcName = ...
  val funcBody = ...
  prevFunc = ctx.addNewFunction
}
s"UTF8String $stringVal = $prevFunc(${ctx.INPUT_ROW}, $indexVal);"

@SparkQA
Copy link

SparkQA commented Nov 20, 2017

Test build #84032 has finished for PR 19778 at commit b0e9092.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

}
}

def splitCodes(expressions: Seq[String]): Seq[String] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually split is not accurate here, how about groupCodes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: private. We also need to write a comment.

How about buildCodeBlocks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but it is not private. It is used in stringExpressions.

@cloud-fan
Copy link
Contributor

LGTM except one minor comment

@cloud-fan
Copy link
Contributor

LGTM pending jenkins

@SparkQA
Copy link

SparkQA commented Nov 21, 2017

Test build #84052 has finished for PR 19778 at commit 3822864.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Nov 21, 2017

Test build #84050 has finished for PR 19778 at commit e70e45c.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Nov 21, 2017

Test build #84060 has finished for PR 19778 at commit 3822864.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@asfgit asfgit closed this in 9bdff0b Nov 21, 2017
@cloud-fan
Copy link
Contributor

thanks, merging to master/2.2

asfgit pushed a commit that referenced this pull request Nov 21, 2017
This PR changes `elt` code generation to place generated code for expression for arguments into separated methods if these size could be large.
This PR resolved the case of `elt` with a lot of argument

Added new test cases into `StringExpressionsSuite`

Author: Kazuaki Ishizaki <[email protected]>

Closes #19778 from kiszk/SPARK-22550.

(cherry picked from commit 9bdff0b)
Signed-off-by: Wenchen Fan <[email protected]>
for (c <- cases.reverse) {
val funcName = ctx.freshName("eltFunc")
val funcBody = s"""
private UTF8String $funcName(InternalRow ${ctx.INPUT_ROW}, int $indexVal) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this splitting doesn't prevent the case in wholestage codegen?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah good catch! we should fix it with splitExpressionsWithCurrentInputs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Proposes a fix in #19964.

MatthewRBruce pushed a commit to Shopify/spark that referenced this pull request Jul 31, 2018
This PR changes `elt` code generation to place generated code for expression for arguments into separated methods if these size could be large.
This PR resolved the case of `elt` with a lot of argument

Added new test cases into `StringExpressionsSuite`

Author: Kazuaki Ishizaki <[email protected]>

Closes apache#19778 from kiszk/SPARK-22550.

(cherry picked from commit 9bdff0b)
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants