Skip to content

Fix length bug - #9

Open
alamb wants to merge 1 commit into
Dandandan:add_extendfrom
alamb:alamb/fix_len_bug
Open

alamb wants to merge 1 commit into
Dandandan:add_extendfrom
alamb:alamb/fix_len_bug

Conversation

@alamb

@alamb alamb commented Jan 11, 2026

Copy link
Copy Markdown

Fixes a bug in

(this was written by chatgpt codex, and I carefully reviewed it all)

@github-actions github-actions Bot added the arrow label Jan 11, 2026
offset: usize,
) {
let (lower, upper) = iter.size_hint();
let len = upper.expect("Iterator must have exact size_hint");

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The bug is that new_len is in terms of bits but self.len is measured in bytes (this is probably left over from when this code was originally in the boolean builder)

let mut builder = BooleanBufferBuilder::new(0);
let bools: Vec<_> = (0..10).map(|i| i % 2 == 0).collect();
unsafe { builder.extend_trusted_len(bools.into_iter()) };
assert_eq!(builder.as_slice().len(), bit_util::ceil(builder.len(), 8));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These tests fails like this without the fix:

failures:

---- builder::boolean::tests::test_extend_trusted_len_sets_byte_len stdout ----

thread 'builder::boolean::tests::test_extend_trusted_len_sets_byte_len' (28877654) panicked at arrow-buffer/src/builder/boolean.rs:611:9:
assertion `left == right` failed
  left: 10
 right: 2

---- builder::boolean::tests::test_extend_trusted_len_then_append stdout ----

thread 'builder::boolean::tests::test_extend_trusted_len_then_append' (28877655) panicked at arrow-buffer/src/builder/boolean.rs:621:9:
assertion `left == right` failed
  left: 9
 right: 2


failures:
    builder::boolean::tests::test_extend_trusted_len_sets_byte_len
    builder::boolean::tests::test_extend_trusted_len_then_append

test result: FAILED. 235 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.40s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant