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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Prefix-compressed key-value block.
//!
//! A "block" is the fundamental on-disk unit of a SSTable: a
//! contiguous run of sorted entries with shared key prefixes
//! compressed away, plus a trailing array of *restart points* that
//! anchors random seeks within the block.
//!
//! # Public types
//!
//! - [`BlockBuilder`] — encodes entries; used by [`crate::table::TableBuilder`]
//! - [`Block`] — owns the parsed bytes
//! - [`BlockIter`] — iterator over a `Block`'s entries (impl
//! [`crate::DbIterator`])
//!
//! # Why surface this
//!
//! Most users only touch tables via [`crate::db_impl::DBImpl`] —
//! they never construct a block directly. The module is public for:
//!
//! - Custom storage engines reusing the block format
//! - Diagnostic tools that need to read raw blocks
//! - Tests that want to assert specific on-disk layouts
//!
//! # Example: round-trip a block in memory
//!
//! ```
//! use novakv::block::{BlockBuilder, Block, BlockIter};
//! use novakv::prelude::*;
//! use novakv::DbIterator;
//!
//! let mut b = BlockBuilder::new(BytewiseComparator, 16);
//! b.add(b"alpha", b"1");
//! b.add(b"bravo", b"2");
//! b.add(b"charlie", b"3");
//! let bytes = b.finish().to_vec();
//!
//! let block = Block::new(bytes).unwrap();
//! let mut it = BlockIter::new(&block, BytewiseComparator);
//! it.seek_to_first();
//! let mut keys = Vec::new();
//! while it.valid() {
//! keys.push(it.key().to_vec());
//! it.next();
//! }
//! assert_eq!(keys, vec![b"alpha".to_vec(), b"bravo".to_vec(), b"charlie".to_vec()]);
//! ```
//!
//! # Restart interval tuning
//!
//! `BlockBuilder::new(comparator, restart_interval)` — every Nth
//! entry is a restart point (full key, not prefix-compressed).
//! Smaller = faster seeks, larger blocks. Default: 16.
//! Exposed via [`crate::db_impl::Options::block_restart_interval`].
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;