This is an automated email from the ASF dual-hosted git repository.

chengpan 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 030ee70c6 [KYUUBI #6070] Improve perf on assembling row-based TRowSet
030ee70c6 is described below

commit 030ee70c6ab7df0e76e575acb990930eb16065dc
Author: wangjunbo <[email protected]>
AuthorDate: Sat Feb 24 17:39:23 2024 +0800

    [KYUUBI #6070] Improve perf on assembling row-based TRowSet
    
    # :mag: Description
    ## Issue References ๐Ÿ”—
    
    This pull request fixes #6070
    
    ## Describe Your Solution ๐Ÿ”ง
    
    https://issues.apache.org/jira/browse/SPARK-47085
    
    ## 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 #6077 from Kwafoor/kyuubi_6070.
    
    Closes #6070
    
    84114f398 [wangjunbo] fix
    90a125635 [wangjunbo] fix
    97db3c99f [wangjunbo] fix
    5442296bf [wangjunbo] [KYUUBI #6070] Performance Improvement for converting 
rows to thrift rows
    
    Authored-by: wangjunbo <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../kyuubi/engine/result/TRowSetGenerator.scala    | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TRowSetGenerator.scala
 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TRowSetGenerator.scala
index 096e45ad8..4f5701919 100644
--- 
a/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TRowSetGenerator.scala
+++ 
b/kyuubi-common/src/main/scala/org/apache/kyuubi/engine/result/TRowSetGenerator.scala
@@ -18,6 +18,8 @@
 package org.apache.kyuubi.engine.result
 import java.util.{ArrayList => JArrayList}
 
+import scala.collection.JavaConverters._
+
 import org.apache.kyuubi.shaded.hive.service.rpc.thrift._
 
 trait TRowSetGenerator[SchemaT, RowT, ColumnT]
@@ -40,23 +42,17 @@ trait TRowSetGenerator[SchemaT, RowT, ColumnT]
   }
 
   def toRowBasedSet(rows: Seq[RowT], schema: SchemaT): TRowSet = {
-    val rowSize = rows.length
-    val tRows = new JArrayList[TRow](rowSize)
-    var i = 0
-    while (i < rowSize) {
-      val row = rows(i)
-      var j = 0
+    val tRows = rows.map { row =>
+      var i = 0
       val columnSize = getColumnSizeFromSchemaType(schema)
       val tColumnValues = new JArrayList[TColumnValue](columnSize)
-      while (j < columnSize) {
-        val columnValue = toTColumnValue(row, j, schema)
+      while (i < columnSize) {
+        val columnValue = toTColumnValue(row, i, schema)
         tColumnValues.add(columnValue)
-        j += 1
+        i += 1
       }
-      i += 1
-      val tRow = new TRow(tColumnValues)
-      tRows.add(tRow)
-    }
+      new TRow(tColumnValues)
+    }.asJava
     new TRowSet(0, tRows)
   }
 

Reply via email to