You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/05/31 12:06:46 UTC

[GitHub] [arrow] pitrou commented on a diff in pull request #13249: ARROW-16674: [Java] C data interface: Reading as nioBuffer from imported buffer causes error

pitrou commented on code in PR #13249:
URL: https://github.com/apache/arrow/pull/13249#discussion_r885553966


##########
java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java:
##########
@@ -678,6 +679,22 @@ public void testSchema() {
     }
   }
 
+  @Test
+  public void testImportedBufferAsNioBuffer() {
+    IntVector imported;
+    try (final IntVector vector = new IntVector("v", allocator)) {
+      setVector(vector, 1, 2, 3, null);
+      imported = (IntVector) vectorRoundtrip(vector);
+      ArrowBuf dataBuffer = imported.getDataBuffer();
+      ByteBuffer nioBuffer = dataBuffer.nioBuffer().asReadOnlyBuffer();
+      nioBuffer.order(ByteOrder.nativeOrder());
+      assertEquals(1, nioBuffer.getInt(0));
+      assertEquals(2, nioBuffer.getInt(1 << 2));
+      assertEquals(3, nioBuffer.getInt(2 << 2));
+    }
+    imported.close();

Review Comment:
   For the record, is it necessary to explicitly close the imported vector?



##########
java/c/src/test/java/org/apache/arrow/c/RoundtripTest.java:
##########
@@ -678,6 +679,22 @@ public void testSchema() {
     }
   }
 
+  @Test
+  public void testImportedBufferAsNioBuffer() {
+    IntVector imported;
+    try (final IntVector vector = new IntVector("v", allocator)) {
+      setVector(vector, 1, 2, 3, null);
+      imported = (IntVector) vectorRoundtrip(vector);

Review Comment:
   Does the test still work if we close the `try` block just after this line?



-- 
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-unsubscribe@arrow.apache.org

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