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

vortex-data / vortex / 16448958948

22 Jul 2025 03:37PM UTC coverage: 81.011% (-0.1%) from 81.109%
16448958948

Pull #3876

github

web-flow
Merge b0e97510f into db33b9fe9
Pull Request #3876: feat[layout]: replace register_splits with a layout splits stream

466 of 572 new or added lines in 17 files covered. (81.47%)

48 existing lines in 4 files now uncovered.

42258 of 52163 relevant lines covered (81.01%)

169401.59 hits per line

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

55.88
/vortex-array/src/stats/stat_bound.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::cmp::Ordering;
5

6
use crate::partial_ord::partial_min;
7
use crate::stats::bound::IntersectionResult;
8
use crate::stats::{Precision, Stat};
9

10
/// `StatType` define the bound of a given statistic. (e.g. `Max` is an upper bound),
11
/// this is used to extract the bound from a `Precision` value, (e.g. `p::bound<Max>()`).
12
pub trait StatType<T> {
13
    type Bound: StatBound<T>;
14

15
    const STAT: Stat;
16
}
17

18
/// `StatBound` defines the operations that can be performed on a bound.
19
/// The main bounds are Upper (e.g. max) and Lower (e.g. min).
20
pub trait StatBound<T>: Sized {
21
    /// Creates a new bound from a Precision statistic.
22
    fn lift(value: Precision<T>) -> Self;
23

24
    /// Converts `Self` back to `Precision<T>`, inverse of `lift`.
25
    fn into_value(self) -> Precision<T>;
26

27
    /// Finds the smallest bound that covers both bounds.
28
    /// A.k.a. the `meet` of the bound.
29
    fn union(&self, other: &Self) -> Option<Self>;
30

31
    /// Refines the bounds to the most precise estimate we can make for that bound.
32
    /// If the bounds are disjoint, then the result is `None`.
33
    /// e.g. `Precision::Inexact(5)` and `Precision::Exact(6)` would result in `Precision::Inexact(5)`.
34
    /// A.k.a. the `join` of the bound.
35
    fn intersection(&self, other: &Self) -> Option<IntersectionResult<Self>>;
36

37
    /// Returns the exact value from the bound if that value is exact, otherwise `None`.
38
    fn to_exact(&self) -> Option<&T>;
39
}
40

41
/// This allows a stat with a `Precision` to be interpreted as a bound.
42
impl<T> Precision<T> {
43
    /// Applied the stat associated bound to the precision value
44
    pub fn bound<S: StatType<T>>(self) -> S::Bound {
96,607✔
45
        S::Bound::lift(self)
96,607✔
46
    }
96,607✔
47
}
48

49
impl<T: PartialOrd + Clone> StatBound<T> for Precision<T> {
50
    fn lift(value: Precision<T>) -> Self {
2,034✔
51
        value
2,034✔
52
    }
2,034✔
53

54
    fn into_value(self) -> Precision<T> {
2,022✔
55
        self
2,022✔
56
    }
2,022✔
57

58
    fn union(&self, other: &Self) -> Option<Self> {
×
59
        self.clone()
×
60
            .zip(other.clone())
×
61
            .map(|(lhs, rhs)| partial_min(&lhs, &rhs).cloned())
×
62
            .transpose()
×
63
    }
×
64

65
    fn intersection(&self, other: &Self) -> Option<IntersectionResult<Self>> {
4✔
66
        Some(match (self, other) {
4✔
67
            (Precision::Exact(lhs), Precision::Exact(rhs)) => {
2✔
68
                if lhs.partial_cmp(rhs)? == Ordering::Equal {
2✔
69
                    IntersectionResult::Value(Precision::Exact(lhs.clone()))
1✔
70
                } else {
71
                    IntersectionResult::None
1✔
72
                }
73
            }
74
            (Precision::Exact(exact), Precision::Inexact(inexact))
2✔
75
            | (Precision::Inexact(inexact), Precision::Exact(exact)) => {
×
76
                if exact.partial_cmp(inexact)? == Ordering::Less {
2✔
77
                    IntersectionResult::Value(Precision::Inexact(exact.clone()))
×
78
                } else {
79
                    IntersectionResult::Value(Precision::Exact(exact.clone()))
2✔
80
                }
81
            }
82
            (Precision::Inexact(lhs), Precision::Inexact(rhs)) => {
×
83
                IntersectionResult::Value(Precision::Inexact(partial_min(lhs, rhs)?.clone()))
×
84
            }
85
        })
86
    }
4✔
87

UNCOV
88
    fn to_exact(&self) -> Option<&T> {
×
UNCOV
89
        match self {
×
UNCOV
90
            Precision::Exact(val) => Some(val),
×
91
            _ => None,
×
92
        }
UNCOV
93
    }
×
94
}
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