Skip to content

Commit

Permalink
Further improved.
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Mar 15, 2015
1 parent 746fcfb commit 385d5b0
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,15 @@ case class Cast(child: Expression, dataType: DataType) extends UnaryExpression w
case (fromField, toField) => cast(fromField.dataType, toField.dataType)
}
// TODO: Could be faster?
val newRow = new GenericMutableRow(from.fields.size)
buildCast[Row](_, row => {
var i = 0
val fields = row.toSeq.map {(v) =>
val f = if (v == null) null else casts(i)(v)
while (i < row.length) {
val v = row(i)
newRow.update(i, if (v == null) null else casts(i)(v))
i += 1
f
}
Row(fields: _*)
newRow.copy()
})
}

Expand Down

0 comments on commit 385d5b0

Please sign in to comment.