[ 
https://issues.apache.org/jira/browse/ARROW-17530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17638374#comment-17638374
 ] 

Apache Arrow JIRA Bot commented on ARROW-17530:
-----------------------------------------------

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|https://arrow.apache.org/docs/dev/developers/bug_reports.html#issue-assignment].
 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.

> [Java] VectorSchemaRoot#addVector() cannot add a vector to the end of the 
> current vector collection
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ARROW-17530
>                 URL: https://issues.apache.org/jira/browse/ARROW-17530
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: Java
>    Affects Versions: 9.0.0, 9.0.1
>            Reporter: Larry White
>            Assignee: Larry White
>            Priority: Major
>
> 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:
> {code:java}
> public VectorSchemaRoot addVector(int index, FieldVector vector) {
>   Preconditions.checkNotNull(vector);
>   Preconditions.checkArgument(index >= 0 && index < fieldVectors.size());
>   List<FieldVector> newVectors = new ArrayList<>();
>   for (int i = 0; i < fieldVectors.size(); i++) {
>     if (i == index) {
>       newVectors.add(vector);
>     }
>     newVectors.add(fieldVectors.get(i));
>   }
>   return new VectorSchemaRoot(newVectors);
> }
>  {code}
> One possible implementation resolving the issue is shown below.
> {code:java}
> public VectorSchemaRoot addVector(int index, FieldVector vector) {
>   Preconditions.checkNotNull(vector);
>   Preconditions.checkArgument(index >= 0 && index <= fieldVectors.size());
>   List<FieldVector> newVectors = new ArrayList<>();
>   if (index == fieldVectors.size()) {
>     newVectors.addAll(fieldVectors);
>     newVectors.add(vector); 
>   } else {
>     for (int i = 0; i < fieldVectors.size(); i++) {
>       if (i == index) {
>         newVectors.add(vector);
>       }
>       newVectors.add(fieldVectors.get(i));
>     }
>   }
>   return new VectorSchemaRoot(newVectors);
> }
> {code}
>  
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to