diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-11-21 14:47:20 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-11-21 14:47:20 +0200 |
| commit | f759208ae41a5bbeb163fda4b66f43b8c0e84b2b (patch) | |
| tree | 10ac7d07e39b2437ca4ccb6b0f5123f8c64d3338 /log_db/src/memtable_primary.rs | |
| parent | a01b696134e56d0e0a57cb5ff6c6dcb5914d05bb (diff) | |
Revert "Refresh indexes on read or at maintenance"
This reverts commit bfa8fab553eab1b0daa062010fb2ccf5d365d21f.
Diffstat (limited to 'log_db/src/memtable_primary.rs')
| -rw-r--r-- | log_db/src/memtable_primary.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/log_db/src/memtable_primary.rs b/log_db/src/memtable_primary.rs index 8340cdd..9d7e1e8 100644 --- a/log_db/src/memtable_primary.rs +++ b/log_db/src/memtable_primary.rs @@ -2,9 +2,14 @@ use super::common::*; use std::collections::BTreeMap; pub struct PrimaryMemtable { - /// Map of record locations indexed by key. Use the `LogKey` values to look up - /// the actual records in the log files. - records: BTreeMap<IndexableValue, LogKey>, + /// Map of records indexed by key. Used as a shared heap of records + /// for all secondary memtables also. Secondary memtables store an + /// IndexableValue as their record value, which is used to get + /// the actual record from the primary memtable `records` map. + /// + /// Note: it must be invariant that all memtables (primary and secondary) + /// contain the same keys. + records: BTreeMap<IndexableValue, Record>, } impl PrimaryMemtable { @@ -14,11 +19,15 @@ impl PrimaryMemtable { } } - pub fn set(&mut self, key: &IndexableValue, value: &LogKey) { + pub fn set(&mut self, key: &IndexableValue, value: &Record) { self.records.insert(key.clone(), value.clone()); } - pub fn get(&self, key: &IndexableValue) -> Option<&LogKey> { + pub fn get(&mut self, key: &IndexableValue) -> Option<&Record> { + self.records.get(key) + } + + pub fn get_without_update(&self, key: &IndexableValue) -> Option<&Record> { self.records.get(key) } } |
