Skip to content

Commit

Permalink
[KYUUBI #6786] Skip repeated checks on convert function in TColumnGen…
Browse files Browse the repository at this point in the history
…erator

# 🔍 Description
## Issue References 🔗

This pull request fixes #

## Describe Your Solution 🔧

- `TColumnGenerator` is used for generating column-based data. This PR skips repeated checks on checking nullability of the convert function in generating single column.

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklist 📝

- [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes #6786 from bowenliang123/skip-converfunc-check.

Closes #6786

f76f686 [Bowen Liang] nit
930dfef [Bowen Liang] fix
9712274 [Bowen Liang] comment
9db16ef [Bowen Liang] nit
977d215 [Bowen Liang] skip repeated checking on convert function

Authored-by: Bowen Liang <[email protected]>
Signed-off-by: Bowen Liang <[email protected]>
  • Loading branch information
bowenliang123 committed Nov 12, 2024
1 parent b4838b4 commit c8b8922
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@ trait TColumnGenerator[RowT] extends TRowSetColumnGetter[RowT] {
val ret = new JArrayList[T](rowSize)
val nulls = new JBitSet()
var idx = 0
val isConvertFuncNull = convertFunc == null
rows.foreach { row =>
val isNull = isColumnNullAt(row, ordinal)
if (isNull) {
val value = if (isColumnNullAt(row, ordinal)) {
nulls.set(idx, true)
ret.add(defaultVal)
defaultVal
} else if (isConvertFuncNull) {
getColumnAs[T](row, ordinal)
} else {
val value = Option(convertFunc) match {
case Some(f) => f(row, ordinal)
case _ => getColumnAs[T](row, ordinal)
}
ret.add(value)
convertFunc(row, ordinal)
}
ret.add(value)
idx += 1
}
(ret, ByteBuffer.wrap(nulls.toByteArray))
Expand Down

0 comments on commit c8b8922

Please sign in to comment.