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

vortex-data / vortex / 16728097825

04 Aug 2025 04:00PM UTC coverage: 48.355% (-35.1%) from 83.429%
16728097825

Pull #4108

github

web-flow
Merge 1b2d27fd8 into 649ba9576
Pull Request #4108: perf[vortex-array]: use all_valid instead of `invalid_count() == 0`

1 of 1 new or added line in 1 file covered. (100.0%)

11596 existing lines in 378 files now uncovered.

18635 of 38538 relevant lines covered (48.35%)

151786.4 hits per line

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

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

4
use flatbuffers::{FlatBufferBuilder, Follow, WIPOffset};
5
use vortex_error::{VortexError, vortex_bail};
6
use vortex_flatbuffers::{ReadFlatBuffer, WriteFlatBuffer, array as fba};
7
use vortex_scalar::ScalarValue;
8

9
use super::traits::{StatsProvider, StatsProviderExt};
10
use crate::stats::{Precision, Stat, StatsSet};
11

12
impl WriteFlatBuffer for StatsSet {
13
    type Target<'t> = fba::ArrayStats<'t>;
14

15
    /// All statistics written must be exact
16
    fn write_flatbuffer<'fb>(
3,092✔
17
        &self,
3,092✔
18
        fbb: &mut FlatBufferBuilder<'fb>,
3,092✔
19
    ) -> WIPOffset<Self::Target<'fb>> {
3,092✔
20
        let (min_precision, min) = self
3,092✔
21
            .get(Stat::Min)
3,092✔
22
            .map(|sum| {
3,092✔
23
                (
24
                    if sum.is_exact() {
490✔
25
                        fba::Precision::Exact
490✔
26
                    } else {
UNCOV
27
                        fba::Precision::Inexact
×
28
                    },
29
                    Some(fbb.create_vector(&sum.into_inner().to_protobytes::<Vec<u8>>())),
490✔
30
                )
31
            })
490✔
32
            .unwrap_or_else(|| (fba::Precision::Inexact, None));
3,092✔
33

34
        let (max_precision, max) = self
3,092✔
35
            .get(Stat::Max)
3,092✔
36
            .map(|sum| {
3,092✔
37
                (
38
                    if sum.is_exact() {
490✔
39
                        fba::Precision::Exact
488✔
40
                    } else {
41
                        fba::Precision::Inexact
2✔
42
                    },
43
                    Some(fbb.create_vector(&sum.into_inner().to_protobytes::<Vec<u8>>())),
490✔
44
                )
45
            })
490✔
46
            .unwrap_or_else(|| (fba::Precision::Inexact, None));
3,092✔
47

48
        let sum = self
3,092✔
49
            .get(Stat::Sum)
3,092✔
50
            .and_then(Precision::as_exact)
3,092✔
51
            .map(|sum| fbb.create_vector(&sum.to_protobytes::<Vec<u8>>()));
3,092✔
52

53
        let stat_args = &fba::ArrayStatsArgs {
3,092✔
54
            min,
3,092✔
55
            min_precision,
3,092✔
56
            max,
3,092✔
57
            max_precision,
3,092✔
58
            sum,
3,092✔
59
            is_sorted: self
3,092✔
60
                .get_as::<bool>(Stat::IsSorted)
3,092✔
61
                .and_then(Precision::as_exact),
3,092✔
62
            is_strict_sorted: self
3,092✔
63
                .get_as::<bool>(Stat::IsStrictSorted)
3,092✔
64
                .and_then(Precision::as_exact),
3,092✔
65
            is_constant: self
3,092✔
66
                .get_as::<bool>(Stat::IsConstant)
3,092✔
67
                .and_then(Precision::as_exact),
3,092✔
68
            null_count: self
3,092✔
69
                .get_as::<u64>(Stat::NullCount)
3,092✔
70
                .and_then(Precision::as_exact),
3,092✔
71
            uncompressed_size_in_bytes: self
3,092✔
72
                .get_as::<u64>(Stat::UncompressedSizeInBytes)
3,092✔
73
                .and_then(Precision::as_exact),
3,092✔
74
            nan_count: self
3,092✔
75
                .get_as::<u64>(Stat::NaNCount)
3,092✔
76
                .and_then(Precision::as_exact),
3,092✔
77
        };
3,092✔
78

79
        fba::ArrayStats::create(fbb, stat_args)
3,092✔
80
    }
3,092✔
81
}
82

83
impl ReadFlatBuffer for StatsSet {
84
    type Source<'a> = fba::ArrayStats<'a>;
85
    type Error = VortexError;
86

87
    fn read_flatbuffer<'buf>(
10,964✔
88
        fb: &<Self::Source<'buf> as Follow<'buf>>::Inner,
10,964✔
89
    ) -> Result<Self, Self::Error> {
10,964✔
90
        let mut stats_set = StatsSet::default();
10,964✔
91

92
        for stat in Stat::all() {
98,676✔
93
            match stat {
98,676✔
94
                Stat::IsConstant => {
95
                    if let Some(is_constant) = fb.is_constant() {
10,964✔
96
                        stats_set.set(Stat::IsConstant, Precision::Exact(is_constant.into()));
1,048✔
97
                    }
9,916✔
98
                }
99
                Stat::IsSorted => {
100
                    if let Some(is_sorted) = fb.is_sorted() {
10,964✔
101
                        stats_set.set(Stat::IsSorted, Precision::Exact(is_sorted.into()));
168✔
102
                    }
10,796✔
103
                }
104
                Stat::IsStrictSorted => {
105
                    if let Some(is_strict_sorted) = fb.is_strict_sorted() {
10,964✔
106
                        stats_set.set(
168✔
107
                            Stat::IsStrictSorted,
168✔
108
                            Precision::Exact(is_strict_sorted.into()),
168✔
109
                        );
168✔
110
                    }
10,796✔
111
                }
112
                Stat::Max => {
113
                    if let Some(max) = fb.max() {
10,964✔
114
                        let value = ScalarValue::from_protobytes(max.bytes())?;
1,558✔
115
                        stats_set.set(
1,558✔
116
                            Stat::Max,
1,558✔
117
                            match fb.max_precision() {
1,558✔
118
                                fba::Precision::Exact => Precision::Exact(value),
1,558✔
UNCOV
119
                                fba::Precision::Inexact => Precision::Inexact(value),
×
120
                                other => vortex_bail!("Corrupted max_precision field: {other:?}"),
×
121
                            },
122
                        );
123
                    }
9,406✔
124
                }
125
                Stat::Min => {
126
                    if let Some(min) = fb.min() {
10,964✔
127
                        let value = ScalarValue::from_protobytes(min.bytes())?;
1,558✔
128
                        stats_set.set(
1,558✔
129
                            Stat::Min,
1,558✔
130
                            match fb.min_precision() {
1,558✔
131
                                fba::Precision::Exact => Precision::Exact(value),
1,558✔
UNCOV
132
                                fba::Precision::Inexact => Precision::Inexact(value),
×
133
                                other => vortex_bail!("Corrupted min_precision field: {other:?}"),
×
134
                            },
135
                        );
136
                    }
9,406✔
137
                }
138
                Stat::NullCount => {
139
                    if let Some(null_count) = fb.null_count() {
10,964✔
140
                        stats_set.set(Stat::NullCount, Precision::Exact(null_count.into()));
1,706✔
141
                    }
9,258✔
142
                }
143
                Stat::UncompressedSizeInBytes => {
144
                    if let Some(uncompressed_size_in_bytes) = fb.uncompressed_size_in_bytes() {
10,964✔
145
                        stats_set.set(
124✔
146
                            Stat::UncompressedSizeInBytes,
124✔
147
                            Precision::Exact(uncompressed_size_in_bytes.into()),
124✔
148
                        );
124✔
149
                    }
10,840✔
150
                }
151
                Stat::Sum => {
152
                    if let Some(sum) = fb.sum() {
10,964✔
153
                        stats_set.set(
124✔
154
                            Stat::Sum,
124✔
155
                            Precision::Exact(ScalarValue::from_protobytes(sum.bytes())?),
124✔
156
                        );
157
                    }
10,840✔
158
                }
159
                Stat::NaNCount => {
160
                    if let Some(nan_count) = fb.nan_count() {
10,964✔
UNCOV
161
                        stats_set.set(
×
UNCOV
162
                            Stat::NaNCount,
×
UNCOV
163
                            Precision::Exact(ScalarValue::from(nan_count)),
×
UNCOV
164
                        );
×
165
                    }
10,964✔
166
                }
167
            }
168
        }
169

170
        Ok(stats_set)
10,964✔
171
    }
10,964✔
172
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc