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

Commit

Permalink
Fixed error in pushing bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecarleitao committed Sep 6, 2021
1 parent 877739b commit 6d55d31
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/array/primitive/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ impl<T: NativeType> MutablePrimitiveArray<T> {
if let Some(validity) = self.validity.as_mut() {
extend_trusted_len_unzip(iterator, validity, &mut self.values)
} else {
let mut validity =
MutableBitmap::from_trusted_len_iter(std::iter::repeat(true).take(self.len()));
let mut validity = MutableBitmap::new();
validity.extend_constant(self.len(), true);
extend_trusted_len_unzip(iterator, &mut validity, &mut self.values);
if validity.null_count() > 0 {
self.validity = Some(validity);
Expand Down Expand Up @@ -449,10 +449,10 @@ pub(crate) unsafe fn extend_trusted_len_unzip<I, P, T>(
I: Iterator<Item = Option<P>>,
{
let (_, upper) = iterator.size_hint();
let len = upper.expect("trusted_len_unzip requires an upper limit");
let additional = upper.expect("trusted_len_unzip requires an upper limit");

validity.reserve(len);
buffer.reserve(len);
validity.reserve(additional);
buffer.reserve(additional);

for item in iterator {
let item = if let Some(item) = item {
Expand Down
6 changes: 2 additions & 4 deletions src/bitmap/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ impl MutableBitmap {
if self.length % 8 == 0 {
self.buffer.push_unchecked(0);
}
if value {
let byte = self.buffer.as_mut_slice().last_mut().unwrap();
*byte = set(*byte, self.length % 8, true);
};
let byte = self.buffer.as_mut_slice().last_mut().unwrap();
*byte = set(*byte, self.length % 8, value);
self.length += 1;
}

Expand Down

0 comments on commit 6d55d31

Please sign in to comment.