Skip to content
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

Merged

Conversation

tustvold
Copy link
Contributor

@tustvold tustvold commented Jun 2, 2023

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, and MutableArrayData::extend_nulls in even fewer.

What changes are included in this PR?

Are there any user-facing changes?

@github-actions github-actions bot added the arrow Changes to the arrow crate label Jun 2, 2023
@@ -53,7 +53,7 @@ struct _MutableArrayData<'a> {
pub null_count: usize,

pub len: usize,
pub null_buffer: MutableBuffer,
pub null_buffer: Option<MutableBuffer>,
Copy link
Contributor Author

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);
Copy link
Contributor Author

@tustvold tustvold Jun 2, 2023

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

Copy link
Contributor

@alamb alamb left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classic TODO

Copy link
Contributor Author

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 😅

@tustvold tustvold merged commit b46ea46 into apache:master Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate
Projects
None yet
2 participants