pub struct MasterIndex {
pub disk_pages: Vec<PageEntry>,
pub memory_pages: Vec<PageEntry>,
pub disk_size: u64,
pub memory_size: u64,
}Expand description
Top-level index stored at the end of a snapshot file.
The master index is the entry point for all random access operations. It contains separate page directories for disk and memory streams, plus logical size metadata for each stream.
§Structure
- disk_pages: Index entries for the disk stream (persistent storage)
- memory_pages: Index entries for the memory stream (volatile state)
- disk_size: Total logical size of disk stream (uncompressed bytes)
- memory_size: Total logical size of memory stream (uncompressed bytes)
§Location
The master index is always stored at the end of the snapshot file. Its offset
is recorded in the snapshot header (header.index_offset).
§Serialization
Serialized using bincode. Typical size: ~1KB per 1GB of data (with 64KB pages).
§Random Access Algorithm
To read from disk stream at offset O:
1. page_idx = binary_search(master.disk_pages, |p| p.start_logical.cmp(&O))
2. page = read_and_deserialize(page_entry[page_idx])
3. block_info = find_block_in_page(page, O)
4. compressed = backend.read_exact(block_info.offset, block_info.length)
5. data = decompress(compressed)
6. return extract_range(data, O, len)§Dual Streams
Disk and memory streams are independently indexed. This enables:
- VM snapshots (disk = disk image, memory = RAM dump)
- Application snapshots (disk = state, memory = heap)
- Separate compression tuning per stream
§Examples
use hexz_core::format::index::{MasterIndex, PageEntry};
let master = MasterIndex {
disk_pages: vec![
PageEntry {
offset: 4096,
length: 65536,
start_block: 0,
start_logical: 0,
}
],
memory_pages: vec![],
disk_size: 1_000_000_000, // 1GB logical
memory_size: 0,
};
println!("Disk stream: {} GB", master.disk_size / (1024 * 1024 * 1024));
println!("Index pages: {}", master.disk_pages.len());Fields§
§disk_pages: Vec<PageEntry>Index pages for the disk stream.
memory_pages: Vec<PageEntry>Index pages for the memory stream.
disk_size: u64Total logical size of the disk stream (uncompressed bytes).
memory_size: u64Total logical size of the memory stream (uncompressed bytes).
Implementations§
Trait Implementations§
Source§impl Clone for MasterIndex
impl Clone for MasterIndex
Source§fn clone(&self) -> MasterIndex
fn clone(&self) -> MasterIndex
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MasterIndex
impl Debug for MasterIndex
Source§impl Default for MasterIndex
impl Default for MasterIndex
Source§fn default() -> MasterIndex
fn default() -> MasterIndex
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for MasterIndex
impl<'de> Deserialize<'de> for MasterIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for MasterIndex
impl RefUnwindSafe for MasterIndex
impl Send for MasterIndex
impl Sync for MasterIndex
impl Unpin for MasterIndex
impl UnsafeUnpin for MasterIndex
impl UnwindSafe for MasterIndex
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more