IndexMapping

Trait IndexMapping 

Source
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§

Source

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.

Source

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.

Source

fn lower_bound(&self, index: i32) -> f64

Returns the lower bound of the bin at the given index.

Source

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.

Source

fn min_indexable_value(&self) -> f64

Returns the minimum positive value that can be indexed.

Source

fn max_indexable_value(&self) -> f64

Returns the maximum positive value that can be indexed.

Source

fn gamma(&self) -> f64

Returns the gamma value (base of the logarithm) for this mapping.

Source

fn index_offset(&self) -> f64

Returns the index offset used by this mapping.

The index offset shifts all bin indices by a constant value.

Source

fn interpolation(&self) -> Interpolation

Returns the interpolation mode used by this mapping.

The interpolation mode determines how the logarithm is approximated.

Source

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.

Source

fn to_proto(&self) -> ProtoIndexMapping

Converts this mapping to a protobuf IndexMapping.

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.

Implementors§