You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Java] VectorSchemaRoot#addVector() cannot add a vector to the end of the current vector collection #301
The current implementation of Java VectorSchemaRoot cannot add a vector at the end of the current list (which is the generally understood meaning of "add").
The Precondition check in the method's second line prevents providing an appropriate index for adding at the end:
publicVectorSchemaRootaddVector(intindex, FieldVectorvector) {
Preconditions.checkNotNull(vector);
Preconditions.checkArgument(index >= 0 && index < fieldVectors.size());
List<FieldVector> newVectors = newArrayList<>();
for (inti = 0; i < fieldVectors.size(); i++) {
if (i == index) {
newVectors.add(vector);
}
newVectors.add(fieldVectors.get(i));
}
returnnewVectorSchemaRoot(newVectors);
}
One possible implementation resolving the issue is shown below.
publicVectorSchemaRootaddVector(intindex, FieldVectorvector) {
Preconditions.checkNotNull(vector);
Preconditions.checkArgument(index >= 0 && index <= fieldVectors.size());
List<FieldVector> newVectors = newArrayList<>();
if (index == fieldVectors.size()) {
newVectors.addAll(fieldVectors);
newVectors.add(vector);
} else {
for (inti = 0; i < fieldVectors.size(); i++) {
if (i == index) {
newVectors.add(vector);
}
newVectors.add(fieldVectors.get(i));
}
}
returnnewVectorSchemaRoot(newVectors);
}
Apache Arrow JIRA Bot:
This issue was last updated over 90 days ago, which may be an indication it is no longer being actively worked. To better reflect the current state, the issue is being unassigned per project policy. Please feel free to re-take assignment of the issue if it is being actively worked, or if you plan to start that work soon.
Hey, I noticed the same issue recently on this line of code as well. Is this expected behavior? If I have an existing VectorSchemaRoot and want to add a new FieldVector to it is there a better way to do it?
Happy to put up a CR to address the issue as well.
Activity
asfimport commentedon Nov 24, 2022
Apache Arrow JIRA Bot:
This issue was last updated over 90 days ago, which may be an indication it is no longer being actively worked. To better reflect the current state, the issue is being unassigned per project policy. Please feel free to re-take assignment of the issue if it is being actively worked, or if you plan to start that work soon.
jjbskir commentedon Apr 22, 2025
Hey, I noticed the same issue recently on this line of code as well. Is this expected behavior? If I have an existing
VectorSchemaRootand want to add a newFieldVectorto it is there a better way to do it?Happy to put up a CR to address the issue as well.
lidavidm commentedon Apr 22, 2025
I suppose you can always create a new root, but given the existence of the method I would support fixing this too. PRs are welcome.
jjbskir commentedon Apr 28, 2025
Sounds good! Will look into putting up a PR for this.
apacheGH-301: Allow adding a vector at the end of VectorSchemaRoot
apacheGH-301: Allow adding a vector at the end of VectorSchemaRoot
apacheGH-301: Allow adding a vector at the end of VectorSchemaRoot
apacheGH-301: Allow adding a vector at the end of VectorSchemaRoot
apacheGH-301: [Vector] Allow adding a vector at the end of VectorSche…