1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use crate::array::default_arrays::FromData;
use arrow::array::{ArrayRef, BooleanArray, PrimitiveArray};
use arrow::bitmap::Bitmap;
use arrow::types::NativeType;
use num::Float;
use std::sync::Arc;
pub fn is_nan<T>(arr: &PrimitiveArray<T>) -> ArrayRef
where
T: NativeType + Float,
{
let values = Bitmap::from_trusted_len_iter(arr.values().iter().map(|v| v.is_nan()));
Arc::new(BooleanArray::from_data_default(
values,
arr.validity().cloned(),
))
}
pub fn is_not_nan<T>(arr: &PrimitiveArray<T>) -> ArrayRef
where
T: NativeType + Float,
{
let values = Bitmap::from_trusted_len_iter(arr.values().iter().map(|v| !v.is_nan()));
Arc::new(BooleanArray::from_data_default(
values,
arr.validity().cloned(),
))
}
pub fn is_finite<T>(arr: &PrimitiveArray<T>) -> ArrayRef
where
T: NativeType + Float,
{
let values = Bitmap::from_trusted_len_iter(arr.values().iter().map(|v| v.is_finite()));
Arc::new(BooleanArray::from_data_default(
values,
arr.validity().cloned(),
))
}
pub fn is_infinite<T>(arr: &PrimitiveArray<T>) -> ArrayRef
where
T: NativeType + Float,
{
let values = Bitmap::from_trusted_len_iter(arr.values().iter().map(|v| v.is_infinite()));
Arc::new(BooleanArray::from_data_default(
values,
arr.validity().cloned(),
))
}