vibhatha commented on code in PR #41967:
URL: https://github.com/apache/arrow/pull/41967#discussion_r1632512141


##########
java/c/src/main/java/org/apache/arrow/c/ArrayExporter.java:
##########
@@ -96,8 +97,34 @@ void export(ArrowArray array, FieldVector vector, 
DictionaryProvider dictionaryP
       }
 
       if (buffers != null) {
+        final long bufferSize = buffers.size();
+        /*
+        * For Variadic types, an additional buffer is kept to store
+        * the size of each variadic buffer since that information
+        * cannot be retrieved in the import component.
+        * Here, the dataBufferReqCount is calculated to determine
+        * the additional number of buffers required.
+        * Also note that if the bufferSize is greater than 2, it means
+        * there is one or more data buffers.
+        * Thus, the dataBufferReqCount is set to 1 to get additional buffer
+        * for to store variadic size buffer.
+        * If it is not the case, the dataBuffer is not present.
+        * According to the spec and C Data interface in C++, there must be
+        * at least 3 data buffers present at the import component.
+        * Thus, the dataBufferReqCount is set to 2 to get additional buffer
+        * for empty dataBuffer and the variadic size buffer.
+        */
+        int dataBufferReqCount = 0;
+        if (vector instanceof BaseVariableWidthViewVector) {

Review Comment:
   I couldn't agree more. I was hesitant to change the C Data interface as it 
is a public API. 
   
   But some thoughts...
   
   In `Data.java` we call the `exportVector(...)` which ultimately calls 
`ArrowExporter.exprt(...)`. And since we recently updated `ArrowRecordBatch` 
with `variadicBufferCounts` would it be okay/feasible if we just pass it here 
by introducing a new function
   
   ```
   public static void exportVector(BufferAllocator allocator, FieldVector 
vector, DictionaryProvider provider,
         ArrowArray out, ArrowSchema outSchema, List<Integer> 
variadicBufferCounts) {
   ....
   }
   ```



-- 
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]

Reply via email to