This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 40d4c54401 MINOR: [Java] add toString on AbstractContainerVector
(#40404)
40d4c54401 is described below
commit 40d4c54401c3c4f6f6c0e6116e32dc20050e67b7
Author: James Henderson <[email protected]>
AuthorDate: Thu Mar 7 17:39:32 2024 +0000
MINOR: [Java] add toString on AbstractContainerVector (#40404)
### Rationale for this change
Adding the ability to see the values in vectors derived from
AbstractContainerVector (e.g. structs, dense unions) when something's not quite
going as you're expecting :slightly_smiling_face:
### What changes are included in this PR?
Add AbstractContainerVector.toString in line with BaseValueVector.toString
### Are these changes tested?
Yes, as part of our XTDB development, but not in the Arrow repo - I didn't
see any other tests for ValueVector.toString implementations?
### Are there any user-facing changes?
Strictly speaking, yes, if the user's printing out the vector - but
Object.toString isn't often considered part of the public API in my experience?
Cheers!
James
Authored-by: James Henderson <[email protected]>
Signed-off-by: David Li <[email protected]>
---
.../org/apache/arrow/vector/complex/AbstractContainerVector.java | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git
a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java
b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java
index 8e6cdb6c45..12a3c209d7 100644
---
a/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java
+++
b/java/vector/src/main/java/org/apache/arrow/vector/complex/AbstractContainerVector.java
@@ -29,6 +29,7 @@ import org.apache.arrow.vector.types.pojo.ArrowType.List;
import org.apache.arrow.vector.types.pojo.ArrowType.Struct;
import org.apache.arrow.vector.types.pojo.FieldType;
import org.apache.arrow.vector.util.CallBack;
+import org.apache.arrow.vector.util.ValueVectorUtility;
/**
* Base class for composite vectors.
@@ -48,6 +49,14 @@ public abstract class AbstractContainerVector implements
ValueVector, DensityAwa
this.callBack = callBack;
}
+ /**
+ * Representation of vector suitable for debugging.
+ */
+ @Override
+ public String toString() {
+ return ValueVectorUtility.getToString(this, 0, getValueCount());
+ }
+
@Override
public void allocateNew() throws OutOfMemoryException {
if (!allocateNewSafe()) {