Skip to content

QTSurfer/alp-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alp-py

CI PyPI License

Pure Python implementation of the ALP (Adaptive Lossless floating-Point) compression algorithm.

Based on: Afroozeh & Boncz, "ALP: Adaptive Lossless floating-Point Compression", ACM SIGMOD 2024. (paper · pdf)

Python port of the QTSurfer/alp-java reference implementation. Bit-exact byte-level compatibility with alp-java — files written by either implementation can be read by the other.

Status

Bit-exact aligned with alp-java — encode + decode round-trip verified against fixtures emitted by the Java reference. See the PyPI badge above for the latest version.

Install

pip install alp-codec

Usage

import numpy as np
from alp import encode, decode

values = np.array([65007.28, 65007.31, 65007.30, 65007.32], dtype=np.float64)

# Encode to bytes
blob = encode(values)

# Decode back to a NumPy float64 array
recovered = decode(blob)
assert np.array_equal(values, recovered)

Why ALP

ALP applies semantic compression to decimal floating-point arrays. For a typical financial price column at 2 decimal places it reaches 3-4 bits per value — about an order of magnitude better than Gorilla XOR or block-compressed PLAIN encodings.

The algorithm picks an (e, f) pair per block such that value × 10^e × 2^-f is exactly representable as a small int64, encodes the integers via Frame-Of-Reference + bit-packing, and stores any non-conforming values as outliers with a position list.

Reference implementations

Language Repo Status
Java QTSurfer/alp-java Reference
Python QTSurfer/alp-py This repo

License

Copyright 2026 Wualabs LTD. Apache License 2.0 — see LICENSE.

About

Python implementation of the ALP (Adaptive Lossless Floating-Point) compression codec for double-precision arrays. Bit-exact compatible with alp-java

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages