Skip to content

Commit

Permalink
address review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kiszk committed Nov 20, 2017
1 parent feecef0 commit b0e9092
Showing 1 changed file with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,32 +244,29 @@ case class Elt(children: Seq[Expression])
}
"""
} else {
var fullFuncName = ""
cases.reverse.zipWithIndex.map { case (s, index) =>
val prevFunc = if (index == 0) {
"null"
} else {
s"$fullFuncName(${ctx.INPUT_ROW}, $indexVal)"
}
var prevFunc = "null"
for (c <- cases.reverse) {
val funcName = ctx.freshName("eltFunc")
val funcBody = s"""
private UTF8String $funcName(InternalRow ${ctx.INPUT_ROW}, int $indexVal) {
UTF8String $stringVal = null;
switch ($indexVal) {
$s
$c
default:
return $prevFunc;
}
return $stringVal;
}
"""
fullFuncName = ctx.addNewFunction(funcName, funcBody)
val fullFuncName = ctx.addNewFunction(funcName, funcBody)
prevFunc = s"$fullFuncName(${ctx.INPUT_ROW}, $indexVal)"
}
s"UTF8String $stringVal = $fullFuncName(${ctx.INPUT_ROW}, ${indexVal});"
s"UTF8String $stringVal = $prevFunc;"
}

ev.copy(index.code + "\n" +
ev.copy(
s"""
${index.code}
final int $indexVal = ${index.value};
$codes
UTF8String ${ev.value} = $stringVal;
Expand Down

0 comments on commit b0e9092

Please sign in to comment.