Component Deep Dive: src/entry.rs
The entry module defines the smallest logical unit handled by the storage engine: a single columnar value augmented with optional metadata fields. Entries are aggregated into Pages and constitute the payload manipulated by higher-level operations.
Source Snapshot
src/entry.rs
5 pub fn current_epoch_millis() -> u64 { … }
12 #[derive(Serialize, Deserialize, Clone)]
13 pub struct Entry { prefix_meta, data, suffix_meta }
19 impl Entry { pub fn new(data: &str) -> Self { … } }
Responsibilities
┌────────────────────────────────────────────┐
│ Entry │
│ - Immutable columnar value wrapper │
│ - Serializable via Serde │
│ - Used inside Page::entries │
└────────────────────────────────────────────┘
-
Logical Value Carrier
Entryencapsulates the raw string data associated with a single row/column intersection. The surrounding metadata fields (prefix_meta,suffix_meta) are placeholders for future bookkeeping (compression hints, digests, etc.). -
Serialization Compatibility
The derive macros (Serialize,Deserialize,Clone) guarantee thatEntrycan be persisted and resurrected viabincode, which underpins the compressor, WAL, and eventual page durability. -
Timestamp Utility
current_epoch_millis()exposes a monotonic timestamp used elsewhere for LRU eviction (PageCache) and MVCC bookkeeping (TableMetaStore). Centralizing this helper in theentrymodule avoids circular dependencies.
Memory Layout
Entry
├─ prefix_meta : String (reserved for future use)
├─ data : String (user payload)
└─ suffix_meta : String (reserved for trailing metadata)
In memory, each Entry owns three String allocations. Compression and serialization shrink and merge these allocations when persisted inside a Page.
Lifecycle
create Entry::new(data)
│
▼
Page::add_entry pushes Entry into Vec<Entry>
│
▼
Page serialized via bincode
│
▼
Compressor applies LZ4
│
▼
Stored in CPC / disk as part of a Page blob
Interactions
Page(src/page.rs) owns aVec<Entry>and uses direct push semantics for appends and updates.ops_handlerusesEntry::newto materialize both new rows and updated values when mutating pages.- Future WAL/compaction layers will treat
Entryas the leaf node of the storage structure.
Extensibility Notes
- The placeholder metadata fields allow seamless evolution toward richer value envelopes (e.g., checksum, encoding hints) without changing external APIs.
- Consider making
Entryfields public or providing accessors once per-entry inspection becomes necessary for predicate pushdown or indexing.