From 23b80c6cfc4726479a99a13da50cfe13cc7636e3 Mon Sep 17 00:00:00 2001 From: Vibhatha Abeykoon Date: Wed, 14 Aug 2024 05:42:25 +0530 Subject: [PATCH] fix: addressing reviews --- .../arrow/vector/complex/AbstractStructVector.java | 2 +- .../arrow/vector/complex/FixedSizeListVector.java | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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 5ca1601055f4f..2921e43cb6410 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 @@ -398,7 +398,7 @@ public ArrowBuf[] getBuffers(boolean clear) { final List buffers = new ArrayList<>(); for (final ValueVector vector : vectors.values()) { - for (final ArrowBuf buf : vector.getBuffers(clear)) { + for (final ArrowBuf buf : vector.getBuffers(false)) { buffers.add(buf); if (clear) { buf.getReferenceManager().retain(1); 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 885e1d7986f1a..c762eb51725ca 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(); @@ -369,7 +380,7 @@ public ArrowBuf[] getBuffers(boolean clear) { } else { List list = new ArrayList<>(); list.add(validityBuffer); - list.addAll(Arrays.asList(vector.getBuffers(clear))); + list.addAll(Arrays.asList(vector.getBuffers(false))); buffers = list.toArray(new ArrowBuf[list.size()]); } if (clear) {