From 5b66f5f33d384e2dd060281b316785ae303af5b2 Mon Sep 17 00:00:00 2001 From: Jorge Leitao Date: Sun, 26 Jun 2022 06:42:20 -0700 Subject: [PATCH] Defered cloning in with_validity (#1104) --- src/array/binary/mod.rs | 20 ++++++++++------ src/array/boolean/mod.rs | 11 ++++----- src/array/dictionary/mod.rs | 22 ++++++++++-------- src/array/fixed_size_binary/mod.rs | 23 ++++++++++++------ src/array/fixed_size_list/mod.rs | 20 ++++++++++------ src/array/list/mod.rs | 24 +++++++++++++------ src/array/map/mod.rs | 24 +++++++++++++++++-- src/array/mod.rs | 4 ++-- src/array/null.rs | 1 + src/array/primitive/mod.rs | 36 +++++++++++++---------------- src/array/struct_/mod.rs | 25 +++++++++++++------- src/array/utf8/mod.rs | 23 +++++++++++------- src/compute/comparison/binary.rs | 12 +++++----- src/compute/comparison/boolean.rs | 12 +++++----- src/compute/comparison/primitive.rs | 12 +++++----- src/compute/comparison/utf8.rs | 12 +++++----- tests/it/compute/comparison.rs | 4 ++-- 17 files changed, 176 insertions(+), 109 deletions(-) diff --git a/src/array/binary/mod.rs b/src/array/binary/mod.rs index 6b0668865b8..af06d19501c 100644 --- a/src/array/binary/mod.rs +++ b/src/array/binary/mod.rs @@ -219,17 +219,23 @@ impl BinaryArray { std::sync::Arc::new(self) } - /// Clones this [`BinaryArray`] with a different validity. + /// Returns this [`BinaryArray`] with a new validity. /// # Panic /// Panics iff `validity.len() != self.len()`. #[must_use] - pub fn with_validity(&self, validity: Option) -> Self { + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`BinaryArray`]. + /// # Panics + /// This function panics iff `values.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity's length must be equal to the array's length") + panic!("validity must be equal to the array's length") } - let mut arr = self.clone(); - arr.validity = validity; - arr + self.validity = validity; } /// Creates an empty [`BinaryArray`], i.e. whose `.len` is zero. @@ -449,7 +455,7 @@ impl Array for BinaryArray { Box::new(self.slice_unchecked(offset, length)) } fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } fn to_boxed(&self) -> Box { Box::new(self.clone()) diff --git a/src/array/boolean/mod.rs b/src/array/boolean/mod.rs index 9901386cc4a..dc856c5e4d5 100644 --- a/src/array/boolean/mod.rs +++ b/src/array/boolean/mod.rs @@ -175,14 +175,13 @@ impl BooleanArray { } } - /// Clones this [`BooleanArray`], returning one with the provided validity. + /// Returns this [`BooleanArray`] with a new validity. /// # Panic /// This function panics iff `validity.len() != self.len()`. #[must_use] - pub fn with_validity(&self, validity: Option) -> Self { - let mut array = self.clone(); - array.set_validity(validity); - array + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self } /// Sets the validity of this [`BooleanArray`]. @@ -412,7 +411,7 @@ impl Array for BooleanArray { Box::new(self.slice_unchecked(offset, length)) } fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } fn to_boxed(&self) -> Box { Box::new(self.clone()) diff --git a/src/array/dictionary/mod.rs b/src/array/dictionary/mod.rs index 83993644836..0c9d9267375 100644 --- a/src/array/dictionary/mod.rs +++ b/src/array/dictionary/mod.rs @@ -109,16 +109,20 @@ impl DictionaryArray { } } - /// Sets the validity bitmap on this [`Array`]. + /// Returns this [`DictionaryArray`] with a new validity. /// # Panic /// This function panics iff `validity.len() != self.len()`. - pub fn with_validity(&self, validity: Option) -> Self { - if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity should be as least as large as the array") - } - let mut arr = self.clone(); - arr.values = arr.values.with_validity(validity); - arr + #[must_use] + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of the keys of this [`DictionaryArray`]. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { + self.keys.set_validity(validity); } } @@ -213,7 +217,7 @@ impl Array for DictionaryArray { Box::new(self.slice_unchecked(offset, length)) } fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } fn to_boxed(&self) -> Box { Box::new(self.clone()) diff --git a/src/array/fixed_size_binary/mod.rs b/src/array/fixed_size_binary/mod.rs index 0378a16f6c8..ab1a28beb08 100644 --- a/src/array/fixed_size_binary/mod.rs +++ b/src/array/fixed_size_binary/mod.rs @@ -144,17 +144,23 @@ impl FixedSizeBinaryArray { } } - /// Sets the validity bitmap on this [`FixedSizeBinaryArray`]. + /// Returns this [`FixedSizeBinaryArray`] with a new validity. /// # Panic /// This function panics iff `validity.len() != self.len()`. #[must_use] - pub fn with_validity(&self, validity: Option) -> Self { + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`FixedSizeBinaryArray`]. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity should be as least as large as the array") + panic!("validity must be equal to the array's length") } - let mut arr = self.clone(); - arr.validity = validity; - arr + self.validity = validity; } } @@ -273,12 +279,15 @@ impl Array for FixedSizeBinaryArray { fn slice(&self, offset: usize, length: usize) -> Box { Box::new(self.slice(offset, length)) } + unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Box { Box::new(self.slice_unchecked(offset, length)) } + fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } + fn to_boxed(&self) -> Box { Box::new(self.clone()) } diff --git a/src/array/fixed_size_list/mod.rs b/src/array/fixed_size_list/mod.rs index c331827e20f..d50518190f9 100644 --- a/src/array/fixed_size_list/mod.rs +++ b/src/array/fixed_size_list/mod.rs @@ -158,17 +158,23 @@ impl FixedSizeListArray { } } - /// Sets the validity bitmap on this [`FixedSizeListArray`]. + /// Returns this [`FixedSizeListArray`] with a new validity. /// # Panic /// This function panics iff `validity.len() != self.len()`. #[must_use] - pub fn with_validity(&self, validity: Option) -> Self { + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`FixedSizeListArray`]. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity should be as least as large as the array") + panic!("validity must be equal to the array's length") } - let mut arr = self.clone(); - arr.validity = validity; - arr + self.validity = validity; } } @@ -268,7 +274,7 @@ impl Array for FixedSizeListArray { Box::new(self.slice_unchecked(offset, length)) } fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } fn to_boxed(&self) -> Box { Box::new(self.clone()) diff --git a/src/array/list/mod.rs b/src/array/list/mod.rs index 451d90086ae..88ab6513234 100644 --- a/src/array/list/mod.rs +++ b/src/array/list/mod.rs @@ -231,16 +231,23 @@ impl ListArray { } } - /// Sets the validity bitmap on this [`ListArray`]. + /// Returns this [`ListArray`] with a new validity. /// # Panic /// This function panics iff `validity.len() != self.len()`. - pub fn with_validity(&self, validity: Option) -> Self { + #[must_use] + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`ListArray`]. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity should be as least as large as the array") + panic!("validity must be equal to the array's length") } - let mut arr = self.clone(); - arr.validity = validity; - arr + self.validity = validity; } } @@ -368,12 +375,15 @@ impl Array for ListArray { fn slice(&self, offset: usize, length: usize) -> Box { Box::new(self.slice(offset, length)) } + unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Box { Box::new(self.slice_unchecked(offset, length)) } + fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } + fn to_boxed(&self) -> Box { Box::new(self.clone()) } diff --git a/src/array/map/mod.rs b/src/array/map/mod.rs index 015b9feab81..cc8a02c7ccd 100644 --- a/src/array/map/mod.rs +++ b/src/array/map/mod.rs @@ -117,6 +117,25 @@ impl MapArray { Self::new(data_type, Buffer::from(vec![0i32]), field, None) } + /// Returns this [`MapArray`] with a new validity. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + #[must_use] + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`MapArray`]. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { + if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { + panic!("validity's length must be equal to the array's length") + } + self.validity = validity; + } + /// Boxes self into a [`Box`]. pub fn boxed(self) -> Box { Box::new(self) @@ -252,9 +271,10 @@ impl Array for MapArray { Box::new(self.slice_unchecked(offset, length)) } - fn with_validity(&self, _validity: Option) -> Box { - self.to_boxed() + fn with_validity(&self, validity: Option) -> Box { + Box::new(self.clone().with_validity(validity)) } + fn to_boxed(&self) -> Box { Box::new(self.clone()) } diff --git a/src/array/mod.rs b/src/array/mod.rs index e020a1bd184..cc5038fa0f4 100644 --- a/src/array/mod.rs +++ b/src/array/mod.rs @@ -102,9 +102,9 @@ pub trait Array: Send + Sync + dyn_clone::DynClone + 'static { /// The caller must ensure that `offset + length <= self.len()` unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Box; - /// Sets the validity bitmap on this [`Array`]. + /// Clones this [`Array`] with a new new assigned bitmap. /// # Panic - /// This function panics iff `validity.len() < self.len()`. + /// This function panics iff `validity.len() != self.len()`. fn with_validity(&self, validity: Option) -> Box; /// Clone a `&dyn Array` to an owned `Box`. diff --git a/src/array/null.rs b/src/array/null.rs index 5b0ee9fd4b5..6a00fcb3530 100644 --- a/src/array/null.rs +++ b/src/array/null.rs @@ -114,6 +114,7 @@ impl Array for NullArray { fn with_validity(&self, _: Option) -> Box { panic!("cannot set validity of a null array") } + fn to_boxed(&self) -> Box { Box::new(self.clone()) } diff --git a/src/array/primitive/mod.rs b/src/array/primitive/mod.rs index 0a4aacf2a9a..74604ed7e8b 100644 --- a/src/array/primitive/mod.rs +++ b/src/array/primitive/mod.rs @@ -241,58 +241,54 @@ impl PrimitiveArray { } } - /// Returns a clone of this [`PrimitiveArray`] with a new validity. + /// Returns this [`PrimitiveArray`] with a new validity. /// # Panics /// This function panics iff `validity.len() != self.len()`. #[must_use] - pub fn with_validity(&self, validity: Option) -> Self { - let mut out = self.clone(); - out.set_validity(validity); - out + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self } - /// Update the validity buffer of this [`PrimitiveArray`]. + /// Sets the validity of this [`PrimitiveArray`]. /// # Panics - /// This function panics iff `values.len() != self.len()`. + /// This function panics iff `validity.len() != self.len()`. pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity should be as least as large as the array") + panic!("validity's length must be equal to the array's length") } self.validity = validity; } - /// Returns a clone of this [`PrimitiveArray`] with new values. + /// Returns this [`PrimitiveArray`] with new values. /// # Panics /// This function panics iff `values.len() != self.len()`. #[must_use] - pub fn with_values(&self, values: Buffer) -> Self { - let mut out = self.clone(); - out.set_values(values); - out + pub fn with_values(mut self, values: Buffer) -> Self { + self.set_values(values); + self } - /// Update the values buffer of this [`PrimitiveArray`]. + /// Update the values of this [`PrimitiveArray`]. /// # Panics /// This function panics iff `values.len() != self.len()`. pub fn set_values(&mut self, values: Buffer) { assert_eq!( values.len(), self.len(), - "values length should be equal to this arrays length" + "values' length must be equal to this arrays' length" ); self.values = values; } - /// Applies a function `f` to the validity of this array, the caller can decide to make - /// it mutable or not. + /// Applies a function `f` to the validity of this array. /// /// This is an API to leverage clone-on-write /// # Panics /// This function panics if the function `f` modifies the length of the [`Bitmap`]. pub fn apply_validity Bitmap>(&mut self, f: F) { if let Some(validity) = std::mem::take(&mut self.validity) { - assert_eq!(validity.len(), self.values.len()); - self.validity = Some(f(validity)) + self.set_validity(Some(f(validity))) } } @@ -462,7 +458,7 @@ impl Array for PrimitiveArray { Box::new(self.slice_unchecked(offset, length)) } fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } fn to_boxed(&self) -> Box { Box::new(self.clone()) diff --git a/src/array/struct_/mod.rs b/src/array/struct_/mod.rs index cb888ce8721..e7e99a9c602 100644 --- a/src/array/struct_/mod.rs +++ b/src/array/struct_/mod.rs @@ -208,17 +208,23 @@ impl StructArray { } } - /// Sets the validity bitmap on this [`StructArray`]. - /// # Panic + /// Returns this [`StructArray`] with a new validity. + /// # Panics /// This function panics iff `validity.len() != self.len()`. #[must_use] - pub fn with_validity(&self, validity: Option) -> Self { + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`StructArray`]. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity should be as least as large as the array") + panic!("validity's length must be equal to the array's length") } - let mut arr = self.clone(); - arr.validity = validity; - arr + self.validity = validity; } /// Boxes self into a [`Box`]. @@ -302,12 +308,15 @@ impl Array for StructArray { fn slice(&self, offset: usize, length: usize) -> Box { Box::new(self.slice(offset, length)) } + unsafe fn slice_unchecked(&self, offset: usize, length: usize) -> Box { Box::new(self.slice_unchecked(offset, length)) } + fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } + fn to_boxed(&self) -> Box { Box::new(self.clone()) } diff --git a/src/array/utf8/mod.rs b/src/array/utf8/mod.rs index 8c9b9046f9e..b6b56e14ccb 100644 --- a/src/array/utf8/mod.rs +++ b/src/array/utf8/mod.rs @@ -230,16 +230,23 @@ impl Utf8Array { std::sync::Arc::new(self) } - /// Clones this [`Utf8Array`] and assigns it a new validity - /// # Panic + /// Returns this [`Utf8Array`] with a new validity. + /// # Panics + /// This function panics iff `validity.len() != self.len()`. + #[must_use] + pub fn with_validity(mut self, validity: Option) -> Self { + self.set_validity(validity); + self + } + + /// Sets the validity of this [`Utf8Array`]. + /// # Panics /// This function panics iff `validity.len() != self.len()`. - pub fn with_validity(&self, validity: Option) -> Self { + pub fn set_validity(&mut self, validity: Option) { if matches!(&validity, Some(bitmap) if bitmap.len() != self.len()) { - panic!("validity's len must be equal to the array") + panic!("validity's length must be equal to the array's length") } - let mut arr = self.clone(); - arr.validity = validity; - arr + self.validity = validity; } /// Try to convert this `Utf8Array` to a `MutableUtf8Array` @@ -566,7 +573,7 @@ impl Array for Utf8Array { Box::new(self.slice_unchecked(offset, length)) } fn with_validity(&self, validity: Option) -> Box { - Box::new(self.with_validity(validity)) + Box::new(self.clone().with_validity(validity)) } fn to_boxed(&self) -> Box { diff --git a/src/compute/comparison/binary.rs b/src/compute/comparison/binary.rs index 242c334d2ea..0317a9b7783 100644 --- a/src/compute/comparison/binary.rs +++ b/src/compute/comparison/binary.rs @@ -56,8 +56,8 @@ pub fn eq(lhs: &BinaryArray, rhs: &BinaryArray) -> BooleanArray pub fn eq_and_validity(lhs: &BinaryArray, rhs: &BinaryArray) -> BooleanArray { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a == b); finish_eq_validities(out, validity_lhs, validity_rhs) @@ -71,7 +71,7 @@ pub fn eq_scalar(lhs: &BinaryArray, rhs: &[u8]) -> BooleanArray { /// Perform `lhs == rhs` operation on [`BinaryArray`] and a scalar and include validities in comparison. pub fn eq_scalar_and_validity(lhs: &BinaryArray, rhs: &[u8]) -> BooleanArray { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = compare_op_scalar(&lhs, rhs, |a, b| a == b); finish_eq_validities(out, validity, None) @@ -90,8 +90,8 @@ pub fn neq(lhs: &BinaryArray, rhs: &BinaryArray) -> BooleanArra pub fn neq_and_validity(lhs: &BinaryArray, rhs: &BinaryArray) -> BooleanArray { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a != b); finish_neq_validities(out, validity_lhs, validity_rhs) @@ -105,7 +105,7 @@ pub fn neq_scalar(lhs: &BinaryArray, rhs: &[u8]) -> BooleanArray { /// Perform `lhs != rhs` operation on [`BinaryArray`] and a scalar and include validities in comparison. pub fn neq_scalar_and_validity(lhs: &BinaryArray, rhs: &[u8]) -> BooleanArray { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = compare_op_scalar(&lhs, rhs, |a, b| a != b); finish_neq_validities(out, validity, None) diff --git a/src/compute/comparison/boolean.rs b/src/compute/comparison/boolean.rs index 256f2f3f851..8295ad3dbb9 100644 --- a/src/compute/comparison/boolean.rs +++ b/src/compute/comparison/boolean.rs @@ -43,8 +43,8 @@ pub fn eq(lhs: &BooleanArray, rhs: &BooleanArray) -> BooleanArray { pub fn eq_and_validity(lhs: &BooleanArray, rhs: &BooleanArray) -> BooleanArray { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| !(a ^ b)); finish_eq_validities(out, validity_lhs, validity_rhs) @@ -62,7 +62,7 @@ pub fn eq_scalar(lhs: &BooleanArray, rhs: bool) -> BooleanArray { /// Perform `lhs == rhs` operation on a [`BooleanArray`] and a scalar value and include validities in comparison. pub fn eq_scalar_and_validity(lhs: &BooleanArray, rhs: bool) -> BooleanArray { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); if rhs { finish_eq_validities(lhs, validity, None) } else { @@ -83,8 +83,8 @@ pub fn neq(lhs: &BooleanArray, rhs: &BooleanArray) -> BooleanArray { pub fn neq_and_validity(lhs: &BooleanArray, rhs: &BooleanArray) -> BooleanArray { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a ^ b); finish_neq_validities(out, validity_lhs, validity_rhs) @@ -98,7 +98,7 @@ pub fn neq_scalar(lhs: &BooleanArray, rhs: bool) -> BooleanArray { /// Perform `left != right` operation on an array and a scalar value. pub fn neq_scalar_and_validity(lhs: &BooleanArray, rhs: bool) -> BooleanArray { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = eq_scalar(&lhs, !rhs); finish_neq_validities(out, validity, None) } diff --git a/src/compute/comparison/primitive.rs b/src/compute/comparison/primitive.rs index d801bdc1d75..7a400f5f850 100644 --- a/src/compute/comparison/primitive.rs +++ b/src/compute/comparison/primitive.rs @@ -108,8 +108,8 @@ where { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a.eq(b)); finish_eq_validities(out, validity_lhs, validity_rhs) @@ -131,7 +131,7 @@ where T::Simd: Simd8PartialEq, { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = compare_op_scalar(&lhs, rhs, |a, b| a.eq(b)); finish_eq_validities(out, validity, None) @@ -154,8 +154,8 @@ where { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a.neq(b)); finish_neq_validities(out, validity_lhs, validity_rhs) @@ -177,7 +177,7 @@ where T::Simd: Simd8PartialEq, { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = compare_op_scalar(&lhs, rhs, |a, b| a.neq(b)); finish_neq_validities(out, validity, None) diff --git a/src/compute/comparison/utf8.rs b/src/compute/comparison/utf8.rs index c8a855a0860..31983fa816c 100644 --- a/src/compute/comparison/utf8.rs +++ b/src/compute/comparison/utf8.rs @@ -51,8 +51,8 @@ pub fn eq(lhs: &Utf8Array, rhs: &Utf8Array) -> BooleanArray { pub fn eq_and_validity(lhs: &Utf8Array, rhs: &Utf8Array) -> BooleanArray { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a == b); finish_eq_validities(out, validity_lhs, validity_rhs) @@ -62,8 +62,8 @@ pub fn eq_and_validity(lhs: &Utf8Array, rhs: &Utf8Array) -> Boo pub fn neq_and_validity(lhs: &Utf8Array, rhs: &Utf8Array) -> BooleanArray { let validity_lhs = lhs.validity().cloned(); let validity_rhs = rhs.validity().cloned(); - let lhs = lhs.with_validity(None); - let rhs = rhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); + let rhs = rhs.clone().with_validity(None); let out = compare_op(&lhs, &rhs, |a, b| a != b); finish_neq_validities(out, validity_lhs, validity_rhs) @@ -77,7 +77,7 @@ pub fn eq_scalar(lhs: &Utf8Array, rhs: &str) -> BooleanArray { /// Perform `lhs == rhs` operation on [`Utf8Array`] and a scalar. Also includes null values in comparisson. pub fn eq_scalar_and_validity(lhs: &Utf8Array, rhs: &str) -> BooleanArray { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = compare_op_scalar(&lhs, rhs, |a, b| a == b); finish_eq_validities(out, validity, None) @@ -86,7 +86,7 @@ pub fn eq_scalar_and_validity(lhs: &Utf8Array, rhs: &str) -> Boole /// Perform `lhs != rhs` operation on [`Utf8Array`] and a scalar. Also includes null values in comparisson. pub fn neq_scalar_and_validity(lhs: &Utf8Array, rhs: &str) -> BooleanArray { let validity = lhs.validity().cloned(); - let lhs = lhs.with_validity(None); + let lhs = lhs.clone().with_validity(None); let out = compare_op_scalar(&lhs, rhs, |a, b| a != b); finish_neq_validities(out, validity, None) diff --git a/tests/it/compute/comparison.rs b/tests/it/compute/comparison.rs index 9934781dd8f..09f3fd61458 100644 --- a/tests/it/compute/comparison.rs +++ b/tests/it/compute/comparison.rs @@ -265,7 +265,7 @@ fn compare_no_propagating_nulls_eq() { // now mask with a null let mask = Bitmap::from_iter([false, true, true]); - let a_masked = a.with_validity(Some(mask)); + let a_masked = a.clone().with_validity(Some(mask)); let out = comparison::utf8::eq_and_validity(&a, &a_masked); check_mask(&out, &[false, true, true]); @@ -306,7 +306,7 @@ fn compare_no_propagating_nulls_neq() { // now mask with a null let mask = Bitmap::from_iter([false, true, true]); - let a_masked = a.with_validity(Some(mask)); + let a_masked = a.clone().with_validity(Some(mask)); let out = comparison::utf8::neq_and_validity(&a, &a_masked); check_mask(&out, &[true, false, false]);