Skip to content

Commit fb58743

Browse files
alexandreycalexandreyc
andauthored
Remove redundant trait bounds on ArrowNativeTypeOp (#9614)
# Which issue does this PR close? None. # Rationale for this change While reading the codebase I spotted some redundant trait bounds on `ArrowNativeTypeOp`. # What changes are included in this PR? Remove some trait bounds on `ArrowNativeTypeOp`. # Are these changes tested? It compiles so I guess it's enough. # Are there any user-facing changes? Nope. Co-authored-by: alexandreyc <alexandre@crayssac.net>
1 parent 9c6b42e commit fb58743

File tree

5 files changed

+22
-50
lines changed

5 files changed

+22
-50
lines changed

arrow-arith/src/aggregate.rs

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use arrow_array::cast::*;
2121
use arrow_array::iterator::ArrayIter;
2222
use arrow_array::*;
23-
use arrow_buffer::{ArrowNativeType, NullBuffer};
23+
use arrow_buffer::NullBuffer;
2424
use arrow_data::bit_iterator::try_for_each_valid_idx;
2525
use arrow_schema::*;
2626
use std::borrow::BorrowMut;
@@ -541,11 +541,9 @@ pub fn min_string_view(array: &StringViewArray) -> Option<&str> {
541541
///
542542
/// This doesn't detect overflow. Once overflowing, the result will wrap around.
543543
/// For an overflow-checking variant, use [`sum_array_checked`] instead.
544-
pub fn sum_array<T, A: ArrayAccessor<Item = T::Native>>(array: A) -> Option<T::Native>
545-
where
546-
T: ArrowNumericType,
547-
T::Native: ArrowNativeTypeOp,
548-
{
544+
pub fn sum_array<T: ArrowNumericType, A: ArrayAccessor<Item = T::Native>>(
545+
array: A,
546+
) -> Option<T::Native> {
549547
match array.data_type() {
550548
DataType::Dictionary(_, _) => {
551549
let null_count = array.null_count();
@@ -583,13 +581,9 @@ where
583581
/// use [`sum_array`] instead.
584582
/// Additionally returns an `Err` on run-end-encoded arrays with a provided
585583
/// values type parameter that is incorrect.
586-
pub fn sum_array_checked<T, A: ArrayAccessor<Item = T::Native>>(
584+
pub fn sum_array_checked<T: ArrowNumericType, A: ArrayAccessor<Item = T::Native>>(
587585
array: A,
588-
) -> Result<Option<T::Native>, ArrowError>
589-
where
590-
T: ArrowNumericType,
591-
T::Native: ArrowNativeTypeOp,
592-
{
586+
) -> Result<Option<T::Native>, ArrowError> {
593587
match array.data_type() {
594588
DataType::Dictionary(_, _) => {
595589
let null_count = array.null_count();
@@ -717,21 +711,17 @@ mod ree {
717711

718712
/// Returns the min of values in the array of `ArrowNumericType` type, or dictionary
719713
/// array with value of `ArrowNumericType` type.
720-
pub fn min_array<T, A: ArrayAccessor<Item = T::Native>>(array: A) -> Option<T::Native>
721-
where
722-
T: ArrowNumericType,
723-
T::Native: ArrowNativeType,
724-
{
714+
pub fn min_array<T: ArrowNumericType, A: ArrayAccessor<Item = T::Native>>(
715+
array: A,
716+
) -> Option<T::Native> {
725717
min_max_array_helper::<T, A, _, _>(array, |a, b| a.is_gt(*b), min)
726718
}
727719

728720
/// Returns the max of values in the array of `ArrowNumericType` type, or dictionary
729721
/// array with value of `ArrowNumericType` type.
730-
pub fn max_array<T, A: ArrayAccessor<Item = T::Native>>(array: A) -> Option<T::Native>
731-
where
732-
T: ArrowNumericType,
733-
T::Native: ArrowNativeTypeOp,
734-
{
722+
pub fn max_array<T: ArrowNumericType, A: ArrayAccessor<Item = T::Native>>(
723+
array: A,
724+
) -> Option<T::Native> {
735725
min_max_array_helper::<T, A, _, _>(array, |a, b| a.is_lt(*b), max)
736726
}
737727

@@ -874,11 +864,9 @@ pub fn bool_or(array: &BooleanArray) -> Option<bool> {
874864
///
875865
/// This detects overflow and returns an `Err` for that. For an non-overflow-checking variant,
876866
/// use [`sum`] instead.
877-
pub fn sum_checked<T>(array: &PrimitiveArray<T>) -> Result<Option<T::Native>, ArrowError>
878-
where
879-
T: ArrowNumericType,
880-
T::Native: ArrowNativeTypeOp,
881-
{
867+
pub fn sum_checked<T: ArrowNumericType>(
868+
array: &PrimitiveArray<T>,
869+
) -> Result<Option<T::Native>, ArrowError> {
882870
let null_count = array.null_count();
883871

884872
if null_count == array.len() {
@@ -922,10 +910,7 @@ where
922910
///
923911
/// This doesn't detect overflow in release mode by default. Once overflowing, the result will
924912
/// wrap around. For an overflow-checking variant, use [`sum_checked`] instead.
925-
pub fn sum<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native>
926-
where
927-
T::Native: ArrowNativeTypeOp,
928-
{
913+
pub fn sum<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native> {
929914
aggregate::<T::Native, T, SumAccumulator<T::Native>>(array)
930915
}
931916

@@ -940,10 +925,7 @@ where
940925
/// let result = min(&array);
941926
/// assert_eq!(result, Some(2));
942927
/// ```
943-
pub fn min<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native>
944-
where
945-
T::Native: PartialOrd,
946-
{
928+
pub fn min<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native> {
947929
aggregate::<T::Native, T, MinAccumulator<T::Native>>(array)
948930
}
949931

@@ -958,10 +940,7 @@ where
958940
/// let result = max(&array);
959941
/// assert_eq!(result, Some(8));
960942
/// ```
961-
pub fn max<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native>
962-
where
963-
T::Native: PartialOrd,
964-
{
943+
pub fn max<T: ArrowNumericType>(array: &PrimitiveArray<T>) -> Option<T::Native> {
965944
aggregate::<T::Native, T, MaxAccumulator<T::Native>>(array)
966945
}
967946

arrow-arith/src/arithmetic.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,7 @@ pub fn multiply_fixed_point(
170170
}
171171

172172
/// Divide a decimal native value by given divisor and round the result.
173-
fn divide_and_round<I>(input: I::Native, div: I::Native) -> I::Native
174-
where
175-
I: DecimalType,
176-
I::Native: ArrowNativeTypeOp,
177-
{
173+
fn divide_and_round<I: DecimalType>(input: I::Native, div: I::Native) -> I::Native {
178174
let d = input.div_wrapping(div);
179175
let r = input.mod_wrapping(div);
180176

arrow-cast/src/cast/decimal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ where
812812
T: ArrowPrimitiveType,
813813
<T as ArrowPrimitiveType>::Native: NumCast,
814814
D: DecimalType + ArrowPrimitiveType,
815-
<D as ArrowPrimitiveType>::Native: ArrowNativeTypeOp + ToPrimitive,
815+
<D as ArrowPrimitiveType>::Native: ToPrimitive,
816816
{
817817
let array = array.as_primitive::<D>();
818818

arrow-cast/src/cast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2298,7 +2298,7 @@ fn cast_from_decimal<D, F>(
22982298
) -> Result<ArrayRef, ArrowError>
22992299
where
23002300
D: DecimalType + ArrowPrimitiveType,
2301-
<D as ArrowPrimitiveType>::Native: ArrowNativeTypeOp + ToPrimitive,
2301+
<D as ArrowPrimitiveType>::Native: ToPrimitive,
23022302
F: Fn(D::Native) -> f64,
23032303
{
23042304
use DataType::*;

arrow-ord/src/ord.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,7 @@ fn compare_primitive<T: ArrowPrimitiveType>(
114114
left: &dyn Array,
115115
right: &dyn Array,
116116
opts: SortOptions,
117-
) -> DynComparator
118-
where
119-
T::Native: ArrowNativeTypeOp,
120-
{
117+
) -> DynComparator {
121118
let left = left.as_primitive::<T>();
122119
let right = right.as_primitive::<T>();
123120
let l_values = left.values().clone();

0 commit comments

Comments
 (0)