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