-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix MutableArrayData::extend_nulls (#1230) #4343
Fix MutableArrayData::extend_nulls (#1230) #4343
Conversation
@@ -53,7 +53,7 @@ struct _MutableArrayData<'a> { | |||
pub null_count: usize, | |||
|
|||
pub len: usize, | |||
pub null_buffer: MutableBuffer, | |||
pub null_buffer: Option<MutableBuffer>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does add a branch on append, in practice appending to a null mask is so branch heavy anyway, not to mention already involving a dyn dispatch, I struggle to see how this could have an appreciable performance impact
self.data.len += len; | ||
let bit_len = bit_util::ceil(self.data.len, 8); | ||
let nulls = self.data.null_buffer(); | ||
nulls.resize(bit_len, 0); | ||
self.data.null_count += len; | ||
(self.extend_nulls)(&mut self.data, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite its name this extends the values buffers with nulls, it doesn't do anything to the bit mask
…-data-extend-nulls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me -- thank you @tustvold
pub fn extend_nulls(&mut self, len: usize) { | ||
// TODO: null_buffer should probably be extended here as well |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
classic TODO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I remember adding it at the same time as I created #1230 - I then completely forgot about it 😅
Which issue does this PR close?
Closes #1230
Closes #4324
Rationale for this change
MutableArrayData::extend_nulls doesn't update the null bitmask, and so has never worked correctly. Since #3775 it most likely will result in freeze panicking. It is surprising that nobody has hit this before, although we use
MutableArrayData
in very limited places, andMutableArrayData::extend_nulls
in even fewer.What changes are included in this PR?
Are there any user-facing changes?