Skip to main content

geolith_tiles_builder/sort/
block.rs

1//! The columnar block codec of the sort runs.
2//!
3//! A run is a sequence of blocks. A block holds a few thousand entries that
4//! are already sorted by key, and stores them column by column:
5//!
6//! - the sort keys as the delta to the key before (the keys of a block are
7//!   close, so a delta is one to three bytes where a key is nine),
8//! - the layer, the geometry type, the feature id and the sort key,
9//! - the geometry commands,
10//! - the properties: a property set that one of the last [`SET_WINDOW`]
11//!   sets of the block already stored is stored once and referenced; a
12//!   string is stored once per block and referenced.
13//!
14//! Every column holds values of one kind, so the general-purpose compressor
15//! that runs over the finished block finds the repeats a row layout hides.
16//! Decoding reproduces every entry exactly, bit for bit.
17
18use std::collections::HashMap;
19use std::hash::{BuildHasherDefault, Hasher};
20use std::sync::Arc;
21
22use geolith::layer::Layer;
23use geolith::tile::feature::{GeomType, PropValue, TileFeature};
24
25use crate::sort::entry::SortEntry;
26
27/// The block was cut: why a block cannot be decoded.
28#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
29#[non_exhaustive]
30pub enum BlockError {
31    /// A column ends before its last value.
32    #[error("a column ends too early")]
33    ColumnEnds,
34    /// A varint is longer than ten bytes or does not fit its type.
35    #[error("a varint is out of range")]
36    Varint,
37    /// A layer or geometry type byte names no known variant.
38    #[error("unknown layer or geometry type {0}")]
39    UnknownKind(u8),
40    /// A property value tag names no known variant.
41    #[error("unknown property value tag {0}")]
42    UnknownTag(u8),
43    /// A string reference or property-set reference points past the table.
44    #[error("a reference points outside its table")]
45    Reference,
46    /// A string is not UTF-8.
47    #[error("a string is not valid UTF-8")]
48    Utf8,
49    /// The block holds fewer columns or bytes than its header says.
50    #[error("the block layout is wrong")]
51    Layout,
52    /// More entries were asked for than the block holds.
53    #[error("the block holds no more entries")]
54    Exhausted,
55    /// An entry cannot be stored: its key is below the key before it.
56    #[error("the entries are not sorted by key")]
57    NotSorted,
58    /// An entry has a value this codec cannot store.
59    #[error("a value of this type cannot be stored")]
60    Unsupported,
61}
62
63/// The properties of a feature, shared by the entries that came from it.
64type PropertySet = Arc<Vec<(String, PropValue)>>;
65
66const COLUMNS: usize = 13;
67const KEYS: usize = 0;
68const LAYERS: usize = 1;
69const GEOM_TYPES: usize = 2;
70const IDS: usize = 3;
71const SORT_KEYS: usize = 4;
72const GEOM_LENS: usize = 5;
73const GEOM_VALUES: usize = 6;
74const PROP_REFS: usize = 7;
75const PROP_COUNTS: usize = 8;
76const PROP_TAGS: usize = 9;
77const PROP_NUMS: usize = 10;
78const STRINGS: usize = 11;
79const STRING_REFS: usize = 12;
80
81/// How many property sets back an entry may refer to. The decoder keeps this
82/// many sets alive, which bounds its memory however long the block is.
83pub const SET_WINDOW: usize = 1024;
84
85const TAG_STR: u8 = 0;
86const TAG_F64: u8 = 1;
87const TAG_I64: u8 = 2;
88const TAG_U64: u8 = 3;
89const TAG_FALSE: u8 = 4;
90const TAG_TRUE: u8 = 5;
91
92/// A hasher for table keys that are already well spread (addresses).
93#[derive(Default)]
94struct AddressHasher(u64);
95
96impl Hasher for AddressHasher {
97    fn finish(&self) -> u64 {
98        self.0
99    }
100
101    fn write(&mut self, bytes: &[u8]) {
102        for &b in bytes {
103            self.0 = (self.0 ^ u64::from(b)).wrapping_mul(0x0100_0000_01b3);
104        }
105    }
106
107    fn write_usize(&mut self, n: usize) {
108        self.0 = (n as u64).wrapping_mul(0x9E37_79B9_7F4A_7C15);
109    }
110}
111
112type AddressMap<V> = HashMap<usize, V, BuildHasherDefault<AddressHasher>>;
113
114/// Appends entries to one block.
115#[derive(Default)]
116pub struct BlockEncoder {
117    columns: [Vec<u8>; COLUMNS],
118    entries: u32,
119    prev_key: u64,
120    sets: AddressMap<u32>,
121    set_count: u32,
122    strings: HashMap<String, u32>,
123}
124
125impl BlockEncoder {
126    /// An empty encoder.
127    #[must_use]
128    pub fn new() -> Self {
129        Self::default()
130    }
131
132    /// Entries added to the block so far.
133    #[must_use]
134    pub const fn len(&self) -> u32 {
135        self.entries
136    }
137
138    /// Whether the block holds no entry.
139    #[must_use]
140    pub const fn is_empty(&self) -> bool {
141        self.entries == 0
142    }
143
144    /// Bytes the block takes before compression, headers excluded.
145    #[must_use]
146    pub fn raw_len(&self) -> usize {
147        self.columns.iter().map(Vec::len).sum()
148    }
149
150    /// Add one entry. Keys must not decrease from one call to the next.
151    ///
152    /// # Errors
153    ///
154    /// [`BlockError::NotSorted`] when `entry.key` is below the previous key;
155    /// [`BlockError::Unsupported`] for a property value of an unknown type.
156    pub fn push(&mut self, entry: &SortEntry) -> Result<(), BlockError> {
157        let delta = entry
158            .key
159            .checked_sub(self.prev_key)
160            .ok_or(BlockError::NotSorted)?;
161        let feature = &entry.feature;
162        let props = self.property_ref(&feature.properties)?;
163        put_varint(&mut self.columns[KEYS], delta);
164        self.columns[LAYERS].push(feature.layer as u8);
165        self.columns[GEOM_TYPES].push(feature.geom_type as u8);
166        put_varint(&mut self.columns[IDS], feature.id);
167        put_varint(
168            &mut self.columns[SORT_KEYS],
169            zigzag(i64::from(feature.sort_key)),
170        );
171        put_varint(&mut self.columns[GEOM_LENS], feature.geometry.len() as u64);
172        for &v in &feature.geometry {
173            put_varint(&mut self.columns[GEOM_VALUES], u64::from(v));
174        }
175        put_varint(&mut self.columns[PROP_REFS], u64::from(props));
176        self.prev_key = entry.key;
177        self.entries += 1;
178        Ok(())
179    }
180
181    /// The reference to a property set: 0 when the set is new (it is then
182    /// stored in the property columns), else how many sets back it was stored.
183    fn property_ref(&mut self, props: &PropertySet) -> Result<u32, BlockError> {
184        let address = Arc::as_ptr(props) as usize;
185        if let Some(&index) = self.sets.get(&address) {
186            let distance = self.set_count - index;
187            if distance as usize <= SET_WINDOW {
188                return Ok(distance);
189            }
190        }
191        put_varint(&mut self.columns[PROP_COUNTS], props.len() as u64);
192        for (key, value) in props.iter() {
193            self.put_string(key);
194            match value {
195                PropValue::Str(s) => {
196                    self.columns[PROP_TAGS].push(TAG_STR);
197                    self.put_string(s);
198                }
199                PropValue::F64(x) => {
200                    self.columns[PROP_TAGS].push(TAG_F64);
201                    self.columns[PROP_NUMS].extend_from_slice(&x.to_bits().to_le_bytes());
202                }
203                PropValue::I64(x) => {
204                    self.columns[PROP_TAGS].push(TAG_I64);
205                    put_varint(&mut self.columns[PROP_NUMS], zigzag(*x));
206                }
207                PropValue::U64(x) => {
208                    self.columns[PROP_TAGS].push(TAG_U64);
209                    put_varint(&mut self.columns[PROP_NUMS], *x);
210                }
211                PropValue::Bool(false) => self.columns[PROP_TAGS].push(TAG_FALSE),
212                PropValue::Bool(true) => self.columns[PROP_TAGS].push(TAG_TRUE),
213                _ => return Err(BlockError::Unsupported),
214            }
215        }
216        self.sets.insert(address, self.set_count);
217        self.set_count += 1;
218        Ok(0)
219    }
220
221    /// A string reference: its number, or the next number and the string
222    /// itself in the string column when the block has not met it yet.
223    fn put_string(&mut self, s: &str) {
224        let next = self.strings.len() as u32;
225        if let Some(&number) = self.strings.get(s) {
226            put_varint(&mut self.columns[STRING_REFS], u64::from(number));
227            return;
228        }
229        put_varint(&mut self.columns[STRING_REFS], u64::from(next));
230        put_varint(&mut self.columns[STRINGS], s.len() as u64);
231        self.columns[STRINGS].extend_from_slice(s.as_bytes());
232        self.strings.insert(s.to_owned(), next);
233    }
234
235    /// Write the block, with its column table, to `out` and reset the
236    /// encoder for the next block. Returns the number of entries.
237    pub fn finish_into(&mut self, out: &mut Vec<u8>) -> u32 {
238        for column in &self.columns {
239            out.extend_from_slice(&(column.len() as u32).to_le_bytes());
240        }
241        for column in &mut self.columns {
242            out.extend_from_slice(column);
243            column.clear();
244        }
245        let entries = self.entries;
246        self.entries = 0;
247        self.prev_key = 0;
248        self.sets.clear();
249        self.set_count = 0;
250        self.strings.clear();
251        entries
252    }
253}
254
255/// Reads the entries of one decoded block in order.
256pub struct BlockDecoder {
257    raw: Vec<u8>,
258    ranges: [(usize, usize); COLUMNS],
259    at: [usize; COLUMNS],
260    remaining: u32,
261    prev_key: u64,
262    sets: Vec<Option<PropertySet>>,
263    set_count: u32,
264    strings: Vec<(usize, usize)>,
265}
266
267impl BlockDecoder {
268    /// A decoder with no block loaded.
269    #[must_use]
270    pub const fn empty() -> Self {
271        Self {
272            raw: Vec::new(),
273            ranges: [(0, 0); COLUMNS],
274            at: [0; COLUMNS],
275            remaining: 0,
276            prev_key: 0,
277            sets: Vec::new(),
278            set_count: 0,
279            strings: Vec::new(),
280        }
281    }
282
283    /// The buffer to decompress the next block into. Call [`Self::load`]
284    /// after it is filled.
285    pub fn buffer(&mut self) -> &mut Vec<u8> {
286        &mut self.raw
287    }
288
289    /// Parse the column table of the block in the buffer.
290    ///
291    /// # Errors
292    ///
293    /// [`BlockError::Layout`] when the columns do not add up to the buffer.
294    pub fn load(&mut self, entries: u32) -> Result<(), BlockError> {
295        let table = COLUMNS * 4;
296        if self.raw.len() < table {
297            return Err(BlockError::Layout);
298        }
299        let mut start = table;
300        for (i, range) in self.ranges.iter_mut().enumerate() {
301            let len = u32::from_le_bytes(
302                self.raw[i * 4..i * 4 + 4]
303                    .try_into()
304                    .map_err(|_| BlockError::Layout)?,
305            ) as usize;
306            let end = start.checked_add(len).ok_or(BlockError::Layout)?;
307            *range = (start, end);
308            start = end;
309        }
310        if start != self.raw.len() {
311            return Err(BlockError::Layout);
312        }
313        self.at = std::array::from_fn(|i| self.ranges[i].0);
314        self.remaining = entries;
315        self.prev_key = 0;
316        self.sets.clear();
317        self.sets.resize(SET_WINDOW, None);
318        self.set_count = 0;
319        self.strings.clear();
320        Ok(())
321    }
322
323    /// Whether every column was read to its end: a block that decodes all
324    /// its entries and leaves bytes behind is wrong.
325    ///
326    /// # Errors
327    ///
328    /// [`BlockError::Layout`] when a column has bytes left.
329    pub fn check_complete(&self) -> Result<(), BlockError> {
330        if self.remaining == 0 && (0..COLUMNS).all(|i| self.at[i] == self.ranges[i].1) {
331            Ok(())
332        } else {
333            Err(BlockError::Layout)
334        }
335    }
336
337    /// Entries not read yet.
338    #[must_use]
339    pub const fn remaining(&self) -> u32 {
340        self.remaining
341    }
342
343    /// The next entry of the block.
344    ///
345    /// # Errors
346    ///
347    /// A [`BlockError`] when the block is cut or inconsistent.
348    pub fn next_entry(&mut self) -> Result<SortEntry, BlockError> {
349        if self.remaining == 0 {
350            return Err(BlockError::Exhausted);
351        }
352        let delta = self.varint(KEYS)?;
353        let key = self.prev_key.checked_add(delta).ok_or(BlockError::Varint)?;
354        let layer_byte = self.byte(LAYERS)?;
355        let layer = Layer::ALL
356            .into_iter()
357            .find(|l| *l as u8 == layer_byte)
358            .ok_or(BlockError::UnknownKind(layer_byte))?;
359        let geom_byte = self.byte(GEOM_TYPES)?;
360        let geom_type = match geom_byte {
361            1 => GeomType::Point,
362            2 => GeomType::Line,
363            3 => GeomType::Polygon,
364            other => return Err(BlockError::UnknownKind(other)),
365        };
366        let id = self.varint(IDS)?;
367        let sort_key =
368            i32::try_from(unzigzag(self.varint(SORT_KEYS)?)).map_err(|_| BlockError::Varint)?;
369        let geom_len = self.varint(GEOM_LENS)? as usize;
370        let available = self.ranges[GEOM_VALUES].1 - self.at[GEOM_VALUES];
371        if geom_len > available {
372            return Err(BlockError::ColumnEnds);
373        }
374        let mut geometry = Vec::with_capacity(geom_len);
375        for _ in 0..geom_len {
376            geometry
377                .push(u32::try_from(self.varint(GEOM_VALUES)?).map_err(|_| BlockError::Varint)?);
378        }
379        let reference = self.varint(PROP_REFS)? as usize;
380        let properties = if reference == 0 {
381            let set = Arc::new(self.property_set()?);
382            let slot = self.set_count as usize % SET_WINDOW;
383            self.sets[slot] = Some(Arc::clone(&set));
384            self.set_count += 1;
385            set
386        } else {
387            if reference > SET_WINDOW || reference > self.set_count as usize {
388                return Err(BlockError::Reference);
389            }
390            let slot = (self.set_count as usize - reference) % SET_WINDOW;
391            Arc::clone(self.sets[slot].as_ref().ok_or(BlockError::Reference)?)
392        };
393        self.prev_key = key;
394        self.remaining -= 1;
395        Ok(SortEntry::new(
396            key,
397            TileFeature {
398                layer,
399                id,
400                geom_type,
401                geometry,
402                properties,
403                sort_key,
404            },
405        ))
406    }
407
408    fn property_set(&mut self) -> Result<Vec<(String, PropValue)>, BlockError> {
409        let count = self.varint(PROP_COUNTS)? as usize;
410        let available = self.ranges[PROP_TAGS].1 - self.at[PROP_TAGS];
411        if count > available {
412            return Err(BlockError::ColumnEnds);
413        }
414        let mut set = Vec::with_capacity(count);
415        for _ in 0..count {
416            let key = self.string()?;
417            let value = match self.byte(PROP_TAGS)? {
418                TAG_STR => PropValue::Str(self.string()?),
419                TAG_F64 => {
420                    let at = self.at[PROP_NUMS];
421                    let end = at.checked_add(8).ok_or(BlockError::ColumnEnds)?;
422                    if end > self.ranges[PROP_NUMS].1 {
423                        return Err(BlockError::ColumnEnds);
424                    }
425                    let bits = u64::from_le_bytes(
426                        self.raw[at..end]
427                            .try_into()
428                            .map_err(|_| BlockError::ColumnEnds)?,
429                    );
430                    self.at[PROP_NUMS] = end;
431                    PropValue::F64(f64::from_bits(bits))
432                }
433                TAG_I64 => PropValue::I64(unzigzag(self.varint(PROP_NUMS)?)),
434                TAG_U64 => PropValue::U64(self.varint(PROP_NUMS)?),
435                TAG_FALSE => PropValue::Bool(false),
436                TAG_TRUE => PropValue::Bool(true),
437                other => return Err(BlockError::UnknownTag(other)),
438            };
439            set.push((key, value));
440        }
441        Ok(set)
442    }
443
444    fn string(&mut self) -> Result<String, BlockError> {
445        let number = self.varint(STRING_REFS)? as usize;
446        let (at, end) = if let Some(&range) = self.strings.get(number) {
447            range
448        } else {
449            if number != self.strings.len() {
450                return Err(BlockError::Reference);
451            }
452            let len = self.varint(STRINGS)? as usize;
453            let at = self.at[STRINGS];
454            let end = at.checked_add(len).ok_or(BlockError::ColumnEnds)?;
455            if end > self.ranges[STRINGS].1 {
456                return Err(BlockError::ColumnEnds);
457            }
458            self.at[STRINGS] = end;
459            self.strings.push((at, end));
460            (at, end)
461        };
462        std::str::from_utf8(&self.raw[at..end])
463            .map(str::to_owned)
464            .map_err(|_| BlockError::Utf8)
465    }
466
467    fn byte(&mut self, column: usize) -> Result<u8, BlockError> {
468        let at = self.at[column];
469        if at >= self.ranges[column].1 {
470            return Err(BlockError::ColumnEnds);
471        }
472        self.at[column] = at + 1;
473        Ok(self.raw[at])
474    }
475
476    fn varint(&mut self, column: usize) -> Result<u64, BlockError> {
477        let end = self.ranges[column].1;
478        let mut at = self.at[column];
479        let mut value = 0u64;
480        for shift in (0..70).step_by(7) {
481            if at >= end {
482                return Err(BlockError::ColumnEnds);
483            }
484            let b = self.raw[at];
485            at += 1;
486            if shift == 63 && b > 1 {
487                return Err(BlockError::Varint);
488            }
489            value |= u64::from(b & 0x7f) << shift;
490            if b & 0x80 == 0 {
491                self.at[column] = at;
492                return Ok(value);
493            }
494        }
495        Err(BlockError::Varint)
496    }
497}
498
499fn put_varint(out: &mut Vec<u8>, mut value: u64) {
500    while value >= 0x80 {
501        out.push((value as u8 & 0x7f) | 0x80);
502        value >>= 7;
503    }
504    out.push(value as u8);
505}
506
507const fn zigzag(v: i64) -> u64 {
508    ((v << 1) ^ (v >> 63)) as u64
509}
510
511const fn unzigzag(v: u64) -> i64 {
512    ((v >> 1) as i64) ^ -((v & 1) as i64)
513}
514
515#[cfg(test)]
516mod tests {
517    use super::*;
518
519    fn entry(key: u64, id: u64, props: &Arc<Vec<(String, PropValue)>>) -> SortEntry {
520        SortEntry::new(
521            key,
522            TileFeature {
523                layer: Layer::Buildings,
524                id,
525                geom_type: GeomType::Polygon,
526                geometry: vec![9, 50, 34, 26, 4, 0, 0, 4, 3, 15],
527                properties: Arc::clone(props),
528                sort_key: -7,
529            },
530        )
531    }
532
533    fn roundtrip(entries: &[SortEntry]) -> Vec<SortEntry> {
534        let mut encoder = BlockEncoder::new();
535        for e in entries {
536            encoder.push(e).expect("push");
537        }
538        let mut raw = Vec::new();
539        let count = encoder.finish_into(&mut raw);
540        assert_eq!(count as usize, entries.len());
541        let mut decoder = BlockDecoder::empty();
542        decoder.buffer().extend_from_slice(&raw);
543        decoder.load(count).expect("load");
544        let out: Vec<SortEntry> = (0..count)
545            .map(|_| decoder.next_entry().expect("entry"))
546            .collect();
547        decoder.check_complete().expect("complete");
548        out
549    }
550
551    fn bytes(entries: &[SortEntry]) -> Vec<Vec<u8>> {
552        entries
553            .iter()
554            .map(|e| e.to_bytes().expect("encode"))
555            .collect()
556    }
557
558    #[test]
559    fn every_value_kind_comes_back_bit_for_bit() {
560        let props = Arc::new(vec![
561            ("name".to_owned(), PropValue::Str("Zürich 駅 🚉".to_owned())),
562            ("empty".to_owned(), PropValue::Str(String::new())),
563            ("nan".to_owned(), PropValue::F64(f64::NAN)),
564            ("neg0".to_owned(), PropValue::F64(-0.0)),
565            ("inf".to_owned(), PropValue::F64(f64::NEG_INFINITY)),
566            ("i".to_owned(), PropValue::I64(i64::MIN)),
567            ("u".to_owned(), PropValue::U64(u64::MAX)),
568            ("t".to_owned(), PropValue::Bool(true)),
569            ("f".to_owned(), PropValue::Bool(false)),
570        ]);
571        let none: Arc<Vec<(String, PropValue)>> = Arc::new(Vec::new());
572        let entries = vec![
573            entry(0, 0, &none),
574            entry(5, u64::MAX, &props),
575            entry(5, 1, &props),
576            entry(u64::MAX, 2, &none),
577        ];
578        let back = roundtrip(&entries);
579        assert_eq!(bytes(&back), bytes(&entries));
580    }
581
582    #[test]
583    fn a_shared_property_set_is_stored_once_and_shared_after_decoding() {
584        let props = Arc::new(vec![("k".to_owned(), PropValue::Str("v".to_owned()))]);
585        let entries: Vec<SortEntry> = (0..10).map(|i| entry(i, i, &props)).collect();
586        let back = roundtrip(&entries);
587        for pair in back.windows(2) {
588            assert!(Arc::ptr_eq(
589                &pair[0].feature.properties,
590                &pair[1].feature.properties
591            ));
592        }
593        let mut shared = BlockEncoder::new();
594        let mut distinct = BlockEncoder::new();
595        // The entries stay alive: the encoder tells sets apart by address.
596        let kept: Vec<SortEntry> = (0..10)
597            .map(|i| entry(i, i, &Arc::new(props.as_ref().clone())))
598            .collect();
599        for (i, own) in kept.iter().enumerate() {
600            shared.push(&entry(i as u64, 0, &props)).expect("push");
601            distinct.push(own).expect("push");
602        }
603        assert!(shared.raw_len() < distinct.raw_len());
604    }
605
606    #[test]
607    fn a_property_set_beyond_the_window_is_stored_again() {
608        let first = Arc::new(vec![("a".to_owned(), PropValue::I64(1))]);
609        let mut entries = vec![entry(0, 0, &first)];
610        for i in 0..(SET_WINDOW as u64 + 5) {
611            let other = Arc::new(vec![("b".to_owned(), PropValue::I64(i as i64))]);
612            entries.push(entry(i + 1, i + 1, &other));
613        }
614        entries.push(entry(SET_WINDOW as u64 + 10, 9, &first));
615        let back = roundtrip(&entries);
616        assert_eq!(bytes(&back), bytes(&entries));
617    }
618
619    #[test]
620    fn keys_that_go_down_are_refused() {
621        let props = Arc::new(Vec::new());
622        let mut encoder = BlockEncoder::new();
623        encoder.push(&entry(10, 0, &props)).expect("push");
624        assert_eq!(
625            encoder.push(&entry(9, 0, &props)),
626            Err(BlockError::NotSorted)
627        );
628    }
629
630    #[test]
631    fn a_cut_block_is_an_error_at_every_length() {
632        let props = Arc::new(vec![
633            ("k".to_owned(), PropValue::Str("v".to_owned())),
634            ("n".to_owned(), PropValue::F64(1.5)),
635        ]);
636        let entries: Vec<SortEntry> = (0..20).map(|i| entry(i, i, &props)).collect();
637        let mut encoder = BlockEncoder::new();
638        for e in &entries {
639            encoder.push(e).expect("push");
640        }
641        let mut raw = Vec::new();
642        let count = encoder.finish_into(&mut raw);
643        for cut in 0..raw.len() {
644            let mut decoder = BlockDecoder::empty();
645            decoder.buffer().extend_from_slice(&raw[..cut]);
646            let outcome = decoder.load(count).and_then(|()| {
647                for _ in 0..count {
648                    decoder.next_entry()?;
649                }
650                decoder.check_complete()
651            });
652            assert!(outcome.is_err(), "a block cut at {cut} must not decode");
653        }
654    }
655
656    #[test]
657    fn garbage_never_panics_the_decoder() {
658        let mut seed = 0x1234_5678_9abc_def0_u64;
659        for _ in 0..2000 {
660            let len = (seed % 300) as usize;
661            let raw: Vec<u8> = (0..len)
662                .map(|_| {
663                    seed = seed
664                        .wrapping_mul(6_364_136_223_846_793_005)
665                        .wrapping_add(1_442_695_040_888_963_407);
666                    (seed >> 33) as u8
667                })
668                .collect();
669            let mut decoder = BlockDecoder::empty();
670            decoder.buffer().extend_from_slice(&raw);
671            if decoder.load(5).is_ok() {
672                for _ in 0..5 {
673                    if decoder.next_entry().is_err() {
674                        break;
675                    }
676                }
677            }
678        }
679    }
680}