1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! lbzip2-rs — Pure Rust parallel bzip2 decompressor.
//!
//! Architecture:
//! 1 reader thread fills a ChunkRevolver ring buffer (~100 MB slots)
//! with raw compressed bzip2 data.
//!
//! Per slot the reader does a cheap bit-scan to locate bzip2 block
//! boundaries (magic 0x314159265359 at arbitrary bit offsets), then
//! dispatches N sub-ranges to a worker pool.
//!
//! Each worker independently decodes its Burrows-Wheeler blocks and
//! produces decompressed output. Results are reassembled in order and
//! emitted as a streaming `Read`.
/// bzip2 block magic: π digits — 0x314159265359 (48 bits, bit-aligned).
pub const BLOCK_MAGIC: u64 = 0x314159265359;
/// bzip2 end-of-stream magic: √π digits — 0x177245385090 (48 bits).
pub const FINAL_MAGIC: u64 = 0x177245385090;
// ── Parallelism ──────────────────────────────────────────────────────────────
//
// bzip2 decode is parallelised with a rayon-free scoped-thread work-stealing
// map (`par::par_map`). Worker count is sized to physical cores, overridable
// via the `LBZIP2_THREADS` env var.