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::ArrayVTable;
30use vortex_array::aggregate_fn::AggregateFnVTable;
31use vortex_array::aggregate_fn::fns::is_constant::IsConstant;
32use vortex_array::aggregate_fn::fns::is_sorted::IsSorted;
33use vortex_array::aggregate_fn::fns::min_max::MinMax;
34use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
35use vortex_array::session::ArraySessionExt;
36use vortex_session::VortexSession;
37
38/// Initialize run-end encoding in the given session.
39pub fn initialize(session: &VortexSession) {
40    session.arrays().register(RunEnd);
41
42    // Register the RunEnd-specific aggregate kernels.
43    session.aggregate_fns().register_aggregate_kernel(
44        RunEnd.id(),
45        Some(MinMax.id()),
46        &compute::min_max::RunEndMinMaxKernel,
47    );
48    session.aggregate_fns().register_aggregate_kernel(
49        RunEnd.id(),
50        Some(IsConstant.id()),
51        &compute::is_constant::RunEndIsConstantKernel,
52    );
53    session.aggregate_fns().register_aggregate_kernel(
54        RunEnd.id(),
55        Some(IsSorted.id()),
56        &compute::is_sorted::RunEndIsSortedKernel,
57    );
58}
59
60#[cfg(test)]
61mod tests {
62    use prost::Message;
63    use vortex_array::dtype::PType;
64    use vortex_array::test_harness::check_metadata;
65
66    use crate::RunEndMetadata;
67
68    #[cfg_attr(miri, ignore)]
69    #[test]
70    fn test_runend_metadata() {
71        check_metadata(
72            "runend.metadata",
73            &RunEndMetadata {
74                ends_ptype: PType::U64 as i32,
75                num_runs: u64::MAX,
76                offset: u64::MAX,
77            }
78            .encode_to_vec(),
79        );
80    }
81}