All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.redis.datasource.topk.TopKCommands Maven / Gradle / Ivy

There is a newer version: 3.17.5
Show newest version
package io.quarkus.redis.datasource.topk;

import java.util.List;
import java.util.Map;
import java.util.Optional;

import io.quarkus.redis.datasource.RedisCommands;

/**
 * Allows executing commands from the {@code top-k} group.
 * These commands require the Redis Bloom module (this modules also
 * include Top-K list support) to be installed in the Redis server.
 * 

* See the top-k command list for further information about * these commands. *

* * @param the type of the key * @param the type of the value stored in the sketch */ public interface TopKCommands extends RedisCommands { /** * Execute the command TOPK.ADD. * Summary: 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. * Group: top-k *

* * @param key the name of list where item is added, must not be {@code null} * @param item the item to add, must not be {@code null} * @return an optional containing the item that get expelled if any, empty otherwise */ Optional topkAdd(K key, V item); /** * Execute the command TOPK.ADD. * Summary: 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. * Group: top-k *

* * @param key the name of list where item is added, must not be {@code null} * @param items the items to add, must not be {@code null}, must not be empty, must not contain {@code null} * @return a list containing for each corresponding added item the expelled item if any, * {@code null} otherwise. */ List topkAdd(K key, V... items); /** * Execute the command TOPK.INCRBY. * Summary: 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. * Group: top-k *

* * @param key the name of list where item is added, must not be {@code null} * @param item the item to add, must not be {@code null} * @param increment increment to current item score. Increment must be greater or equal to 1. Increment is * limited to 100,000 to avoid server freeze. * @return an optional containing the item that get expelled if any, empty otherwise */ Optional topkIncrBy(K key, V item, int increment); /** * Execute the command TOPK.INCRBY. * Summary: 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. * Group: top-k *

* * @param key the name of list where item is added, must not be {@code null} * @param couples The map containing the item / increment, must not be {@code null}, must not be empty * @return a map containing for each added item the expelled item if any, {@code null} otherwise */ Map topkIncrBy(K key, Map couples); /** * Execute the command TOPK.LIST. * Summary: Return full list of items in Top K list. * Group: top-k *

* * @param key the name of list, must not be {@code null} * @return the list of items */ List topkList(K key); /** * Execute the command TOPK.LIST. * Summary: Return full list of items in Top K list. * Group: top-k *

* * @param key the name of list, must not be {@code null} * @return the Map of items with the associated count */ Map topkListWithCount(K key); /** * Execute the command TOPK.QUERY. * Summary: Checks whether an item is one of Top-K items. Multiple items can be checked at once. * Group: top-k *

* * @param key the name of list, must not be {@code null} * @param item the item to check, must not be {@code null} * @return {@code true} if the item is in the list, {@code false} otherwise */ boolean topkQuery(K key, V item); /** * Execute the command TOPK.QUERY. * Summary: Checks whether an item is one of Top-K items. Multiple items can be checked at once. * Group: top-k *

* * @param key the name of list, must not be {@code null} * @param items the items to check, must not be {@code null}, must not contain {@code null}, must not be empty * @return a list containing {@code true} if the corresponding item is in the list, {@code false} * otherwise */ List topkQuery(K key, V... items); /** * Execute the command TOPK.RESERVE. * Summary: Initializes a TopK with specified parameters. * Group: top-k *

* * @param key the name of list, must not be {@code null} * @param topk the number of top occurring items to keep. */ void topkReserve(K key, int topk); /** * Execute the command TOPK.RESERVE. * Summary: Initializes a TopK with specified parameters. * Group: top-k *

* * @param key the name of list, must not be {@code null} * @param topk the number of top occurring items to keep. * @param width the number of counters kept in each array. (Default 8) * @param depth the number of arrays. (Default 7) * @param 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) */ void topkReserve(K key, int topk, int width, int depth, double decay); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy