Skip to content

Commit

Permalink
Revert "Use local variables for resultIsNulls and argValues."
Browse files Browse the repository at this point in the history
This reverts commit f8acda6.
  • Loading branch information
ueshin committed Nov 18, 2016
1 parent f8acda6 commit fe2871c
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ trait InvokeLike extends Expression with NonSQLExpression {
def prepareArguments(ctx: CodegenContext): (String, String, String) = {

val resultIsNull = if (needNullCheck) {
ctx.freshName("resultIsNull")
val resultIsNull = ctx.freshName("resultIsNull")
ctx.addMutableState("boolean", resultIsNull, "")
resultIsNull
} else {
"false"
}
val argValues = arguments.map { e =>
ctx.freshName("argValue")
val argValue = ctx.freshName("argValue")
ctx.addMutableState(ctx.javaType(e.dataType), argValue, "")
argValue
}

val argCodes = if (needNullCheck) {
val reset = s"boolean $resultIsNull = false;"
val reset = s"$resultIsNull = false;"
val argCodes = arguments.zipWithIndex.map { case (e, i) =>
val expr = e.genCode(ctx)
val updateResultIsNull = if (e.nullable) {
Expand All @@ -77,7 +81,6 @@ trait InvokeLike extends Expression with NonSQLExpression {
""
}
s"""
${ctx.javaType(e.dataType)} ${argValues(i)} = ${ctx.defaultValue(e.dataType)};
if (!$resultIsNull) {
${expr.code}
$updateResultIsNull
Expand All @@ -91,11 +94,11 @@ trait InvokeLike extends Expression with NonSQLExpression {
val expr = e.genCode(ctx)
s"""
${expr.code}
${ctx.javaType(e.dataType)} ${argValues(i)} = ${expr.value};
${argValues(i)} = ${expr.value};
"""
}
}
val argCode = argCodes.mkString("\n")
val argCode = ctx.splitExpressions(ctx.INPUT_ROW, argCodes)

(argCode, argValues.mkString(", "), resultIsNull)
}
Expand Down

0 comments on commit fe2871c

Please sign in to comment.