pub trait IndexMapping:
Clone
+ Send
+ Sync {
// Required methods
fn index(&self, value: f64) -> i32;
fn value(&self, index: i32) -> f64;
fn lower_bound(&self, index: i32) -> f64;
fn relative_accuracy(&self) -> f64;
fn min_indexable_value(&self) -> f64;
fn max_indexable_value(&self) -> f64;
fn gamma(&self) -> f64;
fn index_offset(&self) -> f64;
fn interpolation(&self) -> Interpolation;
fn validate_proto_mapping(
&self,
proto: &ProtoIndexMapping,
) -> Result<(), ProtoConversionError>;
fn to_proto(&self) -> ProtoIndexMapping;
}Expand description
Maps values to bin indices and vice versa.
The mapping defines the relationship between floating-point values and integer bin indices, determining the relative accuracy of the sketch.
Required Methods§
Sourcefn index(&self, value: f64) -> i32
fn index(&self, value: f64) -> i32
Returns the index of the bin for the given positive value.
The value must be positive. For negative values, use the index of the absolute value and store in the negative store.
Sourcefn value(&self, index: i32) -> f64
fn value(&self, index: i32) -> f64
Returns the representative value for the given index.
This is typically the geometric mean of the bin’s lower and upper bounds.
Sourcefn lower_bound(&self, index: i32) -> f64
fn lower_bound(&self, index: i32) -> f64
Returns the lower bound of the bin at the given index.
Sourcefn relative_accuracy(&self) -> f64
fn relative_accuracy(&self) -> f64
Returns the relative accuracy of this mapping.
The relative accuracy is the maximum relative error guaranteed for any quantile query.
Sourcefn min_indexable_value(&self) -> f64
fn min_indexable_value(&self) -> f64
Returns the minimum positive value that can be indexed.
Sourcefn max_indexable_value(&self) -> f64
fn max_indexable_value(&self) -> f64
Returns the maximum positive value that can be indexed.
Sourcefn index_offset(&self) -> f64
fn index_offset(&self) -> f64
Returns the index offset used by this mapping.
The index offset shifts all bin indices by a constant value.
Sourcefn interpolation(&self) -> Interpolation
fn interpolation(&self) -> Interpolation
Returns the interpolation mode used by this mapping.
The interpolation mode determines how the logarithm is approximated.
Sourcefn validate_proto_mapping(
&self,
proto: &ProtoIndexMapping,
) -> Result<(), ProtoConversionError>
fn validate_proto_mapping( &self, proto: &ProtoIndexMapping, ) -> Result<(), ProtoConversionError>
Validates that a protobuf IndexMapping is compatible with this mapping.
§Errors
If the given protobuf mapping parameters do not match this mapping’s configuration, an error describing the mismatch is returned.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.