aboutsummaryrefslogtreecommitdiffstats
path: root/log_db/src/memtable_primary.rs
blob: 8340cddedda89e226eeaea548fdd8dfaa6a0d9ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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>,
}

impl PrimaryMemtable {
    pub fn new() -> PrimaryMemtable {
        PrimaryMemtable {
            records: BTreeMap::new(),
        }
    }

    pub fn set(&mut self, key: &IndexableValue, value: &LogKey) {
        self.records.insert(key.clone(), value.clone());
    }

    pub fn get(&self, key: &IndexableValue) -> Option<&LogKey> {
        self.records.get(key)
    }
}