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

vortex-data / vortex / 16350502539

17 Jul 2025 04:22PM UTC coverage: 80.836% (-0.7%) from 81.557%
16350502539

Pull #3876

github

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

645 of 692 new or added lines in 17 files covered. (93.21%)

372 existing lines in 117 files now uncovered.

42316 of 52348 relevant lines covered (80.84%)

141734.87 hits per line

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

56.9
/vortex-layout/src/encoding.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::any::Any;
5
use std::fmt::{Debug, Display, Formatter};
6

7
use arcref::ArcRef;
8
use vortex_array::{ArrayContext, DeserializeMetadata};
9
use vortex_dtype::DType;
10
use vortex_error::{VortexExpect, VortexResult, vortex_panic};
11

12
use crate::segments::SegmentId;
13
use crate::{IntoLayout, LayoutChildren, LayoutRef, VTable};
14

15
pub type LayoutEncodingId = ArcRef<str>;
16
pub type LayoutEncodingRef = ArcRef<dyn LayoutEncoding>;
17

18
pub trait LayoutEncoding: 'static + Send + Sync + Debug + private::Sealed {
19
    fn as_any(&self) -> &dyn Any;
20

21
    fn id(&self) -> LayoutEncodingId;
22

23
    fn build(
24
        &self,
25
        dtype: &DType,
26
        row_count: u64,
27
        metadata: &[u8],
28
        segment_ids: Vec<SegmentId>,
29
        children: &dyn LayoutChildren,
30
        ctx: ArrayContext,
31
    ) -> VortexResult<LayoutRef>;
32
}
33

34
#[repr(transparent)]
35
pub struct LayoutEncodingAdapter<V: VTable>(V::Encoding);
36

37
impl<V: VTable> LayoutEncoding for LayoutEncodingAdapter<V> {
38
    fn as_any(&self) -> &dyn Any {
×
39
        self
×
40
    }
×
41

42
    fn id(&self) -> LayoutEncodingId {
30,386✔
43
        V::id(&self.0)
30,386✔
44
    }
30,386✔
45

46
    fn build(
9,958✔
47
        &self,
9,958✔
48
        dtype: &DType,
9,958✔
49
        row_count: u64,
9,958✔
50
        metadata: &[u8],
9,958✔
51
        segment_ids: Vec<SegmentId>,
9,958✔
52
        children: &dyn LayoutChildren,
9,958✔
53
        ctx: ArrayContext,
9,958✔
54
    ) -> VortexResult<LayoutRef> {
9,958✔
55
        let metadata = <V::Metadata as DeserializeMetadata>::deserialize(metadata)?;
9,958✔
56
        let layout = V::build(
9,958✔
57
            &self.0,
9,958✔
58
            dtype,
9,958✔
59
            row_count,
9,958✔
60
            &metadata,
9,958✔
61
            segment_ids,
9,958✔
62
            children,
9,958✔
63
            ctx,
9,958✔
UNCOV
64
        )?;
×
65

66
        // Validate that the builder function returned the expected values.
67
        if layout.row_count() != row_count {
9,958✔
68
            vortex_panic!(
×
69
                "Layout row count mismatch: {} != {}",
×
70
                layout.row_count(),
×
71
                row_count
72
            );
73
        }
9,958✔
74
        if layout.dtype() != dtype {
9,958✔
75
            vortex_panic!("Layout dtype mismatch: {} != {}", layout.dtype(), dtype);
×
76
        }
9,958✔
77

78
        Ok(layout.into_layout())
9,958✔
79
    }
9,958✔
80
}
81

82
impl<V: VTable> Debug for LayoutEncodingAdapter<V> {
83
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
×
84
        f.debug_struct("LayoutEncoding")
×
85
            .field("id", &self.id())
×
86
            .finish()
×
87
    }
×
88
}
89

90
impl Display for dyn LayoutEncoding + '_ {
91
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
7,990✔
92
        write!(f, "{}", self.id())
7,990✔
93
    }
7,990✔
94
}
95

96
impl PartialEq for dyn LayoutEncoding + '_ {
97
    fn eq(&self, other: &Self) -> bool {
10,074✔
98
        self.id() == other.id()
10,074✔
99
    }
10,074✔
100
}
101

102
impl Eq for dyn LayoutEncoding + '_ {}
103

104
impl dyn LayoutEncoding + '_ {
105
    pub fn is<V: VTable>(&self) -> bool {
×
106
        self.as_opt::<V>().is_some()
×
107
    }
×
108

109
    pub fn as_<V: VTable>(&self) -> &V::Encoding {
×
110
        self.as_opt::<V>()
×
111
            .vortex_expect("LayoutEncoding is not of the expected type")
×
112
    }
×
113

114
    pub fn as_opt<V: VTable>(&self) -> Option<&V::Encoding> {
×
115
        self.as_any()
×
116
            .downcast_ref::<LayoutEncodingAdapter<V>>()
×
117
            .map(|e| &e.0)
×
118
    }
×
119
}
120

121
mod private {
122
    use super::*;
123

124
    pub trait Sealed {}
125

126
    impl<V: VTable> Sealed for LayoutEncodingAdapter<V> {}
127
}
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