Skip to main content

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::aggregate_fn::AggregateFnVTable;
22use vortex_array::aggregate_fn::fns::nan_count::NanCount;
23use vortex_array::aggregate_fn::session::AggregateFnSessionExt;
24use vortex_array::session::ArraySessionExt;
25use vortex_session::VortexSession;
26
27mod alp;
28mod alp_rd;
29
30/// Initialize ALP encoding in the given session.
31pub fn initialize(session: &VortexSession) {
32    session.arrays().register(ALP);
33    session.arrays().register(ALPRD);
34
35    // Register the ALP-specific NaN count aggregate kernel.
36    session.aggregate_fns().register_aggregate_kernel(
37        ALP::ID,
38        Some(NanCount.id()),
39        &compute::nan_count::ALPNanCountKernel,
40    );
41}