Got it. Would the same go for non-primitive layouts like binary layout? Wouldn’t checking IsNull on each iteration cause a cache miss on each iteration?
On Fri, Nov 5, 2021 at 6:23 PM Matthew Topol <[email protected]> wrote: > Hey James, all of the primitive Array types that store their data as a > contiguous array have a function which can return that array. For example, > if you have an *array.Date32 you can use the Date32Values() method as shown > here: > https://pkg.go.dev/github.com/apache/arrow/go/[email protected]/array#Date32.Date32Values > The same would be true for all of the other primitive types such as the int > and uint types. > > > > You would still have to consult the validity bitmap in order to tell > whether a particular index is null either via the IsNull method. In most > cases the overhead from calling Value(i) instead of just iterating over a > slice is negligible. > > > > > > *From:* James Van Alstine <[email protected]> > *Sent:* Friday, November 5, 2021 8:31 PM > *To:* [email protected] > *Subject:* [Go] Efficiently loop through values > > > > What is the most efficient way to loop through the values in an array? It > seems like it would be most efficient if I could get a contiguous array of > values to loop through, but as far as I know the array interface only > exposes the ith value via Value(i). Is there a different way to loop over > the values? >
