Skip to content

Commit

Permalink
Remove deprecated comparison kernels (#4733) (#5768)
Browse files Browse the repository at this point in the history
* Remove deprecated comparison kernels (#4733)

* Fix docs

* Fix doctest

* Update arrow/src/lib.rs

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>

---------

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
  • Loading branch information
tustvold and alamb authored May 15, 2024
1 parent d17b206 commit 30767a6
Show file tree
Hide file tree
Showing 5 changed files with 591 additions and 2,020 deletions.
11 changes: 10 additions & 1 deletion arrow-array/src/array/dictionary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ use crate::cast::AsArray;
use crate::iterator::ArrayIter;
use crate::types::*;
use crate::{
make_array, Array, ArrayAccessor, ArrayRef, ArrowNativeTypeOp, PrimitiveArray, StringArray,
make_array, Array, ArrayAccessor, ArrayRef, ArrowNativeTypeOp, PrimitiveArray, Scalar,
StringArray,
};
use arrow_buffer::bit_util::set_bit;
use arrow_buffer::buffer::NullBuffer;
Expand Down Expand Up @@ -312,6 +313,14 @@ impl<K: ArrowDictionaryKeyType> DictionaryArray<K> {
})
}

/// Create a new [`Scalar`] from `value`
pub fn new_scalar<T: Array + 'static>(value: Scalar<T>) -> Scalar<Self> {
Scalar::new(Self::new(
PrimitiveArray::new(vec![K::Native::usize_as(0)].into(), None),
Arc::new(value.into_inner()),
))
}

/// Create a new [`DictionaryArray`] without performing validation
///
/// # Safety
Expand Down
14 changes: 13 additions & 1 deletion arrow-array/src/array/fixed_size_binary_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use crate::array::print_long_array;
use crate::iterator::FixedSizeBinaryIter;
use crate::{Array, ArrayAccessor, ArrayRef, FixedSizeListArray};
use crate::{Array, ArrayAccessor, ArrayRef, FixedSizeListArray, Scalar};
use arrow_buffer::buffer::NullBuffer;
use arrow_buffer::{bit_util, ArrowNativeType, BooleanBuffer, Buffer, MutableBuffer};
use arrow_data::{ArrayData, ArrayDataBuilder};
Expand Down Expand Up @@ -68,6 +68,12 @@ impl FixedSizeBinaryArray {
Self::try_new(size, values, nulls).unwrap()
}

/// Create a new [`Scalar`] from `value`
pub fn new_scalar(value: impl AsRef<[u8]>) -> Scalar<Self> {
let v = value.as_ref();
Scalar::new(Self::new(v.len() as _, Buffer::from(v), None))
}

/// Create a new [`FixedSizeBinaryArray`] from the provided parts, returning an error on failure
///
/// # Errors
Expand Down Expand Up @@ -551,6 +557,12 @@ impl From<Vec<&[u8]>> for FixedSizeBinaryArray {
}
}

impl<const N: usize> From<Vec<&[u8; N]>> for FixedSizeBinaryArray {
fn from(v: Vec<&[u8; N]>) -> Self {
Self::try_from_iter(v.into_iter()).unwrap()
}
}

impl std::fmt::Debug for FixedSizeBinaryArray {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "FixedSizeBinaryArray<{}>\n[\n", self.value_length())?;
Expand Down
6 changes: 6 additions & 0 deletions arrow-array/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ impl<T: Array> Scalar<T> {
assert_eq!(array.len(), 1);
Self(array)
}

/// Returns the inner array
#[inline]
pub fn into_inner(self) -> T {
self.0
}
}

impl<T: Array> Datum for Scalar<T> {
Expand Down
Loading

0 comments on commit 30767a6

Please sign in to comment.