pub enum Distribution {
Fixed(f64),
Weighted(HashMap<OrderedFloat, f64>),
}Expand description
Represents a distribution of read fractions in a workload.
Variants§
Fixed(f64)
A single fixed read fraction (e.g. 0.5 means 50% reads).
Weighted(HashMap<OrderedFloat, f64>)
A weighted distribution over multiple read fractions.
Maps read_fraction -> weight (not yet normalized).
Implementations§
Source§impl Distribution
impl Distribution
Sourcepub fn fixed(read_fraction: f64) -> Result<Self>
pub fn fixed(read_fraction: f64) -> Result<Self>
Create a fixed distribution with a single read fraction.
§Errors
Returns an error if read_fraction is not in [0.0, 1.0].
Sourcepub fn weighted(weights: &[(f64, f64)]) -> Result<Self>
pub fn weighted(weights: &[(f64, f64)]) -> Result<Self>
Create a weighted distribution from pairs of
(read_fraction, weight). Validates but does not
normalize; call Distribution::canonicalize for normalization.
§Errors
Returns an error if any fraction is not in [0.0, 1.0], any weight is negative, or the weights slice is empty.
Sourcepub fn canonicalize(&self) -> Result<Canonical>
pub fn canonicalize(&self) -> Result<Canonical>
Canonicalize this distribution into a map of
read_fraction -> probability where probabilities
sum to 1.0. Zero-weight entries are excluded.
§Errors
Returns an error if the total weight is zero (for weighted distributions).
Trait Implementations§
Source§impl Clone for Distribution
impl Clone for Distribution
Source§fn clone(&self) -> Distribution
fn clone(&self) -> Distribution
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Distribution
impl Debug for Distribution
Source§impl PartialEq for Distribution
impl PartialEq for Distribution
Source§fn eq(&self, other: &Distribution) -> bool
fn eq(&self, other: &Distribution) -> bool
self and other values to be equal, and is used by ==.Source§impl TryFrom<f64> for Distribution
Convenience conversions so callers can pass a plain f64.
impl TryFrom<f64> for Distribution
Convenience conversions so callers can pass a plain f64.
Source§impl TryFrom<i32> for Distribution
impl TryFrom<i32> for Distribution
impl StructuralPartialEq for Distribution
Auto Trait Implementations§
impl Freeze for Distribution
impl RefUnwindSafe for Distribution
impl Send for Distribution
impl Sync for Distribution
impl Unpin for Distribution
impl UnsafeUnpin for Distribution
impl UnwindSafe for Distribution
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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