Skip to content

Commit

Permalink
fix silly bug
Browse files Browse the repository at this point in the history
  • Loading branch information
orlp committed Jan 16, 2025
1 parent 39e8b69 commit c41015e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/polars-arrow/src/bitmap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,10 @@ impl BitmapBuilder {
/// self.bytes.len() + 8 <= self.bytes.capacity() must hold.
#[inline(always)]
unsafe fn flush_word_unchecked(&mut self, w: u64) {
let p = self.bytes.as_mut_ptr().add(self.bytes.len()).cast::<u64>();
let cur_len = self.bytes.len();
let p = self.bytes.as_mut_ptr().add(cur_len).cast::<u64>();
p.write_unaligned(w.to_le());
self.bytes.set_len(self.bytes.len() + 8);
self.bytes.set_len(cur_len + 8);
}

/// # Safety
Expand Down Expand Up @@ -156,7 +157,7 @@ impl BitmapBuilder {
let slice_bit_offset = offset % 8;
if slice_bit_offset > 0 {
let bits_in_first_byte = (8 - slice_bit_offset).min(length);
let first_byte = *slice.get_unchecked(0) >> slice_bit_offset;
let first_byte = *slice.get_unchecked(offset / 8) >> slice_bit_offset;
self.push_word_with_len_unchecked(
first_byte as u64 & ((1 << bits_in_first_byte) - 1),
bits_in_first_byte,
Expand Down

0 comments on commit c41015e

Please sign in to comment.