Trait rustis::commands::TopKCommands
source · pub trait TopKCommands {
fn topk_add<I: Into<CommandArg>, R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>,
items: impl SingleArgOrCollection<I>
) -> PreparedCommand<'_, Self, RR>
where
Self: Sized,
{ ... }
fn topk_incrby<I: Into<CommandArg>, R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>,
items: impl KeyValueArgOrCollection<I, i64>
) -> PreparedCommand<'_, Self, RR>
where
Self: Sized,
{ ... }
fn topk_info(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, TopKInfoResult>
where
Self: Sized,
{ ... }
fn topk_list<R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, RR>
where
Self: Sized,
{ ... }
fn topk_list_with_count<R: FromValue, RR: FromSingleValueArray<(R, usize)>>(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, RR>
where
Self: Sized,
{ ... }
fn topk_query<I: Into<CommandArg>, R: FromSingleValueArray<bool>>(
&mut self,
key: impl Into<CommandArg>,
items: impl SingleArgOrCollection<I>
) -> PreparedCommand<'_, Self, R>
where
Self: Sized,
{ ... }
fn topk_reserve(
&mut self,
key: impl Into<CommandArg>,
topk: usize,
width_depth_decay: Option<(usize, usize, f64)>
) -> PreparedCommand<'_, Self, ()>
where
Self: Sized,
{ ... }
}Available on crate feature
redis-bloom only.Expand description
Provided Methods§
sourcefn topk_add<I: Into<CommandArg>, R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>,
items: impl SingleArgOrCollection<I>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
fn topk_add<I: Into<CommandArg>, R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>,
items: impl SingleArgOrCollection<I>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
Adds an item to the data structure.
Multiple items can be added at once. If an item enters the Top-K list, the item which is expelled is returned. This allows dynamic heavy-hitter detection of items being entered or expelled from Top-K list.
Arguments
key- Name of sketch where item is added.items- Item/s to be added.
Return
Collection of items if an element was dropped from the TopK list, Null reply otherwise.
See Also
sourcefn topk_incrby<I: Into<CommandArg>, R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>,
items: impl KeyValueArgOrCollection<I, i64>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
fn topk_incrby<I: Into<CommandArg>, R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>,
items: impl KeyValueArgOrCollection<I, i64>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
Increase the score of an item in the data structure by increment.
Multiple items’ score can be increased at once. If an item enters the Top-K list, the item which is expelled is returned.
Arguments
key- Name of sketch where item is added.items- collection of tuples:item- Item to be addedincrement- increment to current item score.
Increment must be greater or equal to 1.
Increment is limited to 100,000 to avoid server freeze.
Return
Collection of items if an element was dropped from the TopK list, Null reply otherwise.
See Also
sourcefn topk_info(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, TopKInfoResult>where
Self: Sized,
fn topk_info(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, TopKInfoResult>where
Self: Sized,
Returns number of required items (k), width, depth and decay values.
Arguments
key- Name of sketch
Return
An instance of TopKInfoResult
See Also
sourcefn topk_list<R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
fn topk_list<R: FromValue, RR: FromSingleValueArray<R>>(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
sourcefn topk_list_with_count<R: FromValue, RR: FromSingleValueArray<(R, usize)>>(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
fn topk_list_with_count<R: FromValue, RR: FromSingleValueArray<(R, usize)>>(
&mut self,
key: impl Into<CommandArg>
) -> PreparedCommand<'_, Self, RR>where
Self: Sized,
sourcefn topk_query<I: Into<CommandArg>, R: FromSingleValueArray<bool>>(
&mut self,
key: impl Into<CommandArg>,
items: impl SingleArgOrCollection<I>
) -> PreparedCommand<'_, Self, R>where
Self: Sized,
fn topk_query<I: Into<CommandArg>, R: FromSingleValueArray<bool>>(
&mut self,
key: impl Into<CommandArg>,
items: impl SingleArgOrCollection<I>
) -> PreparedCommand<'_, Self, R>where
Self: Sized,
sourcefn topk_reserve(
&mut self,
key: impl Into<CommandArg>,
topk: usize,
width_depth_decay: Option<(usize, usize, f64)>
) -> PreparedCommand<'_, Self, ()>where
Self: Sized,
fn topk_reserve(
&mut self,
key: impl Into<CommandArg>,
topk: usize,
width_depth_decay: Option<(usize, usize, f64)>
) -> PreparedCommand<'_, Self, ()>where
Self: Sized,
Initializes a TopK with specified parameters.
Arguments
key- Key under which the sketch is to be found.topk- Number of top occurring items to keep.width_depth_decay- Optional paramaters:width- Number of counters kept in each array. (Default 8)depth- Number of arrays. (Default 7)decay- The probability of reducing a counter in an occupied bucket.
It is raised to power of it’s counter (decay ^ bucket[i].counter).
Therefore, as the counter gets higher, the chance of a reduction is being reduced. (Default 0.9)