Options
All
  • Public
  • Public/Protected
  • All
Menu

Class TopKFilter

TopK filter

Hierarchy

Index

Constructors

constructor

Properties

Protected Readonly client

client: Red

name

name: string

Protected Readonly options

options: Options

Methods

add

  • add(item: any, increment?: number): Promise<any>
  • Add an item to the filter

    Parameters

    • item: any

      Item

    • Default value increment: number = 1

      Increment

    Returns Promise<any>

    null if no change occurred, item dropped from the filter otherwise

connect

  • connect(): Promise<void>

count

  • count(item: any): Promise<number>
  • Count the number of occurrences an item may be in the filter. Because this is a probabilistic data structure, this may not necessarily be accurate.

    Parameters

    • item: any

      Item

    Returns Promise<number>

    The number of occurrences of item

disconnect

  • disconnect(): Promise<void>

exists

  • exists(item: any): Promise<number>
  • Check if an item already exists in the filter

    Parameters

    • item: any

      Item

    Returns Promise<number>

    1 if item may exist, 0 if item certainly does not exist

list

  • list(): Promise<string[]>
  • Get full list of items in the filter

    Returns Promise<string[]>

    Full list of items in the filter

reserve

  • reserve(topk: number, width: number, depth: number, decay: number): Promise<string>
  • Initialize the filter

    Parameters

    • topk: number

      The number of top items to keep

    • width: number

      The number of counter in each array

    • depth: number

      The number of counter-arrays

    • decay: number

      The probability of reducing a counter in an occupied bucket

    Returns Promise<string>

    OK on success, error otherwise

reset

  • reset(): Promise<number>