Skip to main content

vortex_runend/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4#[cfg(feature = "arbitrary")]
5mod arbitrary;
6#[cfg(feature = "arbitrary")]
7pub use arbitrary::ArbitraryRunEndArray;
8pub use array::*;
9pub use iter::trimmed_ends_iter;
10
11mod array;
12#[cfg(feature = "arrow")]
13mod arrow;
14pub mod compress;
15mod compute;
16mod iter;
17mod kernel;
18mod ops;
19mod rules;
20
21#[doc(hidden)]
22pub mod _benchmarking {
23    pub use compute::take::take_indices_unchecked;
24
25    use super::*;
26}
27
28use vortex_array::ArrayBufferVisitor;
29use vortex_array::ArrayChildVisitor;
30use vortex_array::session::ArraySessionExt;
31use vortex_array::vtable::VisitorVTable;
32use vortex_session::VortexSession;
33
34impl VisitorVTable<RunEndVTable> for RunEndVTable {
35    fn visit_buffers(_array: &RunEndArray, _visitor: &mut dyn ArrayBufferVisitor) {}
36
37    fn nbuffers(_array: &RunEndArray) -> usize {
38        0
39    }
40
41    fn visit_children(array: &RunEndArray, visitor: &mut dyn ArrayChildVisitor) {
42        visitor.visit_child("ends", array.ends());
43        visitor.visit_child("values", array.values());
44    }
45
46    fn nchildren(_array: &RunEndArray) -> usize {
47        2
48    }
49}
50
51/// Initialize run-end encoding in the given session.
52pub fn initialize(session: &mut VortexSession) {
53    session.arrays().register(RunEndVTable::ID, RunEndVTable);
54}
55
56#[cfg(test)]
57mod tests {
58    use vortex_array::ProstMetadata;
59    use vortex_array::dtype::PType;
60    use vortex_array::test_harness::check_metadata;
61
62    use crate::RunEndMetadata;
63
64    #[cfg_attr(miri, ignore)]
65    #[test]
66    fn test_runend_metadata() {
67        check_metadata(
68            "runend.metadata",
69            ProstMetadata(RunEndMetadata {
70                ends_ptype: PType::U64 as i32,
71                num_runs: u64::MAX,
72                offset: u64::MAX,
73            }),
74        );
75    }
76}