diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java index feb7edfec94..2921e43cb64 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractStructVector.java @@ -382,6 +382,17 @@ public VectorWithOrdinal getChildVectorWithOrdinal(String name) { return new VectorWithOrdinal(vector, ordinal); } + /** + * Return the underlying buffers associated with this vector. Note that this doesn't impact the + * reference counts for this buffer, so it only should be used for in-context access. Also note + * that this buffer changes regularly, thus external classes shouldn't hold a reference to it + * (unless they change it). + * + * @param clear Whether to clear vector before returning, the buffers will still be refcounted but + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. + * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. + */ @Override public ArrowBuf[] getBuffers(boolean clear) { final List buffers = new ArrayList<>(); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java index 1cdb87eba03..fbe83bad52c 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/BaseRepeatedValueVector.java @@ -271,6 +271,17 @@ public void reset() { valueCount = 0; } + /** + * Return the underlying buffers associated with this vector. Note that this doesn't impact the + * reference counts for this buffer, so it only should be used for in-context access. Also note + * that this buffer changes regularly, thus external classes shouldn't hold a reference to it + * (unless they change it). + * + * @param clear Whether to clear vector before returning, the buffers will still be refcounted but + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. + * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. + */ @Override public ArrowBuf[] getBuffers(boolean clear) { final ArrowBuf[] buffers; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java index cb455084808..c762eb51725 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/FixedSizeListVector.java @@ -360,6 +360,17 @@ public void reset() { valueCount = 0; } + /** + * Return the underlying buffers associated with this vector. Note that this doesn't impact the + * reference counts for this buffer, so it only should be used for in-context access. Also note + * that this buffer changes regularly, thus external classes shouldn't hold a reference to it + * (unless they change it). + * + * @param clear Whether to clear vector before returning, the buffers will still be refcounted but + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. + * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. + */ @Override public ArrowBuf[] getBuffers(boolean clear) { setReaderAndWriterIndex(); diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListVector.java index b5b32c8032d..ed075352c93 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListVector.java @@ -882,12 +882,13 @@ public void reset() { /** * Return the underlying buffers associated with this vector. Note that this doesn't impact the - * reference counts for this buffer so it only should be used for in-context access. Also note - * that this buffer changes regularly thus external classes shouldn't hold a reference to it + * reference counts for this buffer, so it only should be used for in-context access. Also note + * that this buffer changes regularly, thus external classes shouldn't hold a reference to it * (unless they change it). * - * @param clear Whether to clear vector before returning; the buffers will still be refcounted but - * the returned array will be the only reference to them + * @param clear Whether to clear vector before returning, the buffers will still be refcounted but + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. */ @Override diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java index 17ccdbf0eae..f6b3de88b77 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java @@ -546,7 +546,8 @@ public void reset() { * (unless they change it). * * @param clear Whether to clear vector before returning, the buffers will still be refcounted but - * the returned array will be the only reference to them + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. */ @Override @@ -561,7 +562,7 @@ public ArrowBuf[] getBuffers(boolean clear) { list.add(validityBuffer); list.add(offsetBuffer); list.add(sizeBuffer); - list.addAll(Arrays.asList(vector.getBuffers(clear))); + list.addAll(Arrays.asList(vector.getBuffers(false))); buffers = list.toArray(new ArrowBuf[list.size()]); } if (clear) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java index a1e18210fc6..76682c28fe6 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListVector.java @@ -726,12 +726,13 @@ public void reset() { /** * Return the underlying buffers associated with this vector. Note that this doesn't impact the - * reference counts for this buffer so it only should be used for in-context access. Also note - * that this buffer changes regularly thus external classes shouldn't hold a reference to it + * reference counts for this buffer, so it only should be used for in-context access. Also note + * that this buffer changes regularly, thus external classes shouldn't hold a reference to it * (unless they change it). * - * @param clear Whether to clear vector before returning; the buffers will still be refcounted but - * the returned array will be the only reference to them + * @param clear Whether to clear vector before returning, the buffers will still be refcounted but + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. */ @Override diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java index 6ced66d81ec..7f6d92f3be9 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/ListViewVector.java @@ -704,7 +704,8 @@ public void reset() { * (unless they change it). * * @param clear Whether to clear vector before returning, the buffers will still be refcounted but - * the returned array will be the only reference to them + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. */ @Override diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java index dda9b6547f7..ca5f572034c 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/StructVector.java @@ -396,12 +396,13 @@ public int getValueCapacity() { /** * Return the underlying buffers associated with this vector. Note that this doesn't impact the - * reference counts for this buffer so it only should be used for in-context access. Also note - * that this buffer changes regularly thus external classes shouldn't hold a reference to it + * reference counts for this buffer, so it only should be used for in-context access. Also note + * that this buffer changes regularly, thus external classes shouldn't hold a reference to it * (unless they change it). * - * @param clear Whether to clear vector before returning; the buffers will still be refcounted but - * the returned array will be the only reference to them + * @param clear Whether to clear vector before returning, the buffers will still be refcounted but + * the returned array will be the only reference to them. Also, this won't clear the child + * buffers. * @return The underlying {@link ArrowBuf buffers} that is used by this vector instance. */ @Override diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java index 48cf78a4c2e..28d73a8fdff 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestVectorReset.java @@ -25,6 +25,7 @@ import org.apache.arrow.memory.RootAllocator; import org.apache.arrow.vector.complex.FixedSizeListVector; import org.apache.arrow.vector.complex.ListVector; +import org.apache.arrow.vector.complex.ListViewVector; import org.apache.arrow.vector.complex.NonNullableStructVector; import org.apache.arrow.vector.complex.StructVector; import org.apache.arrow.vector.complex.UnionVector; @@ -122,7 +123,10 @@ public void testListTypeReset() { "VarList", allocator, FieldType.nullable(MinorType.INT.getType()), null); final FixedSizeListVector fixedList = new FixedSizeListVector( - "FixedList", allocator, FieldType.nullable(new FixedSizeList(2)), null)) { + "FixedList", allocator, FieldType.nullable(new FixedSizeList(2)), null); + final ListViewVector variableViewList = + new ListViewVector( + "VarListView", allocator, FieldType.nullable(MinorType.INT.getType()), null)) { // ListVector variableList.allocateNewSafe(); variableList.startNewValue(0); @@ -136,6 +140,13 @@ public void testListTypeReset() { fixedList.setNull(0); fixedList.setValueCount(1); resetVectorAndVerify(fixedList, fixedList.getBuffers(false)); + + // ListViewVector + variableViewList.allocateNewSafe(); + variableViewList.startNewValue(0); + variableViewList.endValue(0, 0); + variableViewList.setValueCount(1); + resetVectorAndVerify(variableViewList, variableViewList.getBuffers(false)); } }