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

vortex-data / vortex / 16935267080

13 Aug 2025 11:00AM UTC coverage: 24.312% (-63.3%) from 87.658%
16935267080

Pull #4226

github

web-flow
Merge 81b48c7fb into baa6ea202
Pull Request #4226: Support converting TimestampTZ to and from duckdb

0 of 2 new or added lines in 1 file covered. (0.0%)

20666 existing lines in 469 files now uncovered.

8726 of 35892 relevant lines covered (24.31%)

147.74 hits per line

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

46.88
/vortex-buffer/src/const.rs
1
// SPDX-License-Identifier: Apache-2.0
2
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3

4
use std::ops::Deref;
5

6
use vortex_error::{VortexError, vortex_bail};
7

8
use crate::{Alignment, Buffer};
9

10
/// A buffer of items of `T` with a compile-time alignment.
11
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Hash)]
12
pub struct ConstBuffer<T, const A: usize>(Buffer<T>);
13

14
impl<T, const A: usize> ConstBuffer<T, A> {
15
    /// Returns the alignment of the buffer.
16
    pub const fn alignment() -> Alignment {
46✔
17
        Alignment::new(A)
46✔
18
    }
46✔
19

20
    /// Align the given buffer (possibly with a copy) and return a new `ConstBuffer`.
21
    pub fn align_from<B: Into<Buffer<T>>>(buf: B) -> Self {
14✔
22
        Self(buf.into().aligned(Self::alignment()))
14✔
23
    }
14✔
24

25
    /// Create a new [`ConstBuffer`] with a copy from the provided slice.
26
    pub fn copy_from<B: AsRef<[T]>>(buf: B) -> Self {
8✔
27
        Self(Buffer::<T>::copy_from_aligned(buf, Self::alignment()))
8✔
28
    }
8✔
29

30
    /// Returns a slice over the buffer of elements of type T.
31
    #[inline(always)]
UNCOV
32
    pub fn as_slice(&self) -> &[T] {
×
UNCOV
33
        self.0.as_slice()
×
UNCOV
34
    }
×
35

36
    /// Unwrap the inner buffer.
37
    pub fn inner(&self) -> &Buffer<T> {
×
38
        &self.0
×
39
    }
×
40

41
    /// Unwrap the inner buffer.
UNCOV
42
    pub fn into_inner(self) -> Buffer<T> {
×
UNCOV
43
        self.0
×
UNCOV
44
    }
×
45
}
46

47
impl<T, const A: usize> TryFrom<Buffer<T>> for ConstBuffer<T, A> {
48
    type Error = VortexError;
49

UNCOV
50
    fn try_from(value: Buffer<T>) -> Result<Self, Self::Error> {
×
UNCOV
51
        if !value.alignment().is_aligned_to(Alignment::new(A)) {
×
52
            vortex_bail!(
×
53
                "Cannot convert buffer with alignment {} to buffer with alignment {}",
×
54
                value.alignment(),
×
55
                A
56
            );
UNCOV
57
        }
×
UNCOV
58
        Ok(Self(value))
×
UNCOV
59
    }
×
60
}
61

62
impl<T, const A: usize> AsRef<Buffer<T>> for ConstBuffer<T, A> {
63
    fn as_ref(&self) -> &Buffer<T> {
124✔
64
        &self.0
124✔
65
    }
124✔
66
}
67

68
impl<T, const A: usize> Deref for ConstBuffer<T, A> {
69
    type Target = [T];
70

71
    fn deref(&self) -> &Self::Target {
12✔
72
        self.0.as_slice()
12✔
73
    }
12✔
74
}
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