vortex_alp/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! This crate contains an implementation of the floating point compression algorithm from the
5//! paper ["ALP: Adaptive Lossless floating-Point Compression"][paper] by Afroozeh et al.
6//!
7//! The compressor has two variants, classic ALP which is well-suited for data that does not use
8//! the full precision, and "real doubles", values that do.
9//!
10//! Classic ALP will return small integers, and it is meant to be cascaded with other integer
11//! compression techniques such as bit-packing and frame-of-reference encoding. Combined this allows
12//! for significant compression on the order of what you can get for integer values.
13//!
14//! ALP-RD is generally terminal, and in the ideal case it can represent an f64 is just 49 bits,
15//! though generally it is closer to 54 bits per value or ~12.5% compression.
16//!
17//! [paper]: https://ir.cwi.nl/pub/33334/33334.pdf
18
19pub use alp::*;
20pub use alp_rd::*;
21use vortex_array::ArrayVTable;
22use vortex_array::aggregate_fn::AggregateFnVTable;
23use vortex_array::aggregate_fn::fns::nan_count::NanCount;
24use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
25use vortex_array::arrays::patched::use_experimental_patches;
26use vortex_array::session::ArraySessionExt;
27use vortex_session::VortexSession;
28
29mod alp;
30mod alp_rd;
31
32/// Initialize ALP encoding in the given session.
33pub fn initialize(session: &VortexSession) {
34 // If we're using the experimental Patched encoding, register a shim
35 // for ALP with interior patches to decode as Patched array.
36 if use_experimental_patches() {
37 session.arrays().register(ALPPatchedPlugin);
38 } else {
39 session.arrays().register(ALP);
40 }
41 session.arrays().register(ALPRD);
42
43 // Register the ALP-specific NaN count aggregate kernel.
44 session.aggregate_fns().register_aggregate_kernel(
45 ALP.id(),
46 Some(NanCount.id()),
47 &compute::nan_count::ALPNanCountKernel,
48 );
49}