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

Commit

Permalink
improve utf8 init validity (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored Oct 14, 2021
1 parent 6ec2ffa commit 0b37568
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/array/boolean/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl MutableBooleanArray {
}

fn init_validity(&mut self) {
let mut validity = MutableBitmap::new();
let mut validity = MutableBitmap::with_capacity(self.values.capacity());
validity.extend_constant(self.len(), true);
validity.set(self.len() - 1, false);
self.validity = Some(validity)
Expand Down
2 changes: 1 addition & 1 deletion src/array/list/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<O: Offset, M: MutableArray> MutableListArray<O, M> {
fn init_validity(&mut self) {
let len = self.offsets.len() - 1;

let mut validity = MutableBitmap::new();
let mut validity = MutableBitmap::with_capacity(self.offsets.capacity());
validity.extend_constant(len, true);
validity.set(len - 1, false);
self.validity = Some(validity)
Expand Down
2 changes: 1 addition & 1 deletion src/array/primitive/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl<T: NativeType> MutablePrimitiveArray<T> {
}

fn init_validity(&mut self) {
let mut validity = MutableBitmap::new();
let mut validity = MutableBitmap::with_capacity(self.values.capacity());
validity.extend_constant(self.len(), true);
validity.set(self.len() - 1, false);
self.validity = Some(validity)
Expand Down
9 changes: 4 additions & 5 deletions src/array/utf8/mutable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,10 @@ impl<O: Offset> MutableUtf8Array<O> {
}

fn init_validity(&mut self) {
self.validity = Some(MutableBitmap::from_trusted_len_iter(
std::iter::repeat(true)
.take(self.len() - 1)
.chain(std::iter::once(false)),
))
let mut validity = MutableBitmap::with_capacity(self.offsets.capacity());
validity.extend_constant(self.len(), true);
validity.set(self.len() - 1, false);
self.validity = Some(validity);
}

/// Converts itself into an [`Array`].
Expand Down

0 comments on commit 0b37568

Please sign in to comment.