Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Jan 18, 2024
1 parent 42d9fb9 commit 3302a52
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,17 @@ impl Tree {
#[must_use]
pub fn approximate_len(&self) -> u64 {
let memtable = self.active_memtable.read().expect("lock is poisoned");
let levels = self.levels.read().expect("lock is poisoned");

memtable.len() as u64
+ levels
.get_all_segments_flattened()
.into_iter()
.map(|x| x.metadata.item_count)
.sum::<u64>()
let item_count_segments = self
.levels
.read()
.expect("lock is poisoned")
.get_all_segments_flattened()
.into_iter()
.map(|x| x.metadata.item_count)
.sum::<u64>();

memtable.len() as u64 + item_count_segments
}

/// Returns the approximate size of the active memtable in bytes.
Expand Down

0 comments on commit 3302a52

Please sign in to comment.