66import org .apache .arrow .memory .RootAllocator ;
77import org .apache .arrow .vector .BigIntVector ;
88import org .apache .arrow .vector .VectorSchemaRoot ;
9+ import org .apache .arrow .vector .types .pojo .Field ;
910import org .apache .arrow .vector .FieldVector ;
1011import org .apache .arrow .c .ArrowArray ;
1112import org .apache .arrow .c .ArrowSchema ;
1213import org .apache .arrow .c .Data ;
1314import org .apache .logging .log4j .LogManager ;
1415import org .apache .logging .log4j .Logger ;
1516
17+ import java .util .HashMap ;
18+ import java .util .Map ;
1619import java .util .concurrent .atomic .AtomicReference ;
1720import java .util .concurrent .locks .ReadWriteLock ;
1821import java .util .concurrent .locks .ReentrantReadWriteLock ;
@@ -33,6 +36,7 @@ public class ManagedVSR implements AutoCloseable {
3336 private final AtomicReference <VSRState > state ;
3437 private final ReadWriteLock lock ;
3538 private final long createdTime ;
39+ private final Map <String , Field > fields = new HashMap <>();
3640
3741
3842 public ManagedVSR (String id , VectorSchemaRoot vsr , BufferAllocator allocator ) {
@@ -42,6 +46,9 @@ public ManagedVSR(String id, VectorSchemaRoot vsr, BufferAllocator allocator) {
4246 this .state = new AtomicReference <>(VSRState .ACTIVE );
4347 this .lock = new ReentrantReadWriteLock ();
4448 this .createdTime = System .currentTimeMillis ();
49+ for (Field field : vsr .getSchema ().getFields ()) {
50+ fields .put (field .getName (), field );
51+ }
4552 }
4653
4754 /**
@@ -98,7 +105,7 @@ public void setRowCount(int rowCount) {
98105 public FieldVector getVector (String fieldName ) {
99106 lock .readLock ().lock ();
100107 try {
101- return vsr .getVector (fieldName );
108+ return vsr .getVector (fields . get ( fieldName ) );
102109 } finally {
103110 lock .readLock ().unlock ();
104111 }
0 commit comments