• 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

94.87
/vortex-scan/src/selection_intersection.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use crate::Selection;
5
use crate::row_mask::RowMask;
6
use std::ops::{BitAnd, Range};
7
use vortex_error::{VortexExpect, VortexResult};
8
use vortex_layout::masks::BoxMaskIterator;
9

10
/// Given an iterator of masks a range and a selection, returns row masks that intersect the range
11
/// and satisfy the selection
12
pub struct SelectionIntersectionMaskIterator {
13
    iterators: BoxMaskIterator,
14
    offset: u64,
15
    selection: Selection,
16
    range: Range<u64>,
17
}
18

19
impl SelectionIntersectionMaskIterator {
20
    pub fn new(iterators: BoxMaskIterator, selection: Selection) -> Self {
1,392✔
21
        Self {
1,392✔
22
            iterators,
1,392✔
23
            selection,
1,392✔
24
            offset: 0,
1,392✔
25
            range: 0..u64::MAX,
1,392✔
26
        }
1,392✔
27
    }
1,392✔
28

29
    pub fn with_range(&mut self, range: Range<u64>) {
352✔
30
        self.range = range;
352✔
31
    }
352✔
32
}
33

34
impl Iterator for SelectionIntersectionMaskIterator {
35
    type Item = VortexResult<RowMask>;
36

37
    fn next(&mut self) -> Option<Self::Item> {
3,584✔
38
        loop {
39
            let mask = match self.iterators.next() {
4,470✔
40
                None => return None,
1,392✔
NEW
41
                Some(Err(e)) => return Some(Err(e)),
×
42
                Some(Ok(mask)) => mask,
3,078✔
43
            };
44

45
            let mask_start = self.offset;
3,078✔
46
            let mask_end = self.offset + mask.len() as u64;
3,078✔
47
            self.offset = mask_end;
3,078✔
48

49
            // Check if mask is completely outside range
50
            if mask_end <= self.range.start || mask_start >= self.range.end {
3,078✔
51
                continue;
886✔
52
            }
2,192✔
53

54
            let overlap_start = mask_start.max(self.range.start);
2,192✔
55
            let overlap_end = mask_end.min(self.range.end);
2,192✔
56

57
            // If mask is partially outside range, slice it
58
            let (sliced_mask, slice_offset) =
2,192✔
59
                if overlap_start > mask_start || overlap_end < mask_end {
2,192✔
60
                    // Both local_start and length will fit into usize, since they are smaller than
61
                    // a `mask.len()`
62
                    let local_start = usize::try_from(overlap_start - mask_start)
596✔
63
                        .vortex_expect("must will fit into usize");
596✔
64
                    let length = usize::try_from(overlap_end - overlap_start)
596✔
65
                        .vortex_expect("must will fit into usize");
596✔
66
                    (mask.slice(local_start, length), overlap_start)
596✔
67
                } else {
68
                    (mask, mask_start)
1,596✔
69
                };
70

71
            // Fast path for all-false masks
72
            if sliced_mask.all_false() {
2,192✔
NEW
73
                return Some(Ok(RowMask::new(slice_offset, sliced_mask)));
×
74
            }
2,192✔
75

76
            // Apply selection mask to the effective range
77
            let selection_mask = self.selection.mask(slice_offset, sliced_mask.len());
2,192✔
78
            let final_mask = selection_mask.bitand(&sliced_mask);
2,192✔
79

80
            return Some(Ok(RowMask::new(slice_offset, final_mask)));
2,192✔
81
        }
82
    }
3,584✔
83
}
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

© 2025 Coveralls, Inc