pub struct ShardBits(/* private fields */);Expand description
The number of leading key hash bits that select the shard, i.e. a family has 2^bits shards.
Implementations§
Source§impl ShardBits
impl ShardBits
Sourcepub const fn new(bits: u8) -> Self
pub const fn new(bits: u8) -> Self
Panics if bits exceeds ShardBits::MAX.
Sourcepub fn try_new(bits: u8) -> Option<Self>
pub fn try_new(bits: u8) -> Option<Self>
Returns None if bits exceeds ShardBits::MAX.
Sourcepub fn range(self, index: u32) -> RangeInclusive<u64> ⓘ
pub fn range(self, index: u32) -> RangeInclusive<u64> ⓘ
Returns the range of key hashes in the shard index.
Sourcepub fn maybe_reshard(self, bytes: u64, target_shard_size: u64) -> Self
pub fn maybe_reshard(self, bytes: u64, target_shard_size: u64) -> Self
Computes the shard bits for a family with size bytes, targeting a shard size and using
self bits already.
The shard count only doubles once shards hold more than 1.5 times target_shard_size, and
only halves once they hold less than half of it to prevent resharding around a threshold.
Sourcepub fn maybe_grow(self, bytes: u64, target_shard_size: u64) -> Self
pub fn maybe_grow(self, bytes: u64, target_shard_size: u64) -> Self
Like Self::maybe_reshard, but never shrinks.
Trait Implementations§
impl Copy for ShardBits
impl Eq for ShardBits
Source§impl Ord for ShardBits
impl Ord for ShardBits
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for ShardBits
impl PartialOrd for ShardBits
impl StructuralPartialEq for ShardBits
Auto Trait Implementations§
impl Freeze for ShardBits
impl RefUnwindSafe for ShardBits
impl Send for ShardBits
impl Sync for ShardBits
impl Unpin for ShardBits
impl UnsafeUnpin for ShardBits
impl UnwindSafe for ShardBits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more