davisusanibar commented on code in PR #320:
URL: https://github.com/apache/arrow-cookbook/pull/320#discussion_r1308887640


##########
java/source/data.rst:
##########
@@ -23,6 +23,47 @@ Recipes related to compare, filtering or transforming data.
 
 .. contents::
 
+Concatenate Value Vectors
+=========================
+
+In some cases, we need to concatenate two value vectors into one. To accomplish
+this, we can use `VectorAppender`_. The following code create two vectors 
separately,
+and then appends the two vectors together.
+
+.. testcode::
+
+    import org.apache.arrow.memory.BufferAllocator;
+    import org.apache.arrow.memory.RootAllocator;
+    import org.apache.arrow.vector.IntVector;
+    import org.apache.arrow.vector.ValueVector;
+    import org.apache.arrow.vector.util.VectorAppender;
+
+    try (
+        BufferAllocator allocator = new RootAllocator();
+        IntVector initialValues = new IntVector("initialValues", allocator);
+        IntVector toAppend = new IntVector("toAppend", allocator);
+    ) {
+      initialValues.allocateNew(2);
+      initialValues.set(0, 1);
+      initialValues.set(1, 2);
+      initialValues.setValueCount(2);
+      System.out.println("Initial IntVector: " + initialValues);
+      toAppend.allocateNew(4);
+      toAppend.set(1, 4);
+      toAppend.set(3, 6);
+      toAppend.setValueCount(4);
+      System.out.println("IntVector to Append: " + toAppend);
+      VectorAppender appenderUtil = new VectorAppender(initialValues);
+      ValueVector resultOfVectorsAppended = toAppend.accept(appenderUtil, 
null);

Review Comment:
   Do you have any ideas why the leak wasn't caught? Maybe this ValueVector is 
also deleted after the dependencies were closed?



-- 
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: github-unsubscr...@arrow.apache.org

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

Reply via email to