From 71ec05e2f6edd7c8b5b04fb058960888e3447d8e Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Tue, 5 Oct 2021 14:59:08 -0500 Subject: [PATCH] AcctIdx: cleanup (#20443) --- bucket_map/src/bucket.rs | 20 ++++++++++---------- bucket_map/src/bucket_map.rs | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bucket_map/src/bucket.rs b/bucket_map/src/bucket.rs index 61e2275375..f6374ce065 100644 --- a/bucket_map/src/bucket.rs +++ b/bucket_map/src/bucket.rs @@ -315,10 +315,10 @@ impl Bucket { } } - pub fn grow_index(&self, current_capacity: u8) { - if self.index.capacity_pow2 == current_capacity { + pub fn grow_index(&self, current_capacity_pow2: u8) { + if self.index.capacity_pow2 == current_capacity_pow2 { let mut m = Measure::start("grow_index"); - //debug!("GROW_INDEX: {}", current_capacity); + //debug!("GROW_INDEX: {}", current_capacity_pow2); let increment = 1; for i in increment.. { //increasing the capacity by ^4 reduces the @@ -408,10 +408,10 @@ impl Bucket { /// grow a data bucket /// The application of the new bucket is deferred until the next write lock. - pub fn grow_data(&self, data_index: u64, current_capacity: u8) { + pub fn grow_data(&self, data_index: u64, current_capacity_pow2: u8) { let new_bucket = self.index.grow( self.data.get(data_index as usize), - current_capacity + 1, + current_capacity_pow2 + 1, 1 << data_index, Self::elem_size(), ); @@ -437,13 +437,13 @@ impl Bucket { /// The actual grow is set into self.reallocated and applied later on a write lock pub fn grow(&self, err: BucketMapError) { match err { - BucketMapError::DataNoSpace((data_index, current_capacity)) => { - //debug!("GROWING SPACE {:?}", (data_index, current_capacity)); - self.grow_data(data_index, current_capacity); + BucketMapError::DataNoSpace((data_index, current_capacity_pow2)) => { + //debug!("GROWING SPACE {:?}", (data_index, current_capacity_pow2)); + self.grow_data(data_index, current_capacity_pow2); } - BucketMapError::IndexNoSpace(current_capacity) => { + BucketMapError::IndexNoSpace(current_capacity_pow2) => { //debug!("GROWING INDEX {}", sz); - self.grow_index(current_capacity); + self.grow_index(current_capacity_pow2); } } } diff --git a/bucket_map/src/bucket_map.rs b/bucket_map/src/bucket_map.rs index bbc5a86b7a..73668b8a98 100644 --- a/bucket_map/src/bucket_map.rs +++ b/bucket_map/src/bucket_map.rs @@ -53,7 +53,9 @@ impl std::fmt::Debug for BucketMap { #[derive(Debug)] pub enum BucketMapError { + /// (bucket_index, current_capacity_pow2) DataNoSpace((u64, u8)), + /// current_capacity_pow2 IndexNoSpace(u8), }