AcctIdx: cleanup (#20443)
This commit is contained in:
committed by
GitHub
parent
7783030437
commit
71ec05e2f6
@ -315,10 +315,10 @@ impl<T: Clone + Copy> Bucket<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn grow_index(&self, current_capacity: u8) {
|
pub fn grow_index(&self, current_capacity_pow2: u8) {
|
||||||
if self.index.capacity_pow2 == current_capacity {
|
if self.index.capacity_pow2 == current_capacity_pow2 {
|
||||||
let mut m = Measure::start("grow_index");
|
let mut m = Measure::start("grow_index");
|
||||||
//debug!("GROW_INDEX: {}", current_capacity);
|
//debug!("GROW_INDEX: {}", current_capacity_pow2);
|
||||||
let increment = 1;
|
let increment = 1;
|
||||||
for i in increment.. {
|
for i in increment.. {
|
||||||
//increasing the capacity by ^4 reduces the
|
//increasing the capacity by ^4 reduces the
|
||||||
@ -408,10 +408,10 @@ impl<T: Clone + Copy> Bucket<T> {
|
|||||||
|
|
||||||
/// grow a data bucket
|
/// grow a data bucket
|
||||||
/// The application of the new bucket is deferred until the next write lock.
|
/// 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(
|
let new_bucket = self.index.grow(
|
||||||
self.data.get(data_index as usize),
|
self.data.get(data_index as usize),
|
||||||
current_capacity + 1,
|
current_capacity_pow2 + 1,
|
||||||
1 << data_index,
|
1 << data_index,
|
||||||
Self::elem_size(),
|
Self::elem_size(),
|
||||||
);
|
);
|
||||||
@ -437,13 +437,13 @@ impl<T: Clone + Copy> Bucket<T> {
|
|||||||
/// The actual grow is set into self.reallocated and applied later on a write lock
|
/// The actual grow is set into self.reallocated and applied later on a write lock
|
||||||
pub fn grow(&self, err: BucketMapError) {
|
pub fn grow(&self, err: BucketMapError) {
|
||||||
match err {
|
match err {
|
||||||
BucketMapError::DataNoSpace((data_index, current_capacity)) => {
|
BucketMapError::DataNoSpace((data_index, current_capacity_pow2)) => {
|
||||||
//debug!("GROWING SPACE {:?}", (data_index, current_capacity));
|
//debug!("GROWING SPACE {:?}", (data_index, current_capacity_pow2));
|
||||||
self.grow_data(data_index, current_capacity);
|
self.grow_data(data_index, current_capacity_pow2);
|
||||||
}
|
}
|
||||||
BucketMapError::IndexNoSpace(current_capacity) => {
|
BucketMapError::IndexNoSpace(current_capacity_pow2) => {
|
||||||
//debug!("GROWING INDEX {}", sz);
|
//debug!("GROWING INDEX {}", sz);
|
||||||
self.grow_index(current_capacity);
|
self.grow_index(current_capacity_pow2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,9 @@ impl<T: Clone + Copy + Debug> std::fmt::Debug for BucketMap<T> {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum BucketMapError {
|
pub enum BucketMapError {
|
||||||
|
/// (bucket_index, current_capacity_pow2)
|
||||||
DataNoSpace((u64, u8)),
|
DataNoSpace((u64, u8)),
|
||||||
|
/// current_capacity_pow2
|
||||||
IndexNoSpace(u8),
|
IndexNoSpace(u8),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user