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


##########
java/vector/src/test/java/org/apache/arrow/vector/TestSplitAndTransfer.java:
##########
@@ -282,35 +303,52 @@ public void testMemoryConstrainedTransfer() {
     }
   }
 
-  @Test
-  public void testMemoryConstrainedTransferInViews() {
-    try (final ViewVarCharVector viewVarCharVector = new 
ViewVarCharVector("myvector", allocator)) {
-      // Here we have the target vector being transferred with a long string
-      // hence, the data buffer will be allocated.
-      // The default data buffer allocation takes
-      // BaseVariableWidthViewVector.INITIAL_VIEW_VALUE_ALLOCATION * 
BaseVariableWidthViewVector.ELEMENT_SIZE
-      // set limit = BaseVariableWidthViewVector.INITIAL_VIEW_VALUE_ALLOCATION 
*
-      // BaseVariableWidthViewVector.ELEMENT_SIZE
-      final int setLimit = 
BaseVariableWidthViewVector.INITIAL_VIEW_VALUE_ALLOCATION *
-          BaseVariableWidthViewVector.ELEMENT_SIZE;
-      allocator.setLimit(setLimit);
-
-      viewVarCharVector.allocateNew(16000, 1000);
+  private void 
testMemoryConstrainedTransferInViews(BaseVariableWidthViewVector vector) {
+    // Here we have the target vector being transferred with a long string
+    // hence, the data buffer will be allocated.
+    // The default data buffer allocation takes
+    // BaseVariableWidthViewVector.INITIAL_VIEW_VALUE_ALLOCATION * 
BaseVariableWidthViewVector.ELEMENT_SIZE
+    // set limit = BaseVariableWidthViewVector.INITIAL_VIEW_VALUE_ALLOCATION *
+    // BaseVariableWidthViewVector.ELEMENT_SIZE
+    final int setLimit = 
BaseVariableWidthViewVector.INITIAL_VIEW_VALUE_ALLOCATION *
+        BaseVariableWidthViewVector.ELEMENT_SIZE;
+    allocator.setLimit(setLimit);
 
-      final int valueCount = 1000;
+    vector.allocateNew(16000, 1000);
 
-      populateViewVarcharVector(viewVarCharVector, valueCount, null);
+    final int valueCount = 1000;
 
-      final TransferPair tp = viewVarCharVector.getTransferPair(allocator);
-      final ViewVarCharVector newViewVarCharVector = (ViewVarCharVector) 
tp.getTo();
-      final int[][] startLengths = {{0, 700}, {700, 299}};
+    populateBaseVariableWidthViewVector(vector, valueCount, null);
 
-      for (final int[] startLength : startLengths) {
-        final int start = startLength[0];
-        final int length = startLength[1];
-        tp.splitAndTransfer(start, length);
-        newViewVarCharVector.clear();
-      }
+    final TransferPair tp = vector.getTransferPair(allocator);
+    final BaseVariableWidthViewVector newVector;
+    if (vector instanceof ViewVarCharVector) {
+      newVector = (ViewVarCharVector) tp.getTo();
+    } else {
+      newVector = (ViewVarBinaryVector) tp.getTo();
+    }

Review Comment:
   There are multiple branches in other test cases, let me fix them shortly. 



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