diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2024-10-02 12:43:30 +0300 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2024-10-02 12:43:30 +0300 |
| commit | 8dce4fbbaaf373a5a6c6b02e311a7d8f25cf66c3 (patch) | |
| tree | e171e1a44c357830040ca6d92521367f9dc49260 /src | |
| parent | 7b84f3676b37a85e84b1364e5252283b16f4cb8b (diff) | |
Add test, small improvements
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 8 | ||||
| -rw-r--r-- | src/secondary_memtable.rs | 5 |
2 files changed, 12 insertions, 1 deletions
@@ -224,6 +224,8 @@ impl<Field: Eq + Clone + Debug> DB<Field> { Ok(db) } + /// Insert a record into the database. If the primary key value already exists, + /// the existing record will be replaced by the supplied one. pub fn upsert(&mut self, record: &Record) -> Result<(), io::Error> { debug!("Upserting record: {:?}", record); // Validate the record length @@ -293,7 +295,7 @@ impl<Field: Eq + Clone + Debug> DB<Field> { file.unlock()?; debug!("Record appended to log file, lock released"); - debug!("Updating memtables"); + debug!("Updating primary memtable"); let primary_value = &record.values[self.primary_key_index] @@ -308,6 +310,10 @@ impl<Field: Eq + Clone + Debug> DB<Field> { self.secondary_memtables .iter_mut() .for_each(|secondary_memtable| { + debug!( + "Updating memtable for index on {:?}", + &secondary_memtable.field + ); for (index, (schema_field, _)) in self.config.fields.iter().enumerate() { if schema_field == &secondary_memtable.field { let key = record.values[index] diff --git a/src/secondary_memtable.rs b/src/secondary_memtable.rs index 602db3a..fcf4a7f 100644 --- a/src/secondary_memtable.rs +++ b/src/secondary_memtable.rs @@ -85,9 +85,14 @@ impl<Field: Eq + Clone + Debug> SecondaryMemtable<Field> { match self.records.get_mut(key) { Some(existing) => { + debug!( + "Existing entry found with {} records in the set", + &existing.len() + ); existing.insert(unique_record); } None => { + debug!("No existing entry found, creating one."); let mut set = HashSet::with_capacity(1); set.insert(unique_record); self.records.insert(key.clone(), set); |
