• 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

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

4
use std::fmt::{Debug, Formatter};
5
use std::ops::Deref;
6

7
use vortex_error::{VortexResult, vortex_bail};
8

9
/// Trait for serializing Vortex metadata to a vector of unaligned bytes.
10
pub trait SerializeMetadata {
11
    fn serialize(self) -> Vec<u8>;
12
}
13

14
/// Trait for deserializing Vortex metadata from a vector of unaligned bytes.
15
pub trait DeserializeMetadata
16
where
17
    Self: Sized,
18
{
19
    /// The fully deserialized type of the metadata.
20
    type Output;
21

22
    /// Deserialize metadata from a vector of unaligned bytes.
23
    fn deserialize(metadata: &[u8]) -> VortexResult<Self::Output>;
24
}
25

26
/// Empty array metadata
27
#[derive(Debug)]
28
pub struct EmptyMetadata;
29

30
impl SerializeMetadata for EmptyMetadata {
31
    fn serialize(self) -> Vec<u8> {
2,516✔
32
        vec![]
2,516✔
33
    }
2,516✔
34
}
35

36
impl DeserializeMetadata for EmptyMetadata {
37
    type Output = EmptyMetadata;
38

39
    fn deserialize(metadata: &[u8]) -> VortexResult<Self::Output> {
19,130✔
40
        if !metadata.is_empty() {
19,130✔
41
            vortex_bail!("EmptyMetadata should not have metadata bytes")
×
42
        }
19,130✔
43
        Ok(EmptyMetadata)
19,130✔
44
    }
19,130✔
45
}
46

47
/// A utility wrapper for raw metadata serialization. This delegates the serialiation step
48
/// to the arrays' vtable.
49
pub struct RawMetadata(pub Vec<u8>);
50

51
impl SerializeMetadata for RawMetadata {
52
    fn serialize(self) -> Vec<u8> {
×
53
        self.0
×
54
    }
×
55
}
56

57
impl DeserializeMetadata for RawMetadata {
58
    type Output = Vec<u8>;
59

60
    fn deserialize(metadata: &[u8]) -> VortexResult<Self::Output> {
×
61
        Ok(metadata.to_vec())
×
62
    }
×
63
}
64

65
impl Debug for RawMetadata {
66
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
×
67
        write!(f, "\"{}\"", self.0.escape_ascii())
×
68
    }
×
69
}
70

71
/// A utility wrapper for Prost metadata serialization.
72
pub struct ProstMetadata<M>(pub M);
73

74
impl<M> Deref for ProstMetadata<M> {
75
    type Target = M;
76

77
    fn deref(&self) -> &Self::Target {
×
78
        &self.0
×
79
    }
×
80
}
81

82
impl<M: Debug> Debug for ProstMetadata<M> {
UNCOV
83
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
×
UNCOV
84
        self.0.fmt(f)
×
UNCOV
85
    }
×
86
}
87

88
impl<M> SerializeMetadata for ProstMetadata<M>
89
where
90
    M: prost::Message,
91
{
92
    fn serialize(self) -> Vec<u8> {
3,512✔
93
        self.0.encode_to_vec()
3,512✔
94
    }
3,512✔
95
}
96

97
impl<M> DeserializeMetadata for ProstMetadata<M>
98
where
99
    M: Debug,
100
    M: prost::Message + Default,
101
{
102
    type Output = M;
103

104
    fn deserialize(metadata: &[u8]) -> VortexResult<Self::Output> {
5,540✔
105
        Ok(M::decode(metadata)?)
5,540✔
106
    }
5,540✔
107
}
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