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