You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by "bowenliang123 (via GitHub)" <gi...@apache.org> on 2024/10/29 07:14:17 UTC

[PR] Skip repeated checks on convert function [kyuubi]

bowenliang123 opened a new pull request, #6786:
URL: https://github.com/apache/kyuubi/pull/6786

   # :mag: Description
   ## Issue References ๐Ÿ”—
   <!-- Append the issue number after #. If there is no issue for you to link create one or -->
   <!-- If there are no issues to link, please provide details here. -->
   
   This pull request fixes #
   
   ## Describe Your Solution ๐Ÿ”ง
   
   Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.
   
   
   ## Types of changes :bookmark:
   <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
   - [ ] 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 ๐Ÿ“
   <!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
   <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
   
   - [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)
   
   **Be nice. Be informative.**
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Skip repeated checks on convert function in TColumnGenerator [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #6786:
URL: https://github.com/apache/kyuubi/pull/6786#discussion_r1823819701


##########
kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala:
##########
@@ -33,16 +33,18 @@ trait TColumnGenerator[RowT] extends TRowSetColumnGetter[RowT] {
     val rowSize = rows.length
     val ret = new JArrayList[T](rowSize)
     val nulls = new JBitSet()
+    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)

Review Comment:
   Sure.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Skip repeated checks on convert function in TColumnGenerator [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on PR #6786:
URL: https://github.com/apache/kyuubi/pull/6786#issuecomment-2469740630

   Thanks, merged to master (1.11.0) and branch-1.10 (1.10.1).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Skip repeated checks on convert function in TColumnGenerator [kyuubi]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6786:
URL: https://github.com/apache/kyuubi/pull/6786#issuecomment-2443551191

   ## [Codecov](https://app.codecov.io/gh/apache/kyuubi/pull/6786?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   Attention: Patch coverage is `0%` with `4 lines` in your changes missing coverage. Please review.
   > Project coverage is 0.00%. Comparing base [(`d3520dd`)](https://app.codecov.io/gh/apache/kyuubi/commit/d3520ddbcea96ec55c525600126047c44c7adb35?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to head [(`9db16ef`)](https://app.codecov.io/gh/apache/kyuubi/commit/9db16ef6b064751a8d4618ae49cffe5e67836371?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/kyuubi/pull/6786?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...apache/kyuubi/engine/result/TColumnGenerator.scala](https://app.codecov.io/gh/apache/kyuubi/pull/6786?src=pr&el=tree&filepath=kyuubi-common%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fkyuubi%2Fengine%2Fresult%2FTColumnGenerator.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvcmVzdWx0L1RDb2x1bW5HZW5lcmF0b3Iuc2NhbGE=) | 0.00% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/kyuubi/pull/6786?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   ```diff
   @@          Coverage Diff           @@
   ##           master   #6786   +/-   ##
   ======================================
     Coverage    0.00%   0.00%           
   ======================================
     Files         687     687           
     Lines       42439   42440    +1     
     Branches     5793    5793           
   ======================================
   - Misses      42439   42440    +1     
   ```
   
   </details>
   
   [:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/kyuubi/pull/6786?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Skip repeated checks on convert function in TColumnGenerator [kyuubi]

Posted by "pan3793 (via GitHub)" <gi...@apache.org>.
pan3793 commented on code in PR #6786:
URL: https://github.com/apache/kyuubi/pull/6786#discussion_r1823817903


##########
kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala:
##########
@@ -33,16 +33,18 @@ trait TColumnGenerator[RowT] extends TRowSetColumnGetter[RowT] {
     val rowSize = rows.length
     val ret = new JArrayList[T](rowSize)
     val nulls = new JBitSet()
+    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)

Review Comment:
   let's use a simple way
   ```
   if (convertFunc == null) {
     ...
   } else {
     ...
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Skip repeated checks on convert function in TColumnGenerator [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 commented on code in PR #6786:
URL: https://github.com/apache/kyuubi/pull/6786#discussion_r1823819701


##########
kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TColumnGenerator.scala:
##########
@@ -33,16 +33,18 @@ trait TColumnGenerator[RowT] extends TRowSetColumnGetter[RowT] {
     val rowSize = rows.length
     val ret = new JArrayList[T](rowSize)
     val nulls = new JBitSet()
+    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)

Review Comment:
   I would still prefer to use an extracted boolean value for this. I assume that accessing a boolean costs less step and byte code steps for comparing `convertFunc` to `null`, especially since it's repeatedly used and checked once for each row.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


Re: [PR] Skip repeated checks on convert function in TColumnGenerator [kyuubi]

Posted by "bowenliang123 (via GitHub)" <gi...@apache.org>.
bowenliang123 closed pull request #6786: Skip repeated checks on convert function in TColumnGenerator
URL: https://github.com/apache/kyuubi/pull/6786


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org