Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Merge branch 'jorgecarleitao:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanMarcus authored Oct 21, 2023
2 parents 4eaf057 + 9a26422 commit 8222aaa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Bitmap {
// just set each byte to u8::MAX
// we will not access data with index >= length
let bytes = vec![0b11111111u8; length.saturating_add(7) / 8];
unsafe { Bitmap::from_inner_unchecked(Arc::new(bytes.into()), 0, length, length) }
unsafe { Bitmap::from_inner_unchecked(Arc::new(bytes.into()), 0, length, 0) }
}

/// Counts the nulls (unset bits) starting from `offset` bits and for `length` bits.
Expand Down
3 changes: 2 additions & 1 deletion src/io/parquet/read/deserialize/binary/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ impl<O: Offset> Binary<O> {
if self.offsets.len_proxy() == 100 && self.offsets.capacity() > 100 {
let bytes_per_row = self.values.len() / 100 + 1;
let bytes_estimate = bytes_per_row * self.offsets.capacity();
if bytes_estimate > self.values.capacity() {

if bytes_estimate > self.values.capacity() && bytes_estimate < 10 * 1024 * 1024 {
self.values.reserve(bytes_estimate - self.values.capacity());
}
}
Expand Down
19 changes: 19 additions & 0 deletions tests/it/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,25 @@ fn as_slice_offset_middle() {
assert_eq!(length, 5);
}

#[test]
fn new_constant() {
let b = Bitmap::new_constant(true, 9);
let (slice, offset, length) = b.as_slice();
assert_eq!(slice[0], 0b11111111);
assert!((slice[1] & 0b00000001) > 0);
assert_eq!(offset, 0);
assert_eq!(length, 9);
assert_eq!(b.unset_bits(), 0);

let b = Bitmap::new_constant(false, 9);
let (slice, offset, length) = b.as_slice();
assert_eq!(slice[0], 0b00000000);
assert!((slice[1] & 0b00000001) == 0);
assert_eq!(offset, 0);
assert_eq!(length, 9);
assert_eq!(b.unset_bits(), 9);
}

#[test]
fn debug() {
let b = Bitmap::from([true, true, false, true, true, true, true, true, true]);
Expand Down

0 comments on commit 8222aaa

Please sign in to comment.