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

vortex-data / vortex / 16935267080

13 Aug 2025 11:00AM UTC coverage: 24.312% (-63.3%) from 87.658%
16935267080

Pull #4226

github

web-flow
Merge 81b48c7fb into baa6ea202
Pull Request #4226: Support converting TimestampTZ to and from duckdb

0 of 2 new or added lines in 1 file covered. (0.0%)

20666 existing lines in 469 files now uncovered.

8726 of 35892 relevant lines covered (24.31%)

147.74 hits per line

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

0.0
/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
UNCOV
44
    pub fn bound<S: StatType<T>>(self) -> S::Bound {
×
UNCOV
45
        S::Bound::lift(self)
×
UNCOV
46
    }
×
47
}
48

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

UNCOV
54
    fn into_value(self) -> Precision<T> {
×
UNCOV
55
        self
×
UNCOV
56
    }
×
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

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