Skip to content

Commit

Permalink
change approximate_len to usize
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-j97 committed Sep 18, 2024
1 parent a19828e commit 44aa36d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/abstract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub trait AbstractTree {
fn is_first_level_disjoint(&self) -> bool;

/// Approximates the amount of items in the tree.
fn approximate_len(&self) -> u64;
fn approximate_len(&self) -> usize;

/// Returns the disk space usage.
fn disk_space(&self) -> u64;
Expand Down
2 changes: 1 addition & 1 deletion src/blob_tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ impl AbstractTree for BlobTree {
self.index.first_level_segment_count()
}

fn approximate_len(&self) -> u64 {
fn approximate_len(&self) -> usize {
self.index.approximate_len()
}

Expand Down
6 changes: 4 additions & 2 deletions src/tree/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ impl AbstractTree for Tree {
}

#[allow(clippy::significant_drop_tightening)]
fn approximate_len(&self) -> u64 {
fn approximate_len(&self) -> usize {
// NOTE: Mind lock order L -> M -> S
let levels = self.levels.read().expect("lock is poisoned");
let memtable = self.active_memtable.read().expect("lock is poisoned");
Expand All @@ -280,7 +280,9 @@ impl AbstractTree for Tree {
let memtable_count = memtable.len() as u64;
let sealed_count = sealed.iter().map(|(_, mt)| mt.len()).sum::<usize>() as u64;

memtable_count + sealed_count + segments_item_count
(memtable_count + sealed_count + segments_item_count)
.try_into()
.expect("should not be too large")
}

fn disk_space(&self) -> u64 {
Expand Down

0 comments on commit 44aa36d

Please sign in to comment.