rymurr commented on a change in pull request #6402:
URL: https://github.com/apache/arrow/pull/6402#discussion_r433156439
##########
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:
nit: `assertEquals` is normally 'expected' as the first arg and 'actual'
as the second. Makes error logs easier to read too. Swapping the order of args
here and in the next unit test would be nice.
##########
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:
Sorry if I am being thick: why does the validity and offset ref count
increase by 2? We created one copy for the transfer right? Where does the
second come from?
----------------------------------------------------------------
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:
[email protected]