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

vortex-data / vortex / 16331938722

16 Jul 2025 10:49PM UTC coverage: 80.702% (-0.9%) from 81.557%
16331938722

push

github

web-flow
feat: build with stable rust (#3881)

120 of 173 new or added lines in 28 files covered. (69.36%)

174 existing lines in 102 files now uncovered.

41861 of 51871 relevant lines covered (80.7%)

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

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

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

© 2025 Coveralls, Inc