Skip to main content

vortex_btrblocks/schemes/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Compression scheme implementations.
5
6pub mod binary;
7pub mod float;
8pub mod integer;
9pub mod string;
10
11pub mod decimal;
12pub mod temporal;
13
14pub(crate) mod patches;
15
16use vortex_compressor::builtins::BinaryDictScheme;
17use vortex_compressor::builtins::FloatDictScheme;
18use vortex_compressor::builtins::IntDictScheme;
19use vortex_compressor::builtins::StringDictScheme;
20use vortex_compressor::scheme::AncestorExclusion;
21use vortex_compressor::scheme::ChildSelection;
22use vortex_compressor::scheme::DescendantExclusion;
23use vortex_compressor::scheme::SchemeExt;
24
25use crate::schemes::integer::SparseScheme;
26
27/// Shared descendant exclusion rules for RLE schemes.
28///
29/// RLE indices (child 1) and offsets (child 2) are monotonically increasing positions with all
30/// unique values. Dict and Sparse are pointless on such data. Self-exclusion already prevents
31/// RLE on RLE children.
32fn rle_descendant_exclusions() -> Vec<DescendantExclusion> {
33    vec![
34        DescendantExclusion {
35            excluded: IntDictScheme.id(),
36            children: ChildSelection::Many(&[1, 2]),
37        },
38        // TODO(connor): This is wrong for some reason?
39        // DescendantExclusion {
40        //     excluded: RunEndScheme.id(),
41        //     children: ChildSelection::Many(&[1, 2]),
42        // },
43        DescendantExclusion {
44            excluded: SparseScheme.id(),
45            children: ChildSelection::Many(&[1, 2]),
46        },
47    ]
48}
49
50/// Shared ancestor exclusion rules for RLE schemes.
51///
52/// Dict values (child 0) are all unique by definition, so RLE is pointless on them.
53fn rle_ancestor_exclusions() -> Vec<AncestorExclusion> {
54    vec![
55        AncestorExclusion {
56            ancestor: IntDictScheme.id(),
57            children: ChildSelection::One(0),
58        },
59        AncestorExclusion {
60            ancestor: FloatDictScheme.id(),
61            children: ChildSelection::One(0),
62        },
63        AncestorExclusion {
64            ancestor: StringDictScheme.id(),
65            children: ChildSelection::One(0),
66        },
67        AncestorExclusion {
68            ancestor: BinaryDictScheme.id(),
69            children: ChildSelection::One(0),
70        },
71    ]
72}