GitHub user mobiusklein created a discussion: Proper way to initialize an `ListArray.Builder`
I've been using this library for a while now, but I have found a few places where I miss an invariant over how to initialize a `ListArray.Builder`. https://github.com/apache/arrow-dotnet/blob/3e235ea8720b7f41c1bacd08fa9b940f04187d5a/src/Apache.Arrow/Arrays/ListArray.cs#L46-L52 When initializing the builder the `ValueOffsetsBufferBuilder` is empty. When I am attentive, I remember to immediately call the `Append` method which adds `0` to the `ValueBuilder.Length` attribute being `0`. This ensures that the offset to the start of the first list in the array is 0, as shown in the specification https://arrow.apache.org/docs/format/Intro.html#list. Otherwise trying to _read_ this array later will skip over everything before the first call to `Append`. I recently spent a time running down a bug that was effectively that I forgot to call `Append` _after_ `Clear`ing the `ListArray.Builder`. Is there a reason an empty `ListArray.Builder` shouldn't always initialize with `ValueOffsetsBufferBuilder = [0]` and do similar when cleared? Thank you GitHub link: https://github.com/apache/arrow-dotnet/discussions/321 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected]
