Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CuckooFilter

Cuckoo filter

Hierarchy

Index

Constructors

constructor

Properties

Protected Readonly client

client: Red

name

name: string

Protected Readonly options

options: Options

Methods

add

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

    Parameters

    • item: any

      Item

    • Default value notExistsOnly: boolean = true

      Whether to accept duplicates

    Returns Promise<number>

    1 if item was newly added, 0 if item already exists and notExistsOnly is true, error 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

remove

  • remove(item: any): Promise<number>
  • Remove an occurrence of an item from the filter. Remove elements that are not in the filter may delete a different item, resulting in false negatives!

    Parameters

    • item: any

      Item

    Returns Promise<number>

    1 if item has been removed, 0 if item was not found

reserve

  • reserve(capacity: number, bucketSize?: number, maxIterations?: number, expansionRate?: number): Promise<string>
  • Reserve space for the filter

    Parameters

    • capacity: number

      Estimated capacity for the filter

    • Default value bucketSize: number = 2

      Number of items in each bucket

    • Default value maxIterations: number = 20

      Number of attempts to swap buckets before declaring filter as full and creating an additional filter

    • Default value expansionRate: number = 1

      Expansion rate

    Returns Promise<string>

    OK on success, error otherwise

reset

  • reset(): Promise<number>