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


##########
java/c/src/test/java/org/apache/arrow/c/ArrowArrayUtilityTest.java:
##########
@@ -56,19 +56,39 @@ void afterEach() {
   // BufferImportTypeVisitor
 
   @Test
-  void getBufferPtr() throws Exception {
+  void importBuffer() throws Exception {
     // Note values are all dummy values here
-    try (BufferImportTypeVisitor visitor =
-        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(0, 0), new long[]{0})) {
+    try (BufferImportTypeVisitor notEmptyDataVisitor =
+        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(/* length= */ 1, 0), new long[]{0})) {
 
       // Too few buffers
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 1));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 1, 1));
 
       // Null where one isn't expected
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 0));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity not zero but c arry ptr is NULL (zero)
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity is zero and c arry ptr is NULL (zero)
+      assertThat(notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 
0)).isEqualTo(allocator.getEmpty());
+    }
+
+    try (BufferImportTypeVisitor emptyDataVisitor =
+        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(/* length= */ 0, 0), new long[]{0})) {
+
+      // Too few buffers
+      assertThrows(IllegalStateException.class, () -> 
emptyDataVisitor.importBuffer(new ArrowType.Bool(), 1, 1));
+
+      // Expected capacity not zero but c arry ptr is NULL (zero)

Review Comment:
   ```suggestion
         // Expected capacity not zero but c array ptr is NULL (zero)
   ```



##########
java/c/src/test/java/org/apache/arrow/c/ArrowArrayUtilityTest.java:
##########
@@ -56,19 +56,39 @@ void afterEach() {
   // BufferImportTypeVisitor
 
   @Test
-  void getBufferPtr() throws Exception {
+  void importBuffer() throws Exception {
     // Note values are all dummy values here
-    try (BufferImportTypeVisitor visitor =
-        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(0, 0), new long[]{0})) {
+    try (BufferImportTypeVisitor notEmptyDataVisitor =
+        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(/* length= */ 1, 0), new long[]{0})) {
 
       // Too few buffers
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 1));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 1, 1));
 
       // Null where one isn't expected
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 0));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity not zero but c arry ptr is NULL (zero)
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity is zero and c arry ptr is NULL (zero)

Review Comment:
   ```suggestion
         // Expected capacity is zero and c array ptr is NULL (zero)
   ```



##########
java/c/src/test/java/org/apache/arrow/c/ArrowArrayUtilityTest.java:
##########
@@ -56,19 +56,39 @@ void afterEach() {
   // BufferImportTypeVisitor
 
   @Test
-  void getBufferPtr() throws Exception {
+  void importBuffer() throws Exception {
     // Note values are all dummy values here
-    try (BufferImportTypeVisitor visitor =
-        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(0, 0), new long[]{0})) {
+    try (BufferImportTypeVisitor notEmptyDataVisitor =
+        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(/* length= */ 1, 0), new long[]{0})) {
 
       // Too few buffers
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 1));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 1, 1));
 
       // Null where one isn't expected
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 0));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity not zero but c arry ptr is NULL (zero)
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity is zero and c arry ptr is NULL (zero)
+      assertThat(notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 
0)).isEqualTo(allocator.getEmpty());
+    }
+
+    try (BufferImportTypeVisitor emptyDataVisitor =
+        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(/* length= */ 0, 0), new long[]{0})) {
+
+      // Too few buffers
+      assertThrows(IllegalStateException.class, () -> 
emptyDataVisitor.importBuffer(new ArrowType.Bool(), 1, 1));
+
+      // Expected capacity not zero but c arry ptr is NULL (zero)
+      assertThrows(IllegalStateException.class, () -> 
emptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity is zero and c arry ptr is NULL (zero)

Review Comment:
   ```suggestion
         // Expected capacity is zero and c array ptr is NULL (zero)
   ```



##########
java/c/src/test/java/org/apache/arrow/c/ArrowArrayUtilityTest.java:
##########
@@ -56,19 +56,39 @@ void afterEach() {
   // BufferImportTypeVisitor
 
   @Test
-  void getBufferPtr() throws Exception {
+  void importBuffer() throws Exception {
     // Note values are all dummy values here
-    try (BufferImportTypeVisitor visitor =
-        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(0, 0), new long[]{0})) {
+    try (BufferImportTypeVisitor notEmptyDataVisitor =
+        new BufferImportTypeVisitor(allocator, dummyHandle, new 
ArrowFieldNode(/* length= */ 1, 0), new long[]{0})) {
 
       // Too few buffers
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 1));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 1, 1));
 
       // Null where one isn't expected
-      assertThrows(IllegalStateException.class, () -> visitor.getBufferPtr(new 
ArrowType.Bool(), 0));
+      assertThrows(IllegalStateException.class, () -> 
notEmptyDataVisitor.importBuffer(new ArrowType.Bool(), 0, 1));
+
+      // Expected capacity not zero but c arry ptr is NULL (zero)

Review Comment:
   ```suggestion
         // Expected capacity not zero but c array ptr is NULL (zero)
   ```



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