Options
All
  • Public
  • Public/Protected
  • All
Menu

A TopK computes the ranking of elements in a multiset (by an arbitrary score) and returns the k results with the highest scores. This implementation of the TopK problem sorts items based on their estimated cardinality in the multiset. It is based on a Count Min Sketch, for estimating the cardinality of items, and a MinHeap, for implementing a sliding window over the k results with the highest scores.

author

Thomas Minier

author

Arnaud Grall

Hierarchy

Index

Properties

_accuracy: number
_errorRate: number
_hashing: Hashing
_heap: MinHeap
_k: number
_rng: prng
_seed: number

Methods

  • add(element: string, count?: number): void
  • Add an element to the TopK

    Parameters

    • element: string

      Element to add

    • count: number = 1

    Returns void

  • clear(): void
  • fromJSON(json: JSON): any
  • Load an Object from a provided JSON object

    Parameters

    • json: JSON

      the JSON object to load

    Returns any

    Return the Object loaded from the provided JSON object

  • Get the top-k values as an iterator that yields objects {value: string, frequency: number, rank: number}. WARNING: With this method, values are produced on-the-fly, hence you should not modify the TopK while the iteration is not completed, otherwise the generated values may not respect the TopK properties.

    Returns Iterator<TopkElement, any, undefined>

    The top-k values as an iterator of object {value: string, frequency: number, rank: number}

  • nextInt32(): number
  • saveAsJSON(): any
  • Get the top-k values as an array of objects {value: string, frequency: number, rank: number}

    Returns TopkElement[]

    The top-k values as an array of objects {value: string, frequency: number, rank: number}

Constructors

  • new TopK(k: number, errorRate: number, accuracy: number): TopK

Accessors

  • Get a function used to draw random number

    Returns prng

    A factory function used to draw random integer

  • get seed(): number
  • set seed(seed: number): void
  • Get the seed used in this structure

    Returns number

  • Set the seed for this structure

    Parameters

    • seed: number

      the new seed that will be used in this structure

    Returns void

Generated using TypeDoc