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

Commit

Permalink
account for both chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Sep 23, 2021
1 parent 91bd01d commit a08e426
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/bitmap/immutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use super::{
utils::{count_zeros, fmt, get_bit, get_bit_unchecked, BitChunk, BitChunks, BitmapIter},
MutableBitmap,
};
use num_traits::zero;

/// An immutable container whose API is optimized to handle bitmaps. All quantities on this
/// container's API are measured in bits.
Expand Down Expand Up @@ -118,8 +119,10 @@ impl Bitmap {
// count the null values in the slice
self.null_count = count_zeros(&self.bytes, offset, length);
} else {
// subtract the null count of the chunk we slice off
self.null_count -= count_zeros(&self.bytes, self.offset, self.offset + offset)
// subtract the null count of the chunks we slice off
let start_end = self.offset + offset + length;
self.null_count -= (count_zeros(&self.bytes, self.offset, self.offset + offset)
+ count_zeros(&self.bytes, start_end, self.length - start_end))
}
self.offset += offset;
self.length = length;
Expand Down

0 comments on commit a08e426

Please sign in to comment.