Interface TopKCommands<K,V>

Type Parameters:
K - the type of the key
V - the type of the value stored in the sketch
All Superinterfaces:
RedisCommands
All Known Implementing Classes:
BlockingTopKCommandsImpl

public interface TopKCommands<K,V> extends RedisCommands
Allows executing commands from the 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.

  • Method Details

    • topkAdd

      Optional<V> 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

      Parameters:
      key - the name of list where item is added, must not be null
      item - the item to add, must not be null
      Returns:
      an optional containing the item that get expelled if any, empty otherwise
    • topkAdd

      List<V> topkAdd(K key, V... items)
      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

      Parameters:
      key - the name of list where item is added, must not be null
      items - the items to add, must not be null, must not be empty, must not contain null
      Returns:
      a list containing for each corresponding added item the expelled item if any, null otherwise.
    • topkIncrBy

      Optional<V> 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

      Parameters:
      key - the name of list where item is added, must not be null
      item - the item to add, must not be null
      increment - increment to current item score. Increment must be greater or equal to 1. Increment is limited to 100,000 to avoid server freeze.
      Returns:
      an optional containing the item that get expelled if any, empty otherwise
    • topkIncrBy

      Map<V,V> topkIncrBy(K key, Map<V,Integer> couples)
      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

      Parameters:
      key - the name of list where item is added, must not be null
      couples - The map containing the item / increment, must not be null, must not be empty
      Returns:
      a map containing for each added item the expelled item if any, null otherwise
    • topkList

      List<V> topkList(K key)
      Execute the command TOPK.LIST. Summary: Return full list of items in Top K list. Group: top-k

      Parameters:
      key - the name of list, must not be null
      Returns:
      the list of items
    • topkListWithCount

      Map<V,Integer> topkListWithCount(K key)
      Execute the command TOPK.LIST. Summary: Return full list of items in Top K list. Group: top-k

      Parameters:
      key - the name of list, must not be null
      Returns:
      the Map of items with the associated count
    • topkQuery

      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

      Parameters:
      key - the name of list, must not be null
      item - the item to check, must not be null
      Returns:
      true if the item is in the list, false otherwise
    • topkQuery

      List<Boolean> topkQuery(K key, V... items)
      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

      Parameters:
      key - the name of list, must not be null
      items - the items to check, must not be null, must not contain null, must not be empty
      Returns:
      a list containing true if the corresponding item is in the list, false otherwise
    • topkReserve

      void topkReserve(K key, int topk)
      Execute the command TOPK.RESERVE. Summary: Initializes a TopK with specified parameters. Group: top-k

      Parameters:
      key - the name of list, must not be null
      topk - the number of top occurring items to keep.
    • topkReserve

      void topkReserve(K key, int topk, int width, int depth, double decay)
      Execute the command TOPK.RESERVE. Summary: Initializes a TopK with specified parameters. Group: top-k

      Parameters:
      key - the name of list, must not be null
      topk - the number of top occurring items to keep.
      width - the number of counters kept in each array. (Default 8)
      depth - the 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)