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


##########
common/src/main/scala/org/apache/comet/vector/NativeUtil.scala:
##########
@@ -56,6 +60,35 @@ 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 Arrow arrays and Arrow schemas
+   */
+  def allocateArrowStructs(numCols: Int): (Array[ArrowArray], 
Array[ArrowSchema]) = {
+    val arrays = new Array[ArrowArray](numCols)
+    val schemas = new Array[ArrowSchema](numCols)
+
+    (0 until numCols).foreach { index =>
+      val arrowSchema = ArrowSchema.allocateNew(allocator)
+
+      // Manually fill NULL to `release` slot of ArrowSchema because 
ArrowSchema doesn't provide
+      // `markReleased`.
+      val buffer =
+        MemoryUtil.directBuffer(arrowSchema.memoryAddress(), 
72).order(ByteOrder.nativeOrder)
+      buffer.putLong(56, NULL);

Review Comment:
   Added a comment.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to