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

vortex-data / vortex / 16324698785

16 Jul 2025 04:12PM UTC coverage: 80.702% (-0.9%) from 81.557%
16324698785

Pull #3881

github

web-flow
Merge afc822f8d into ced09d9a8
Pull Request #3881: feat: build with stable rust

119 of 172 new or added lines in 28 files covered. (69.19%)

174 existing lines in 102 files now uncovered.

41861 of 51871 relevant lines covered (80.7%)

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

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

78
        Ok(layout.into_layout())
21,136✔
79
    }
21,136✔
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