Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Dec 3, 2023
1 parent b8ba9da commit 39b7284
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/batch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ impl Batch {
item.seqno = batch_seqno;
}

let bytes_written = shard.write_batch(&self.data.iter().collect())?;
let items = self.data.iter().collect::<Vec<_>>();
let bytes_written = shard.write_batch(&items)?;
shard.flush()?;

let memtable_size = self
Expand Down
4 changes: 2 additions & 2 deletions src/journal/shard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ impl JournalShard {

/// Appends a single item wrapped in a batch to the commit log
pub(crate) fn write(&mut self, item: &Value) -> crate::Result<usize> {
self.write_batch(&vec![item])
self.write_batch(&[item])
}

pub fn write_batch(&mut self, items: &Vec<&Value>) -> crate::Result<usize> {
pub fn write_batch(&mut self, items: &[&Value]) -> crate::Result<usize> {
// NOTE: entries.len() is surely never > u32::MAX
#[allow(clippy::cast_possible_truncation)]
let item_count = items.len() as u32;
Expand Down
4 changes: 1 addition & 3 deletions src/memtable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ impl MemTable {
/// Inserts an item into the `MemTable`
pub fn insert(&self, entry: Value) {
let key = ParsedInternalKey::new(entry.key, entry.seqno, entry.is_tombstone);
let value = entry.value;

self.items.insert(key, value);
self.items.insert(key, entry.value);
}
}

Expand Down

0 comments on commit 39b7284

Please sign in to comment.