Class VectorAccessors

java.lang.Object
org.apache.drill.exec.vector.accessor.reader.VectorAccessors

public class VectorAccessors extends Object
Collection of vector accessors. A single class handles the single-batch case. But, for hyper-vectors, we need a separate accessor for each (vector, sub-vector) combination to handle the indirections in the hyper-vector case.

For a required vector:
reader index --> hyper vector --> required vector

For a nullable vector:
reader index --> hyper vector --> nullable vector
nullable vector --> bits vector
--> values vector

For a repeated vector:
reader index --> hyper vector --> repeated vector
repeated vector --> offset vector
--> values vector

And so on. In each case, we must start with a top-level vector as indicated the row index, indirected through the SV4. That is done by the reader index. That points to a top-level vector in the hyper-vector.

Most of the vectors needed are nested. These inner vectors are not part of a hyper-vector list. Instead, we must get the top-level vector, then navigate down from that vector to the desired vector.

Sometimes the navigation is static (the "bits" vector for a nullable vector.) Other times, it is a bit more dynamic: a member of a map (given by index) or the member of a union (given by type.)

These accessors can be chained to handle deeply-nested structures such as an array of maps that contains a list of unions.

Because the navigation is required on every access, the use of hyper vectors is slow. Since hyper-vectors are seldom used, we optimize for the single-batch case by caching vectors at each stage. Thus, for the single-batch case, we use different accessor implementations. To keep the rest of the code simple, both the hyper and single batch cases use the same API, but they use entirely different implementations. The methods here choose the correct implementation for the single and hyper cases.