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;
16pub mod decompress_bool;
17mod iter;
18mod kernel;
19mod ops;
20mod rules;
21
22#[doc(hidden)]
23pub mod _benchmarking {
24    pub use compute::take::take_indices_unchecked;
25
26    use super::*;
27}
28
29use vortex_array::aggregate_fn::AggregateFnVTable;
30use vortex_array::aggregate_fn::fns::is_constant::IsConstant;
31use vortex_array::aggregate_fn::fns::is_sorted::IsSorted;
32use vortex_array::aggregate_fn::fns::min_max::MinMax;
33use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
34use vortex_array::session::ArraySessionExt;
35use vortex_session::VortexSession;
36
37/// Initialize run-end encoding in the given session.
38pub fn initialize(session: &mut VortexSession) {
39    session.arrays().register(RunEnd);
40
41    // Register the RunEnd-specific aggregate kernels.
42    session.aggregate_fns().register_aggregate_kernel(
43        RunEnd::ID,
44        Some(MinMax.id()),
45        &compute::min_max::RunEndMinMaxKernel,
46    );
47    session.aggregate_fns().register_aggregate_kernel(
48        RunEnd::ID,
49        Some(IsConstant.id()),
50        &compute::is_constant::RunEndIsConstantKernel,
51    );
52    session.aggregate_fns().register_aggregate_kernel(
53        RunEnd::ID,
54        Some(IsSorted.id()),
55        &compute::is_sorted::RunEndIsSortedKernel,
56    );
57}
58
59#[cfg(test)]
60mod tests {
61    use vortex_array::ProstMetadata;
62    use vortex_array::dtype::PType;
63    use vortex_array::test_harness::check_metadata;
64
65    use crate::RunEndMetadata;
66
67    #[cfg_attr(miri, ignore)]
68    #[test]
69    fn test_runend_metadata() {
70        check_metadata(
71            "runend.metadata",
72            ProstMetadata(RunEndMetadata {
73                ends_ptype: PType::U64 as i32,
74                num_runs: u64::MAX,
75                offset: u64::MAX,
76            }),
77        );
78    }
79}