Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,15 @@ class CodeGenerationSuite extends SparkFunSuite with ExpressionEvalHelper {
}

test("SPARK-18091: split large if expressions into blocks due to JVM code size limit") {

Choose a reason for hiding this comment

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

@cloud-fan Just confirming, have you made sure that this test fails without the fix for SPARK-18091?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean? this test was added by SPARK-18091

Copy link

@kapilsingh5050 kapilsingh5050 Dec 10, 2016

Choose a reason for hiding this comment

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

This test simulates the scenario where large code for components of If expression causes JVM's method code size limit to be hit. So the point of having this test is if it fails before the fix for SPARK-18091 was committed and it passes afterwards. By failure I mean it gets terminated due to the method code size limit exceeded exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea of course, I reverted SPARK-18091 and ran this test locally, it failed.

Choose a reason for hiding this comment

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

great!

val inStr = "StringForTesting"
val row = create_row(inStr)
val inputStrAttr = 'a.string.at(0)

var strExpr: Expression = inputStrAttr
for (_ <- 1 to 13) {
strExpr = If(EqualTo(Decode(Encode(strExpr, "utf-8"), "utf-8"), inputStrAttr),
strExpr, strExpr)
var strExpr: Expression = Literal("abc")
for (_ <- 1 to 150) {
strExpr = Decode(Encode(strExpr, "utf-8"), "utf-8")
}

val expressions = Seq(strExpr)
val plan = GenerateUnsafeProjection.generate(expressions, true)
val actual = plan(row).toSeq(expressions.map(_.dataType))
val expected = Seq(UTF8String.fromString(inStr))
val expressions = Seq(If(EqualTo(strExpr, strExpr), strExpr, strExpr))
val plan = GenerateMutableProjection.generate(expressions)
val actual = plan(null).toSeq(expressions.map(_.dataType))
val expected = Seq(UTF8String.fromString("abc"))

if (!checkResult(actual, expected)) {
fail(s"Incorrect Evaluation: expressions: $expressions, actual: $actual, expected: $expected")
Expand Down