aboutsummaryrefslogtreecommitdiffstats
path: root/log_db/src/memtable_secondary.rs
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2025-01-17 12:34:41 +0200
committerJan Tuomi <jan@jantuomi.fi>2025-01-17 12:34:41 +0200
commitbe5fcde4989ac883201a1895be519f63fa6e6dd4 (patch)
tree11f20d824fb573449908756d4ec7fb50615eda91 /log_db/src/memtable_secondary.rs
parent14b77c5cdfdcb1112deeacba010879037b456020 (diff)
Refactor interfaces to use more moves, remove log_reader_reverse
Diffstat (limited to 'log_db/src/memtable_secondary.rs')
-rw-r--r--log_db/src/memtable_secondary.rs32
1 files changed, 6 insertions, 26 deletions
diff --git a/log_db/src/memtable_secondary.rs b/log_db/src/memtable_secondary.rs
index dc161c8..cd6c252 100644
--- a/log_db/src/memtable_secondary.rs
+++ b/log_db/src/memtable_secondary.rs
@@ -19,14 +19,13 @@ impl SecondaryMemtable {
}
}
- pub fn set(&mut self, key: &IndexableValue, value: &LogKey) {
- match self.records.get_mut(key) {
+ pub fn set(&mut self, key: IndexableValue, value: LogKey) {
+ match self.records.get_mut(&key) {
Some(set) => {
- set.insert(value.clone());
+ set.insert(value);
}
None => {
- self.records
- .insert(key.clone(), LogKeySet::new_with_initial(&value));
+ self.records.insert(key, LogKeySet::new_with_initial(value));
}
};
}
@@ -38,11 +37,6 @@ impl SecondaryMemtable {
}
}
- // Remove all log keys associated with the given key
- pub fn remove_all(&mut self, key: &IndexableValue) -> Option<LogKeySet> {
- self.records.remove(key)
- }
-
// Remove a single log key associated with the given key. Returns `true`
// if the log key existed and was removed, `false` otherwise.
pub fn remove(&mut self, key: &IndexableValue, log_key: &LogKey) -> bool {
@@ -62,24 +56,10 @@ impl SecondaryMemtable {
}
}
- // Remove all log keys associated with the given log key
- // Note: This is a linear time operation, prefer using the `remove` method
- // if you know the secondary key associated with the log key.
- pub fn scan_remove(&mut self, log_key: &LogKey) -> u64 {
- let mut removed = 0;
- self.records.iter_mut().for_each(|(_, set)| {
- if let Ok(_) = set.remove(&log_key) {
- removed += 1;
- }
- });
-
- removed
- }
-
- pub fn range<B: RangeBounds<IndexableValue>>(&self, range: B) -> Vec<LogKey> {
+ pub fn range<B: RangeBounds<IndexableValue>>(&self, range: B) -> Vec<&LogKey> {
let mut keys = Vec::new();
for (_, set) in self.records.range(range) {
- keys.extend(set.log_keys().iter().cloned());
+ keys.extend(set.log_keys().iter());
}
keys
}