Skip to content

Commit

Permalink
Optimized slicing (jorgecarleitao#1285)
Browse files Browse the repository at this point in the history
Optimized slice
  • Loading branch information
jorgecarleitao authored and ritchie46 committed Nov 6, 2022
1 parent 396db63 commit 737c3fc
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/array/binary/mod.rs
Expand Up @@ -203,7 +203,8 @@ impl<O: Offset> BinaryArray<O> {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
let offsets = self.offsets.clone().slice_unchecked(offset, length + 1);
Self {
data_type: self.data_type.clone(),
Expand Down
3 changes: 2 additions & 1 deletion src/array/boolean/mod.rs
Expand Up @@ -164,7 +164,8 @@ impl BooleanArray {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
Self {
data_type: self.data_type.clone(),
values: self.values.clone().slice_unchecked(offset, length),
Expand Down
3 changes: 2 additions & 1 deletion src/array/fixed_size_binary/mod.rs
Expand Up @@ -131,7 +131,8 @@ impl FixedSizeBinaryArray {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
let values = self
.values
.clone()
Expand Down
3 changes: 2 additions & 1 deletion src/array/fixed_size_list/mod.rs
Expand Up @@ -150,7 +150,8 @@ impl FixedSizeListArray {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
let values = self
.values
.clone()
Expand Down
3 changes: 2 additions & 1 deletion src/array/list/mod.rs
Expand Up @@ -222,7 +222,8 @@ impl<O: Offset> ListArray<O> {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
let offsets = self.offsets.clone().slice_unchecked(offset, length + 1);
Self {
data_type: self.data_type.clone(),
Expand Down
3 changes: 2 additions & 1 deletion src/array/map/mod.rs
Expand Up @@ -167,7 +167,8 @@ impl MapArray {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
Self {
data_type: self.data_type.clone(),
offsets,
Expand Down
3 changes: 2 additions & 1 deletion src/array/primitive/mod.rs
Expand Up @@ -230,7 +230,8 @@ impl<T: NativeType> PrimitiveArray<T> {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
Self {
data_type: self.data_type.clone(),
values: self.values.clone().slice_unchecked(offset, length),
Expand Down
3 changes: 2 additions & 1 deletion src/array/struct_/mod.rs
Expand Up @@ -198,7 +198,8 @@ impl StructArray {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
Self {
data_type: self.data_type.clone(),
values: self
Expand Down
3 changes: 2 additions & 1 deletion src/array/utf8/mod.rs
Expand Up @@ -220,7 +220,8 @@ impl<O: Offset> Utf8Array<O> {
let validity = self
.validity
.clone()
.map(|x| x.slice_unchecked(offset, length));
.map(|bitmap| bitmap.slice_unchecked(offset, length))
.and_then(|bitmap| (bitmap.unset_bits() > 0).then(|| bitmap));
// + 1: `length == 0` implies that we take the first offset.
let offsets = self.offsets.clone().slice_unchecked(offset, length + 1);
Self {
Expand Down

0 comments on commit 737c3fc

Please sign in to comment.