lidavidm commented on code in PR #13248:
URL: https://github.com/apache/arrow/pull/13248#discussion_r981711344


##########
java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java:
##########
@@ -704,6 +705,37 @@ public void testImportReleasedArray() {
     }
   }
 
+  @Test
+  public void testTransferImportedBuffer() {
+    VectorSchemaRoot imported;
+
+    // Consumer allocates empty structures
+    try (ArrowSchema consumerArrowSchema = ArrowSchema.allocateNew(allocator);
+        ArrowArray consumerArrowArray = ArrowArray.allocateNew(allocator)) {
+      try (VectorSchemaRoot vsr = createTestVSR()) {
+        // Producer creates structures from existing memory pointers
+        try (ArrowSchema arrowSchema = 
ArrowSchema.wrap(consumerArrowSchema.memoryAddress());
+            ArrowArray arrowArray = 
ArrowArray.wrap(consumerArrowArray.memoryAddress())) {
+          // Producer exports vector into the C Data Interface structures
+          Data.exportVectorSchemaRoot(allocator, vsr, null, arrowArray, 
arrowSchema);
+        }
+      }
+      // Consumer imports vector
+      imported = Data.importVectorSchemaRoot(allocator, consumerArrowArray, 
consumerArrowSchema, null);
+    }
+
+    try (BufferAllocator targetAllocator = 
allocator.newChildAllocator("transfer allocator", 0, Long.MAX_VALUE)) {
+      for (FieldVector fieldVector : imported.getFieldVectors()) {
+        int cnt = fieldVector.getValueCount();
+        // Transfer buffer ownerships. Should not report any error
+        TransferPair transferPair = 
fieldVector.getTransferPair(targetAllocator);
+        transferPair.transfer();
+        ValueVector to = transferPair.getTo();
+        assertEquals(cnt, to.getValueCount());

Review Comment:
   What does targetAllocator report for allocated bytes after the transfer?



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