Open TimDiekmann opened 2 years ago
I wonder if we could just add advance()
to the ListBuilder interface.
I am a little worried about adding a pub advance()
function to all the builders that simply leaves the values undefined as it would be fairly easy to misuse.
Maybe we ListBuilder::advance
could be pub
and the advance()
functions on the value builders could be pub(crate)
🤔
Given the scenario from the Fixed size list layout in the Arrow Columnar Format, I have a list of IP addresses:
For an array of length 4 with respective values:
which will have the following representation:
When using the builder-API I currently have this code:
As I wrote
value_builder.append_nulls(4)
the value array has the nulls inside. As in the specs, the values are unspecified and the null count of the value array must be 0. In order to achieve this, I could replace it withvalue_builder.append_values(&[0, 0, 0, 0], &[false, false, false, false])
or do a loop, but a) this introduces unnecessary overhead because the values are not needed, b) is pretty boilerplate code, and c) isn't very easy if the type isn't known beforehand in more complex examples (like deeply nested types, etc.).Proposed solution
If builders would have an
fn advance
method, then one could simply callarray.advance(4)
, which won't set the values tonull
at the internal bitmap.The
BufferBuilder
already has anadvance
method, this could probably be forwarded to the user.