Trait bitpacking::BitPacker
[−]
[src]
pub trait BitPacker { type DataType; const BLOCK_LEN: usize; fn compress(
decompressed: &[u32],
compressed: &mut [u8],
num_bits: u8
) -> usize; fn compress_sorted(
initial: u32,
decompressed: &[u32],
compressed: &mut [u8],
num_bits: u8
) -> usize; fn decompress_to<Output: FnMut(Self::DataType)>(
compressed: &[u8],
output: Output,
num_bits: u8
) -> usize; fn decompress(
compressed: &[u8],
decompressed: &mut [u32],
num_bits: u8
) -> usize; fn decompress_sorted(
initial: u32,
compressed: &[u8],
decompressed: &mut [u32],
num_bits: u8
) -> usize; fn num_bits(decompressed: &[u32]) -> u8; fn num_bits_sorted(initial: u32, decompressed: &[u32]) -> u8; fn compressed_block_size(num_bits: u8) -> usize { ... } }
Associated Types
type DataType
Type of the register used by the BitPacker
.
Associated Constants
const BLOCK_LEN: usize
Integers are compressed in pack of BLOCK_LEN
u32
-integers.
BLOCK_LEN
is required to be a power of 2, greater than 8.
A high BLOCK_LEN
may negatively impact the compression rate.
Indeed all integers of a given block will take as many bits as the most significant bit of the largest integer.
Required Methods
fn compress(decompressed: &[u32], compressed: &mut [u8], num_bits: u8) -> usize
Compress a block of u32
Assumes that the integers are all lower than 2^num_bits
.
The result is undefined if they are larger.
Returns the amount of bytes of the compressed block.
Panics
Panics if the compressed destination array is assumed to be large enough.
Panics if decompressed
length is not exactly the BLOCK_LEN
.
fn compress_sorted(
initial: u32,
decompressed: &[u32],
compressed: &mut [u8],
num_bits: u8
) -> usize
initial: u32,
decompressed: &[u32],
compressed: &mut [u8],
num_bits: u8
) -> usize
Delta encode and compressed the decompressed
array.
Assumes that the decompressed
array is sorted.
The first element will assume the previous element is initial
.
Returns the amount of bytes of the compressed block.
Panics
Panics if the compressed array is too short.
Panics if the decompressed array is not exactly the BLOCK_LEN
.
fn decompress_to<Output: FnMut(Self::DataType)>(
compressed: &[u8],
output: Output,
num_bits: u8
) -> usize
compressed: &[u8],
output: Output,
num_bits: u8
) -> usize
Decompresses the compressed
array and streams registers full of u32
to the output functions.
fn decompress(
compressed: &[u8],
decompressed: &mut [u32],
num_bits: u8
) -> usize
compressed: &[u8],
decompressed: &mut [u32],
num_bits: u8
) -> usize
fn decompress_sorted(
initial: u32,
compressed: &[u8],
decompressed: &mut [u32],
num_bits: u8
) -> usize
initial: u32,
compressed: &[u8],
decompressed: &mut [u32],
num_bits: u8
) -> usize
fn num_bits(decompressed: &[u32]) -> u8
Returns the minimum number of bits used to represent all integers in the
decompressed
array.
fn num_bits_sorted(initial: u32, decompressed: &[u32]) -> u8
Returns the minimum number of bits used to represent all the deltas in the
decompressed
array.
Provided Methods
fn compressed_block_size(num_bits: u8) -> usize
Returns the size of a compressed block.
Implementors
impl BitPacker for ScalarBitPacker type DataType = u32;
impl BitPacker for SSE3BitPacker type DataType = DataType;