Liya Fan created ARROW-6896:
-------------------------------

             Summary: [Java] Vector schema root should not share vectors
                 Key: ARROW-6896
                 URL: https://issues.apache.org/jira/browse/ARROW-6896
             Project: Apache Arrow
          Issue Type: Bug
          Components: Java
            Reporter: Liya Fan
            Assignee: Liya Fan


Vector schema root should not share vectors. Otherwise, unexpectd behavior 
would happen. 

Please note that VectorSchemaRoot is not just a container for vectors, it is 
also a resource (it implements the AutoClosable interface), and it manages the 
life cycle of its inner vectors.

When two VectorSchemaRoots share vectors, something unexpected may happen. 
Consider the following scenario, which is frequently encountered in a SQL 
engine.

1. We create a batch:
VectorSchemaRoot oldBatch = ...

2. We add a vector to it, which results in a new batch
VectorSchemaRoot newBatch = oldBatch.addVector(vector);

3. We are done with the old batch, and release the resource
oldBatch.close();

4. We continue to use the new batch, but gets an exception, because some inner 
vectors have been released by the old batch. 





--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to