@@ -27,18 +27,18 @@ use crate::array::*;
27
27
use crate :: buffer:: { buffer_unary_not, Buffer , MutableBuffer } ;
28
28
use crate :: compute:: util:: combine_option_bitmap;
29
29
use crate :: datatypes:: {
30
- ArrowNativeType , ArrowNumericType , DataType , Date32Type , Date64Type , Float32Type ,
31
- Float64Type , Int16Type , Int32Type , Int64Type , Int8Type , IntervalDayTimeType ,
32
- IntervalMonthDayNanoType , IntervalUnit , IntervalYearMonthType , Time32MillisecondType ,
33
- Time32SecondType , Time64MicrosecondType , Time64NanosecondType , TimeUnit ,
34
- TimestampMicrosecondType , TimestampMillisecondType , TimestampNanosecondType ,
35
- TimestampSecondType , UInt16Type , UInt32Type , UInt64Type , UInt8Type ,
30
+ native_op:: ArrowNativeTypeOp , ArrowNativeType , ArrowNumericType , DataType ,
31
+ Date32Type , Date64Type , Float32Type , Float64Type , Int16Type , Int32Type , Int64Type ,
32
+ Int8Type , IntervalDayTimeType , IntervalMonthDayNanoType , IntervalUnit ,
33
+ IntervalYearMonthType , Time32MillisecondType , Time32SecondType ,
34
+ Time64MicrosecondType , Time64NanosecondType , TimeUnit , TimestampMicrosecondType ,
35
+ TimestampMillisecondType , TimestampNanosecondType , TimestampSecondType , UInt16Type ,
36
+ UInt32Type , UInt64Type , UInt8Type ,
36
37
} ;
37
38
#[ allow( unused_imports) ]
38
39
use crate :: downcast_dictionary_array;
39
40
use crate :: error:: { ArrowError , Result } ;
40
41
use crate :: util:: bit_util;
41
- use num:: ToPrimitive ;
42
42
use regex:: Regex ;
43
43
use std:: collections:: HashMap ;
44
44
@@ -1336,7 +1336,7 @@ macro_rules! dyn_compare_utf8_scalar {
1336
1336
/// Please refer to `f32::total_cmp` and `f64::total_cmp`.
1337
1337
pub fn eq_dyn_scalar < T > ( left : & dyn Array , right : T ) -> Result < BooleanArray >
1338
1338
where
1339
- T : num :: ToPrimitive + std :: fmt :: Debug ,
1339
+ T : ArrowNativeTypeOp ,
1340
1340
{
1341
1341
match left. data_type ( ) {
1342
1342
DataType :: Dictionary ( key_type, _value_type) => {
@@ -3048,24 +3048,12 @@ where
3048
3048
pub fn eq_scalar < T > ( left : & PrimitiveArray < T > , right : T :: Native ) -> Result < BooleanArray >
3049
3049
where
3050
3050
T : ArrowNumericType ,
3051
- T :: Native : num :: ToPrimitive + std :: fmt :: Debug ,
3051
+ T :: Native : ArrowNativeTypeOp ,
3052
3052
{
3053
3053
#[ cfg( feature = "simd" ) ]
3054
3054
return simd_compare_op_scalar ( left, right, T :: eq, |a, b| a == b) ;
3055
3055
#[ cfg( not( feature = "simd" ) ) ]
3056
- match left. data_type ( ) {
3057
- DataType :: Float32 => {
3058
- let left = as_primitive_array :: < Float32Type > ( left) ;
3059
- let right = try_to_type ! ( right, to_f32) ?;
3060
- compare_op_scalar ( left, |a : f32 | a. total_cmp ( & right) . is_eq ( ) )
3061
- }
3062
- DataType :: Float64 => {
3063
- let left = as_primitive_array :: < Float64Type > ( left) ;
3064
- let right = try_to_type ! ( right, to_f64) ?;
3065
- compare_op_scalar ( left, |a : f64 | a. total_cmp ( & right) . is_eq ( ) )
3066
- }
3067
- _ => compare_op_scalar ( left, |a| a == right) ,
3068
- }
3056
+ return compare_op_scalar ( left, |a| a. is_eq ( right) ) ;
3069
3057
}
3070
3058
3071
3059
/// Applies an unary and infallible comparison function to a primitive array.
@@ -3096,24 +3084,12 @@ where
3096
3084
pub fn neq_scalar < T > ( left : & PrimitiveArray < T > , right : T :: Native ) -> Result < BooleanArray >
3097
3085
where
3098
3086
T : ArrowNumericType ,
3099
- T :: Native : num :: ToPrimitive + std :: fmt :: Debug ,
3087
+ T :: Native : ArrowNativeTypeOp ,
3100
3088
{
3101
3089
#[ cfg( feature = "simd" ) ]
3102
3090
return simd_compare_op_scalar ( left, right, T :: ne, |a, b| a != b) ;
3103
3091
#[ cfg( not( feature = "simd" ) ) ]
3104
- match left. data_type ( ) {
3105
- DataType :: Float32 => {
3106
- let left = as_primitive_array :: < Float32Type > ( left) ;
3107
- let right = try_to_type ! ( right, to_f32) ?;
3108
- compare_op_scalar ( left, |a : f32 | a. total_cmp ( & right) . is_ne ( ) )
3109
- }
3110
- DataType :: Float64 => {
3111
- let left = as_primitive_array :: < Float64Type > ( left) ;
3112
- let right = try_to_type ! ( right, to_f64) ?;
3113
- compare_op_scalar ( left, |a : f64 | a. total_cmp ( & right) . is_ne ( ) )
3114
- }
3115
- _ => compare_op_scalar ( left, |a| a != right) ,
3116
- }
3092
+ return compare_op_scalar ( left, |a| a. is_ne ( right) ) ;
3117
3093
}
3118
3094
3119
3095
/// Perform `left < right` operation on two [`PrimitiveArray`]s. Null values are less than non-null
@@ -3137,24 +3113,12 @@ where
3137
3113
pub fn lt_scalar < T > ( left : & PrimitiveArray < T > , right : T :: Native ) -> Result < BooleanArray >
3138
3114
where
3139
3115
T : ArrowNumericType ,
3140
- T :: Native : num :: ToPrimitive + std :: fmt :: Debug ,
3116
+ T :: Native : ArrowNativeTypeOp ,
3141
3117
{
3142
3118
#[ cfg( feature = "simd" ) ]
3143
3119
return simd_compare_op_scalar ( left, right, T :: lt, |a, b| a < b) ;
3144
3120
#[ cfg( not( feature = "simd" ) ) ]
3145
- match left. data_type ( ) {
3146
- DataType :: Float32 => {
3147
- let left = as_primitive_array :: < Float32Type > ( left) ;
3148
- let right = try_to_type ! ( right, to_f32) ?;
3149
- compare_op_scalar ( left, |a : f32 | a. total_cmp ( & right) . is_lt ( ) )
3150
- }
3151
- DataType :: Float64 => {
3152
- let left = as_primitive_array :: < Float64Type > ( left) ;
3153
- let right = try_to_type ! ( right, to_f64) ?;
3154
- compare_op_scalar ( left, |a : f64 | a. total_cmp ( & right) . is_lt ( ) )
3155
- }
3156
- _ => compare_op_scalar ( left, |a| a < right) ,
3157
- }
3121
+ return compare_op_scalar ( left, |a| a. is_lt ( right) ) ;
3158
3122
}
3159
3123
3160
3124
/// Perform `left <= right` operation on two [`PrimitiveArray`]s. Null values are less than non-null
@@ -3181,24 +3145,12 @@ where
3181
3145
pub fn lt_eq_scalar < T > ( left : & PrimitiveArray < T > , right : T :: Native ) -> Result < BooleanArray >
3182
3146
where
3183
3147
T : ArrowNumericType ,
3184
- T :: Native : num :: ToPrimitive + std :: fmt :: Debug ,
3148
+ T :: Native : ArrowNativeTypeOp ,
3185
3149
{
3186
3150
#[ cfg( feature = "simd" ) ]
3187
3151
return simd_compare_op_scalar ( left, right, T :: le, |a, b| a <= b) ;
3188
3152
#[ cfg( not( feature = "simd" ) ) ]
3189
- match left. data_type ( ) {
3190
- DataType :: Float32 => {
3191
- let left = as_primitive_array :: < Float32Type > ( left) ;
3192
- let right = try_to_type ! ( right, to_f32) ?;
3193
- compare_op_scalar ( left, |a : f32 | a. total_cmp ( & right) . is_le ( ) )
3194
- }
3195
- DataType :: Float64 => {
3196
- let left = as_primitive_array :: < Float64Type > ( left) ;
3197
- let right = try_to_type ! ( right, to_f64) ?;
3198
- compare_op_scalar ( left, |a : f64 | a. total_cmp ( & right) . is_le ( ) )
3199
- }
3200
- _ => compare_op_scalar ( left, |a| a <= right) ,
3201
- }
3153
+ return compare_op_scalar ( left, |a| a. is_le ( right) ) ;
3202
3154
}
3203
3155
3204
3156
/// Perform `left > right` operation on two [`PrimitiveArray`]s. Non-null values are greater than null
@@ -3222,24 +3174,12 @@ where
3222
3174
pub fn gt_scalar < T > ( left : & PrimitiveArray < T > , right : T :: Native ) -> Result < BooleanArray >
3223
3175
where
3224
3176
T : ArrowNumericType ,
3225
- T :: Native : num :: ToPrimitive + std :: fmt :: Debug ,
3177
+ T :: Native : ArrowNativeTypeOp ,
3226
3178
{
3227
3179
#[ cfg( feature = "simd" ) ]
3228
3180
return simd_compare_op_scalar ( left, right, T :: gt, |a, b| a > b) ;
3229
3181
#[ cfg( not( feature = "simd" ) ) ]
3230
- match left. data_type ( ) {
3231
- DataType :: Float32 => {
3232
- let left = as_primitive_array :: < Float32Type > ( left) ;
3233
- let right = try_to_type ! ( right, to_f32) ?;
3234
- compare_op_scalar ( left, |a : f32 | a. total_cmp ( & right) . is_gt ( ) )
3235
- }
3236
- DataType :: Float64 => {
3237
- let left = as_primitive_array :: < Float64Type > ( left) ;
3238
- let right = try_to_type ! ( right, to_f64) ?;
3239
- compare_op_scalar ( left, |a : f64 | a. total_cmp ( & right) . is_gt ( ) )
3240
- }
3241
- _ => compare_op_scalar ( left, |a| a > right) ,
3242
- }
3182
+ return compare_op_scalar ( left, |a| a. is_gt ( right) ) ;
3243
3183
}
3244
3184
3245
3185
/// Perform `left >= right` operation on two [`PrimitiveArray`]s. Non-null values are greater than null
@@ -3266,24 +3206,12 @@ where
3266
3206
pub fn gt_eq_scalar < T > ( left : & PrimitiveArray < T > , right : T :: Native ) -> Result < BooleanArray >
3267
3207
where
3268
3208
T : ArrowNumericType ,
3269
- T :: Native : num :: ToPrimitive + std :: fmt :: Debug ,
3209
+ T :: Native : ArrowNativeTypeOp ,
3270
3210
{
3271
3211
#[ cfg( feature = "simd" ) ]
3272
3212
return simd_compare_op_scalar ( left, right, T :: ge, |a, b| a >= b) ;
3273
3213
#[ cfg( not( feature = "simd" ) ) ]
3274
- match left. data_type ( ) {
3275
- DataType :: Float32 => {
3276
- let left = as_primitive_array :: < Float32Type > ( left) ;
3277
- let right = try_to_type ! ( right, to_f32) ?;
3278
- compare_op_scalar ( left, |a : f32 | a. total_cmp ( & right) . is_ge ( ) )
3279
- }
3280
- DataType :: Float64 => {
3281
- let left = as_primitive_array :: < Float64Type > ( left) ;
3282
- let right = try_to_type ! ( right, to_f64) ?;
3283
- compare_op_scalar ( left, |a : f64 | a. total_cmp ( & right) . is_ge ( ) )
3284
- }
3285
- _ => compare_op_scalar ( left, |a| a >= right) ,
3286
- }
3214
+ return compare_op_scalar ( left, |a| a. is_ge ( right) ) ;
3287
3215
}
3288
3216
3289
3217
/// Checks if a [`GenericListArray`] contains a value in the [`PrimitiveArray`]
0 commit comments