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 549ddbf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 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,11 @@ 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;
let head_count = count_zeros(&self.bytes, self.offset, offset);
let tail_count = count_zeros(&self.bytes, start_end, self.length - length - offset);
self.null_count -= head_count + tail_count;
}
self.offset += offset;
self.length = length;
Expand Down

0 comments on commit 549ddbf

Please sign in to comment.