Skip to content

Commit

Permalink
skip repeated checking on convert function
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Oct 29, 2024
1 parent d3520dd commit 977d215
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ trait TColumnGenerator[RowT] extends TRowSetColumnGetter[RowT] {
convertFunc: (RowT, Int) => T = null): (JList[T], ByteBuffer) = {
val rowSize = rows.length
val ret = new JArrayList[T](rowSize)
val nulls = new JBitSet()
val nulls = new JBitSet(rowSize)
val isConvertFuncDefined = Option(convertFunc).isDefined
var idx = 0
rows.foreach { row =>
val isNull = isColumnNullAt(row, ordinal)
if (isNull) {
nulls.set(idx, true)
ret.add(defaultVal)
} else {
val value = Option(convertFunc) match {
case Some(f) => f(row, ordinal)
case _ => getColumnAs[T](row, ordinal)
val value = if (isConvertFuncDefined) {
convertFunc(row, ordinal)
} else {
getColumnAs[T](row, ordinal)
}
ret.add(value)
}
Expand Down

0 comments on commit 977d215

Please sign in to comment.