This is an automated email from the ASF dual-hosted git repository.
bowenliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new c8b89221b6 [KYUUBI #6786] Skip repeated checks on convert function in
TColumnGenerator
c8b89221b6 is described below
commit c8b89221b6cb95c56155a703b020487c11f91e92
Author: Bowen Liang <[email protected]>
AuthorDate: Tue Nov 12 14:54:59 2024 +0800
[KYUUBI #6786] Skip repeated checks on convert function in TColumnGenerator
# :mag: 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 :bookmark:
- [ ] 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 :coffin:
#### Behavior With This Pull Request :tada:
#### 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
f76f6864a [Bowen Liang] nit
930dfef3a [Bowen Liang] fix
9712274e3 [Bowen Liang] comment
9db16ef6b [Bowen Liang] nit
977d21533 [Bowen Liang] skip repeated checking on convert function
Authored-by: Bowen Liang <[email protected]>
Signed-off-by: Bowen Liang <[email protected]>
---
.../apache/kyuubi/engine/result/TColumnGenerator.scala | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git
a/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala
b/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala
index 7326e5a3d1..5a2acd0bdd 100644
---
a/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala
+++
b/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala
@@ -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))