Skip to content

[Java]: Expose util methods inside VectorAppender class such as append vector values #37246

Description

@davisusanibar

Describe the enhancement requested

Current VectorAppender class is package-private.

This class provides utility methods for appending vector values fields that can be exposed publicly.

Java code:

packageorg.apache.arrow.vector.util;
importorg.apache.arrow.memory.BufferAllocator;
importorg.apache.arrow.memory.RootAllocator;
importorg.apache.arrow.vector.IntVector;
importorg.apache.arrow.vector.ValueVector;
publicclassFieldVectorAppender {
publicstaticvoidmain(String[] args) {
try (
BufferAllocatorallocator = newRootAllocator();
IntVectorinitialValues = newIntVector("initialValues", allocator);
IntVectortoAppend = newIntVector("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);
VectorAppenderappenderUtil = newVectorAppender(initialValues);
ValueVectorresultOfVectorsAppended = toAppend.accept(appenderUtil, null);
System.out.println("IntVector Result: " + resultOfVectorsAppended);
}
}
}

Result:

 Initial IntVector: [1, 2]
IntVector to Append: [null, 4, null, 6]
IntVector Result: [1, 2, null, 4, null, 6]

Component(s)

Java

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions