scampi commented on a change in pull request #6402:
URL: https://github.com/apache/arrow/pull/6402#discussion_r439778364



##########
File path: 
java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java
##########
@@ -886,6 +886,65 @@ public void testNullableFixedType4() {
    *  -- VarBinaryVector
    */
 
+  @Test /* VarCharVector */
+  public void testSplitAndTransfer1() {
+    try (final VarCharVector target = newVarCharVector("split-target", 
allocator)) {
+      try (final VarCharVector vector = newVarCharVector(EMPTY_SCHEMA_PATH, 
allocator)) {
+        vector.allocateNew(1024 * 10, 1024);
+
+        vector.set(0, STR1);
+        vector.set(1, STR2);
+        vector.set(2, STR3);
+        vector.setValueCount(3);
+
+        final long allocatedMem = allocator.getAllocatedMemory();
+        final int validityRefCnt = vector.getValidityBuffer().refCnt();
+        final int offsetRefCnt = vector.getOffsetBuffer().refCnt();
+        final int dataRefCnt = vector.getDataBuffer().refCnt();
+
+        // split and transfer with slice starting at the beginning: this 
should not allocate anything new
+        vector.splitAndTransferTo(0, 2, target);
+        assertEquals(allocator.getAllocatedMemory(), allocatedMem);
+        // 2 = validity and offset buffers are stored in the same arrowbuf
+        assertEquals(vector.getValidityBuffer().refCnt(), validityRefCnt + 2);

Review comment:
       Of course ;o) I'm used to hamcrest where that is the opposite...

##########
File path: 
java/vector/src/test/java/org/apache/arrow/vector/TestValueVector.java
##########
@@ -886,6 +886,65 @@ public void testNullableFixedType4() {
    *  -- VarBinaryVector
    */
 
+  @Test /* VarCharVector */
+  public void testSplitAndTransfer1() {
+    try (final VarCharVector target = newVarCharVector("split-target", 
allocator)) {
+      try (final VarCharVector vector = newVarCharVector(EMPTY_SCHEMA_PATH, 
allocator)) {
+        vector.allocateNew(1024 * 10, 1024);
+
+        vector.set(0, STR1);
+        vector.set(1, STR2);
+        vector.set(2, STR3);
+        vector.setValueCount(3);
+
+        final long allocatedMem = allocator.getAllocatedMemory();
+        final int validityRefCnt = vector.getValidityBuffer().refCnt();
+        final int offsetRefCnt = vector.getOffsetBuffer().refCnt();
+        final int dataRefCnt = vector.getDataBuffer().refCnt();
+
+        // split and transfer with slice starting at the beginning: this 
should not allocate anything new
+        vector.splitAndTransferTo(0, 2, target);
+        assertEquals(allocator.getAllocatedMemory(), allocatedMem);
+        // 2 = validity and offset buffers are stored in the same arrowbuf
+        assertEquals(vector.getValidityBuffer().refCnt(), validityRefCnt + 2);

Review comment:
       Not at all, that's a good question. I've improved the assertion's 
comment in commit .




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

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


Reply via email to