lidavidm commented on code in PR #454:
URL: https://github.com/apache/arrow-java/pull/454#discussion_r1921660552
##########
vector/src/test/java/org/apache/arrow/vector/util/TestVectorAppender.java:
##########
@@ -171,6 +176,82 @@ public void testAppendVariableWidthVector() {
}
}
+ @Test
+ public void testAppendVariableWidthViewVector() {
+ final int length1 = 10;
+ final int length2 = 5;
+ try (ViewVarCharVector target = new ViewVarCharVector("", allocator);
+ ViewVarCharVector delta = new ViewVarCharVector("", allocator)) {
+ target.allocateNew(5, length1);
+ delta.allocateNew(5, length2);
+
+ ValueVectorDataPopulator.setVector(
+ target, "a0", "a1", "a2", "a3", null, "a5", "a6", "a7", "a8", "a9");
+ ValueVectorDataPopulator.setVector(delta, "a10", "a11", "a12", "a13",
null);
+
+ VectorAppender appender = new VectorAppender(target);
+ delta.accept(appender, null);
+
+ try (ViewVarCharVector expected = new ViewVarCharVector("expected",
allocator)) {
+ expected.allocateNew();
+ ValueVectorDataPopulator.setVector(
+ expected, "a0", "a1", "a2", "a3", null, "a5", "a6", "a7", "a8",
"a9", "a10", "a11",
+ "a12", "a13", null);
+ assertVectorsEqual(expected, target);
+ }
+ }
+ }
+
+ @Test
+ public void testAppendEmptyVariableWidthViewVector() {
+ try (ViewVarCharVector target = new ViewVarCharVector("", allocator);
+ ViewVarCharVector delta = new ViewVarCharVector("", allocator)) {
+ ValueVectorDataPopulator.setVector(
+ target, "a0", "a1", "a2", "a3", null, "a5", "a6", "a7", "a8", "a9");
+
+ VectorAppender appender = new VectorAppender(target);
+ delta.accept(appender, null);
+
+ try (ViewVarCharVector expected = new ViewVarCharVector("expected",
allocator)) {
+ ValueVectorDataPopulator.setVector(
+ expected, "a0", "a1", "a2", "a3", null, "a5", "a6", "a7", "a8",
"a9");
+ assertVectorsEqual(expected, target);
+ }
+ }
+ }
+
+ @Test
+ public void testAppendShortLongVariableWidthViewVector() {
+ try (ViewVarCharVector target = new ViewVarCharVector("", allocator);
+ ViewVarCharVector delta = new ViewVarCharVector("", allocator)) {
+ String[] targetValues =
+ IntStream.range(-5, 5)
+ .mapToObj(
+ i ->
TestUtils.generateRandomString(BaseVariableWidthViewVector.INLINE_SIZE + i))
+ .toArray(String[]::new);
+ ValueVectorDataPopulator.setVector(target, targetValues);
+
+ String[] deltaValues =
+ IntStream.range(-3, 3)
+ .mapToObj(
+ i ->
TestUtils.generateRandomString(BaseVariableWidthViewVector.INLINE_SIZE + i))
+ .toArray(String[]::new);
+ ValueVectorDataPopulator.setVector(delta, deltaValues);
+
+ VectorAppender appender = new VectorAppender(target);
+ delta.accept(appender, null);
+
+ assertEquals(2, target.getDataBuffers().size());
Review Comment:
But what about the cases where `target` and `delta` have more than one data
buffer _before_ appending?
--
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]