emilk commented on code in PR #10759:
URL: https://github.com/apache/arrow-rs/pull/10759#discussion_r3842623257
##########
arrow-buffer/src/builder/null.rs:
##########
@@ -244,19 +241,17 @@ impl NullBufferBuilder {
Some(self.bitmap_builder.as_ref()?.as_slice())
}
- fn materialize_if_needed(&mut self) {
- if self.bitmap_builder.is_none() {
- self.materialize()
- }
+ fn materialize_if_needed(&mut self) -> &mut BooleanBufferBuilder {
+ let (len, capacity) = (self.len, self.capacity);
+ self.bitmap_builder
+ .get_or_insert_with(|| Self::materialize(len, capacity))
}
Review Comment:
Benchmark pushed. It is up to 14% faster, with no perf regressions
Results from two runs (vs main):
| bench | run 1 | run 2 | |
| ----------------- | ------- | ------- | --- |
| `append_n_nulls` | −13.1% | −15.3% | |
| `append_slice` | −4.4% | −4.2% | |
| `append_null` | −0.5% | −1.4% | likely noise |
| `append` | −0.1% | +0.2% | likely noise |
| `append_non_null` | +1.4% | +2.4% | likely noise |
| `materialize` | +0.6% | +3.8% | likely noise |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]