Skip to content

Commit 30767a6

Browse files
tustvoldalamb
andauthored
Remove deprecated comparison kernels (#4733) (#5768)
* Remove deprecated comparison kernels (#4733) * Fix docs * Fix doctest * Update arrow/src/lib.rs Co-authored-by: Andrew Lamb <[email protected]> --------- Co-authored-by: Andrew Lamb <[email protected]>
1 parent d17b206 commit 30767a6

File tree

5 files changed

+591
-2020
lines changed

5 files changed

+591
-2020
lines changed

arrow-array/src/array/dictionary_array.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ use crate::cast::AsArray;
2020
use crate::iterator::ArrayIter;
2121
use crate::types::*;
2222
use crate::{
23-
make_array, Array, ArrayAccessor, ArrayRef, ArrowNativeTypeOp, PrimitiveArray, StringArray,
23+
make_array, Array, ArrayAccessor, ArrayRef, ArrowNativeTypeOp, PrimitiveArray, Scalar,
24+
StringArray,
2425
};
2526
use arrow_buffer::bit_util::set_bit;
2627
use arrow_buffer::buffer::NullBuffer;
@@ -312,6 +313,14 @@ impl<K: ArrowDictionaryKeyType> DictionaryArray<K> {
312313
})
313314
}
314315

316+
/// Create a new [`Scalar`] from `value`
317+
pub fn new_scalar<T: Array + 'static>(value: Scalar<T>) -> Scalar<Self> {
318+
Scalar::new(Self::new(
319+
PrimitiveArray::new(vec![K::Native::usize_as(0)].into(), None),
320+
Arc::new(value.into_inner()),
321+
))
322+
}
323+
315324
/// Create a new [`DictionaryArray`] without performing validation
316325
///
317326
/// # Safety

arrow-array/src/array/fixed_size_binary_array.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
use crate::array::print_long_array;
1919
use crate::iterator::FixedSizeBinaryIter;
20-
use crate::{Array, ArrayAccessor, ArrayRef, FixedSizeListArray};
20+
use crate::{Array, ArrayAccessor, ArrayRef, FixedSizeListArray, Scalar};
2121
use arrow_buffer::buffer::NullBuffer;
2222
use arrow_buffer::{bit_util, ArrowNativeType, BooleanBuffer, Buffer, MutableBuffer};
2323
use arrow_data::{ArrayData, ArrayDataBuilder};
@@ -68,6 +68,12 @@ impl FixedSizeBinaryArray {
6868
Self::try_new(size, values, nulls).unwrap()
6969
}
7070

71+
/// Create a new [`Scalar`] from `value`
72+
pub fn new_scalar(value: impl AsRef<[u8]>) -> Scalar<Self> {
73+
let v = value.as_ref();
74+
Scalar::new(Self::new(v.len() as _, Buffer::from(v), None))
75+
}
76+
7177
/// Create a new [`FixedSizeBinaryArray`] from the provided parts, returning an error on failure
7278
///
7379
/// # Errors
@@ -551,6 +557,12 @@ impl From<Vec<&[u8]>> for FixedSizeBinaryArray {
551557
}
552558
}
553559

560+
impl<const N: usize> From<Vec<&[u8; N]>> for FixedSizeBinaryArray {
561+
fn from(v: Vec<&[u8; N]>) -> Self {
562+
Self::try_from_iter(v.into_iter()).unwrap()
563+
}
564+
}
565+
554566
impl std::fmt::Debug for FixedSizeBinaryArray {
555567
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
556568
write!(f, "FixedSizeBinaryArray<{}>\n[\n", self.value_length())?;

arrow-array/src/scalar.rs

+6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ impl<T: Array> Scalar<T> {
137137
assert_eq!(array.len(), 1);
138138
Self(array)
139139
}
140+
141+
/// Returns the inner array
142+
#[inline]
143+
pub fn into_inner(self) -> T {
144+
self.0
145+
}
140146
}
141147

142148
impl<T: Array> Datum for Scalar<T> {

0 commit comments

Comments
 (0)