• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

vortex-data / vortex / 16331938722

16 Jul 2025 10:49PM UTC coverage: 80.702% (-0.9%) from 81.557%
16331938722

push

github

web-flow
feat: build with stable rust (#3881)

120 of 173 new or added lines in 28 files covered. (69.36%)

174 existing lines in 102 files now uncovered.

41861 of 51871 relevant lines covered (80.7%)

157487.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.43
/vortex-array/src/arrays/primitive/compute/between.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use arrow_buffer::BooleanBuffer;
5
use vortex_dtype::{NativePType, Nullability, match_each_native_ptype};
6
use vortex_error::VortexResult;
7

8
use crate::arrays::{BoolArray, PrimitiveArray, PrimitiveVTable};
9
use crate::compute::{BetweenKernel, BetweenKernelAdapter, BetweenOptions, StrictComparison};
10
use crate::vtable::ValidityHelper;
11
use crate::{Array, ArrayRef, IntoArray, register_kernel};
12

13
impl BetweenKernel for PrimitiveVTable {
14
    fn between(
222✔
15
        &self,
222✔
16
        arr: &PrimitiveArray,
222✔
17
        lower: &dyn Array,
222✔
18
        upper: &dyn Array,
222✔
19
        options: &BetweenOptions,
222✔
20
    ) -> VortexResult<Option<ArrayRef>> {
222✔
21
        let (Some(lower), Some(upper)) = (lower.as_constant(), upper.as_constant()) else {
222✔
22
            return Ok(None);
5✔
23
        };
24

25
        // Note, we know that have checked before that the lower and upper bounds are not constant
26
        // null values
27

28
        let nullability =
217✔
29
            arr.dtype.nullability() | lower.dtype().nullability() | upper.dtype().nullability();
217✔
30

31
        Ok(Some(match_each_native_ptype!(arr.ptype(), |P| {
217✔
UNCOV
32
            between_impl::<P>(
×
33
                arr,
×
34
                P::try_from(lower)?,
×
35
                P::try_from(upper)?,
×
36
                nullability,
×
37
                options,
×
38
            )
39
        })))
40
    }
222✔
41
}
42

43
register_kernel!(BetweenKernelAdapter(PrimitiveVTable).lift());
44

45
fn between_impl<T: NativePType + Copy>(
217✔
46
    arr: &PrimitiveArray,
217✔
47
    lower: T,
217✔
48
    upper: T,
217✔
49
    nullability: Nullability,
217✔
50
    options: &BetweenOptions,
217✔
51
) -> ArrayRef {
217✔
52
    match (options.lower_strict, options.upper_strict) {
217✔
53
        // Note: these comparisons are explicitly passed in to allow function impl inlining
54
        (StrictComparison::Strict, StrictComparison::Strict) => between_impl_(
72✔
55
            arr,
72✔
56
            lower,
72✔
57
            NativePType::is_lt,
72✔
58
            upper,
72✔
59
            NativePType::is_lt,
72✔
60
            nullability,
72✔
61
        ),
72✔
62
        (StrictComparison::Strict, StrictComparison::NonStrict) => between_impl_(
36✔
63
            arr,
36✔
64
            lower,
36✔
65
            NativePType::is_lt,
66
            upper,
36✔
67
            NativePType::is_le,
68
            nullability,
36✔
69
        ),
70
        (StrictComparison::NonStrict, StrictComparison::Strict) => between_impl_(
72✔
71
            arr,
72✔
72
            lower,
72✔
73
            NativePType::is_le,
74
            upper,
72✔
75
            NativePType::is_lt,
76
            nullability,
72✔
77
        ),
78
        (StrictComparison::NonStrict, StrictComparison::NonStrict) => between_impl_(
37✔
79
            arr,
37✔
80
            lower,
37✔
81
            NativePType::is_le,
82
            upper,
37✔
83
            NativePType::is_le,
84
            nullability,
37✔
85
        ),
86
    }
87
}
217✔
88

89
fn between_impl_<T>(
217✔
90
    arr: &PrimitiveArray,
217✔
91
    lower: T,
217✔
92
    lower_fn: impl Fn(T, T) -> bool,
217✔
93
    upper: T,
217✔
94
    upper_fn: impl Fn(T, T) -> bool,
217✔
95
    nullability: Nullability,
217✔
96
) -> ArrayRef
217✔
97
where
217✔
98
    T: NativePType + Copy,
217✔
99
{
100
    let slice = arr.as_slice::<T>();
217✔
101
    BoolArray::new(
217✔
102
        BooleanBuffer::collect_bool(slice.len(), |idx| {
365✔
103
            // We only iterate upto arr len and |arr| == |slice|.
104
            let i = unsafe { *slice.get_unchecked(idx) };
365✔
105
            lower_fn(lower, i) & upper_fn(i, upper)
365✔
106
        }),
365✔
107
        arr.validity().clone().union_nullability(nullability),
217✔
108
    )
109
    .into_array()
217✔
110
}
217✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc