columnar::bytes::serialization_neu

Function encode

Source
pub fn encode<'a, A>(store: &mut Vec<u64>, iter: &A)
where A: AsBytes<'a>,
Expand description

Encodes item into u64 aligned words.

The sequence of byte slices are appended, with padding to have each slice start u64 aligned. The sequence is then pre-pended with as many byte offsets as there are slices in item, plus one. The byte offsets indicate where each slice ends, and by rounding up to u64 alignemnt where the next slice begins. The first offset indicates where the list of offsets itself ends, and where the first slice begins.

We will need to visit as_bytes three times to extract this information, so the method should be efficient and inlined. The first read writes the first offset, the second writes each other offset, and the third writes the bytes themselves.

The offsets are zero-based, rather than based on store.len(). If you call the method with a non-empty store be careful decoding.