Skip to content

Commit

Permalink
MINOR: [Java] add toString on AbstractContainerVector (apache#40404)
Browse files Browse the repository at this point in the history
### 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 🙂  

### 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]>
  • Loading branch information
jarohen authored Mar 7, 2024
1 parent 1c9a312 commit 40d4c54
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
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.
Expand All @@ -48,6 +49,14 @@ protected AbstractContainerVector(String name, BufferAllocator allocator, CallBa
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()) {
Expand Down

0 comments on commit 40d4c54

Please sign in to comment.