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

bugfix: adjust allocated_size() in GenericByteViewBuilder #7104

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion arrow-array/src/builder/generic_bytes_view_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ impl<T: ByteViewType + ?Sized> GenericByteViewBuilder<T> {
/// Return the allocated size of this builder in bytes, useful for memory accounting.
pub fn allocated_size(&self) -> usize {
let views = self.views_builder.capacity() * std::mem::size_of::<u128>();
let null = self.null_buffer_builder.allocated_size();
let null = self.null_buffer_builder.allocated_size() / 8;
let buffer_size = self.completed.iter().map(|b| b.capacity()).sum::<usize>();
let in_progress = self.in_progress.capacity();
let tracker = match &self.string_tracker {
Expand Down Expand Up @@ -730,4 +730,16 @@ mod tests {
MAX_BLOCK_SIZE as usize
);
}

#[test]
fn test_string_view_size() {
let mut builder = StringViewBuilder::new();
assert_eq!(builder.allocated_size(), 16384);

builder.append_value("hello");
assert_eq!(builder.allocated_size(), 16384);

builder.append_null();
assert_eq!(builder.allocated_size(), 16384 + 128);
}
}
Loading