Kontinuation commented on code in PR #905:
URL: https://github.com/apache/datafusion-comet/pull/905#discussion_r1743675528


##########
common/src/main/scala/org/apache/comet/vector/NativeUtil.scala:
##########
@@ -110,12 +132,12 @@ class NativeUtil {
    * @return
    *   a list of Comet vectors
    */
-  def importVector(arrayAddress: Array[Long]): Seq[CometVector] = {
+  def importVector(arrayAddrs: Array[Long], schemaAddrs: Array[Long]): 
Seq[CometVector] = {
     val arrayVectors = mutable.ArrayBuffer.empty[CometVector]
 
-    for (i <- arrayAddress.indices by 2) {
-      val arrowSchema = ArrowSchema.wrap(arrayAddress(i + 1))
-      val arrowArray = ArrowArray.wrap(arrayAddress(i))
+    (0 until arrayAddrs.length).foreach { i =>
+      val arrowSchema = ArrowSchema.wrap(schemaAddrs(i))
+      val arrowArray = ArrowArray.wrap(arrayAddrs(i))

Review Comment:
   The `close` method is a no-op for ArrowSchema and ArrowArray objects created 
by `wrap`. I suggest passing in the originally allocated ArrowSchema and 
ArrowArray objects, so that those objects will be automatically released by 
`importVector`.



##########
common/src/main/scala/org/apache/comet/vector/NativeUtil.scala:
##########
@@ -56,6 +56,28 @@ class NativeUtil {
    */
   private val dictionaryProvider: CDataDictionaryProvider = new 
CDataDictionaryProvider
 
+ /**
+   * Allocates Arrow structs for the given number of columns.
+   *
+   * @param numCols
+   *   the number of columns
+   * @return
+   *   a pair of arrays containing memory addresses of Arrow arrays and Arrow 
schemas
+   */
+  def allocateArrowStructs(numCols: Int): (Array[Long], Array[Long]) = {

Review Comment:
   We can return `(Array[ArrowSchema], Array[ArrowArray])` here.



-- 
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: github-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to