aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorJan Tuomi <jan@jantuomi.fi>2024-10-02 12:43:30 +0300
committerJan Tuomi <jan@jantuomi.fi>2024-10-02 12:43:30 +0300
commit8dce4fbbaaf373a5a6c6b02e311a7d8f25cf66c3 (patch)
treee171e1a44c357830040ca6d92521367f9dc49260 /src/lib.rs
parent7b84f3676b37a85e84b1364e5252283b16f4cb8b (diff)
Add test, small improvements
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 4afeb4c..3b249d8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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]