Skip to content

Commit

Permalink
Do toArray once and lazily outside of eval().
Browse files Browse the repository at this point in the history
  • Loading branch information
concretevitamin committed Jun 12, 2014
1 parent bb3d109 commit 47d406a
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,10 @@ case class CaseWhen(branches: Seq[Expression]) extends Expression {
if (!childrenResolved) false else allCondBooleans && dataTypesEqual
}

private lazy val branchesArr = branches.toArray

/** Written in imperative fashion for performance considerations. Same for CaseKeyWhen. */
override def eval(input: Row): Any = {
val branchesArr = branches.toArray
val len = branchesArr.length
var i = 0
// If all branches fail and an elseVal is not provided, the whole statement
Expand Down Expand Up @@ -306,9 +307,10 @@ case class CaseKeyWhen(key: Expression, branches: Seq[Expression]) extends Expre
if (!childrenResolved) false else dataTypesEqual
}

private lazy val branchesArr = branches.toArray

override def eval(input: Row): Any = {
val evaledKey = key.eval(input)
val branchesArr = branches.toArray
val len = branchesArr.length
var i = 0
// If all branches fail and an elseVal is not provided, the whole statement
Expand Down

0 comments on commit 47d406a

Please sign in to comment.