Is using FieldReader recommended over using using a cast with direct access? In 
https://arrow.apache.org/docs/java/vector.html#building-valuevector it says that

"writer/reader is not as efficient as direct access"

What's the recommended way to read a value between these two techniques?

First method using reader:

FieldReader reader = vectorSchemaRoot.getVector(123).getReader();
reader.setPosition(456);
reader.readLong();

Second method using cast to BigIntVector with direct access:

((BigIntVector) vectorSchemaRoot.getVector(123)).getValueAsLong(456);

On 2021/09/09 16:33:57, Micah Kornfield <[email protected]> wrote: 
> I'll add that getObject is going to be expensive in general, since it boxes
> the integer and does a copy of the VarBinary data.
> 
> On Thu, Sep 9, 2021 at 9:25 AM Jacques Nadeau <[email protected]> wrote:
> 
> > Fieldreader was defined to expose direct access in a type centric way.
> >
> > On Thu, Sep 9, 2021, 1:47 AM Daniel Hsu <[email protected]> wrote:
> >
> >> Perhaps a better way to phrase this question is:
> >>
> >> If the VectorSchemaRoot already stores BigIntVector's and
> >> VarBinaryVector's, how can I make the VectorSchemaRoot directly return
> >> `long` and `byte[]` values when doing random reads, instead of returning
> >> `Object` when doing random reads?
> >>
> >> On 2021/09/09 08:43:56, Daniel Hsu <[email protected]> wrote:
> >> > I have a VectorSchemaRoot object containing many BigIntVector's and
> >> VarBinaryVector's, and I want to do many random value reads.
> >> >
> >> > Right now I am doing the random value reads like this:
> >> >
> >> > VectorSchemaRoot # getVector(<vector number>) # getObject(<row number>)
> >> >
> >> > This returns an `Object` and then I look in VectorSchemaRoot # Schema #
> >> getField() to figure out whether to cast this object to a `long` or
> >> `byte[]`.
> >> >
> >> > Is it possible to avoid casting from `Object` to `long` or `byte[]` on
> >> every random read?
> >> >
> >>
> >
> 

Reply via email to