fix up refcounts on disk bucket test (#31001)
This commit is contained in:
parent
8a96b91515
commit
fc2bcdffe2
|
@ -170,6 +170,7 @@ fn read_be_u64(input: &[u8]) -> u64 {
|
||||||
mod tests {
|
mod tests {
|
||||||
use {
|
use {
|
||||||
super::*,
|
super::*,
|
||||||
|
crate::index_entry::MAX_LEGAL_REFCOUNT,
|
||||||
rand::{thread_rng, Rng},
|
rand::{thread_rng, Rng},
|
||||||
std::{collections::HashMap, sync::RwLock},
|
std::{collections::HashMap, sync::RwLock},
|
||||||
};
|
};
|
||||||
|
@ -365,7 +366,18 @@ mod tests {
|
||||||
let v = (0..count)
|
let v = (0..count)
|
||||||
.map(|x| (x as usize, x as usize /*thread_rng().gen::<usize>()*/))
|
.map(|x| (x as usize, x as usize /*thread_rng().gen::<usize>()*/))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let rc = thread_rng().gen_range(0, RefCount::MAX >> 2);
|
let range = thread_rng().gen_range(0, 100);
|
||||||
|
// pick ref counts that are useful and common
|
||||||
|
let rc = if range < 50 {
|
||||||
|
1
|
||||||
|
} else if range < 60 {
|
||||||
|
0
|
||||||
|
} else if range < 70 {
|
||||||
|
2
|
||||||
|
} else {
|
||||||
|
thread_rng().gen_range(0, MAX_LEGAL_REFCOUNT)
|
||||||
|
};
|
||||||
|
|
||||||
(v, rc)
|
(v, rc)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ pub struct IndexEntry<T: 'static> {
|
||||||
_phantom: PhantomData<&'static T>,
|
_phantom: PhantomData<&'static T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 62 bits available for ref count
|
||||||
|
pub(crate) const MAX_LEGAL_REFCOUNT: RefCount = RefCount::MAX >> 2;
|
||||||
|
|
||||||
/// hold a big `RefCount` while leaving room for extra bits to be used for things like 'Occupied'
|
/// hold a big `RefCount` while leaving room for extra bits to be used for things like 'Occupied'
|
||||||
#[bitfield(bits = 64)]
|
#[bitfield(bits = 64)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
|
|
Loading…
Reference in New Issue