Compression Algorithms
AXON automatically applies the most effective compression based on your data patterns
Automatic Selection: You don't need to choose compression algorithms manually. AXON analyzes your data and applies the best combination automatically.
1. RLE (Run-Length Encoding)
Best For
Repeated values
How it works:
Compresses sequences of identical values by storing the value once plus a count.
Example:
age: [30, 30, 30, 30, 30] age:30*5 Savings: 99.5% reduction for 100 repeated values
2. Dictionary Compression
Best For
Limited unique values (high cardinality)
How it works:
Creates a lookup table of unique values, then references them by index.
Example:
role: ["admin", "user", "admin", "guest", "user"] @dict(admin,user,guest)
role:[0,1,0,2,1] Savings: 65-75% reduction for strings with limited unique values
3. Delta Encoding
Best For
Sequential or time-series data
How it works:
Stores differences between consecutive values instead of absolute values.
Example:
price: [10.00, 10.50, 10.75, 11.25] price:Δ10.00[0.50,0.25,0.50] 4. Bit Packing
Best For
Boolean arrays
How it works:
Compresses boolean values to single bits (8 booleans = 1 byte).
Example:
active: [true, true, false, true, false, false, true, true] active:@bitpack(8):0b11010011 Savings: 95.6% reduction for boolean arrays
5. Varint Encoding
Best For
Integers with variable magnitude
How it works:
Variable-length integer encoding that uses fewer bytes for smaller numbers. Small numbers (0-127) use just 1 byte, while larger numbers use more bytes only when needed.
Example:
id:@varint[1,100,1000000] The number 1 uses 1 byte, 100 uses 1 byte, 1000000 uses 3 bytes. Much more efficient than fixed-width encoding.
Automatic Algorithm Selection
AXON analyzes your data and chooses the best algorithm(s) automatically:
import { encode } from '@axon-format/core';
// AXON automatically detects patterns and applies optimal compression
const data = {
users: [
{ id: 1, role: "admin", active: true },
{ id: 2, role: "user", active: true },
{ id: 3, role: "user", active: true }
]
};
const axon = encode(data);
// Automatically uses:
// - RLE for repeated "true" values
// - Dictionary for role field (admin/user)
// - Varint for sequential IDs Next: Learn about Encoding Modes and how AXON adapts to different data structures.