Module mayda::unimodal [] [src]

Unimodal encoding of integer arrays. Intended for cases where information about the probability distribution of the entries is not known, and the presence of outliers reduces the compression ratio of the other types. Implemented for all primitive integer types.

This type approaches general probability distributions with outliers by performing several initial transformations to reduce the minimum necessary bit width. Specifically, the median value is subtracted from the entries, the entries are mapped to the unsigned integers by the zig-zag encoding, and the most significant bits of any outliers are removed and stored separately. The result is that the compression effectively depends only on the standard deviation of the probability distribution of the block entries.

Examples

use mayda::{Access, Encode, Unimodal};

let input: Vec<u32> = vec![1, 4, 2, 8, 5, 7];
let mut bits = Unimodal::new();
bits.encode(&input).unwrap();

let length = bits.len();
assert_eq!(length, 6);

let output = bits.decode();
assert_eq!(input, output);

let value = bits.access(4);
assert_eq!(value, 5);

let range = bits.access(1..4);
assert_eq!(range, vec![4, 2, 8]); 

Structs

Unimodal

The type of a unimodal encoded integer array. Designed for moderate compression and efficient decoding through the Encode trait, and efficient random access through the Access and AccessInto traits.