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

Optimized slicing #1285

Merged
merged 1 commit into from
Oct 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/array/binary/mod.rs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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