Options
All
  • Public
  • Public/Protected
  • All
Menu

XOR-Filter for 8-bits and 16-bits fingerprint length.

To use for fixed sets of elements only Inspired from @see https://github.com/FastFilter/fastfilter_java

author

Arnaud GRALL

example
const xor8 = new XorFilter(1) // default fingerprint of 8 bits
xor8.add(['a'])
xor8.has('a') // true
xor8.has('b') // false
const xor16 = new XorFilter(1, 16)
xor16.add(['a'])
xor16.has('a') // true
xor16.has('b') // false

Hierarchy

Index

Properties

ALLOWED_FINGERPRINT_SIZES: number[] = ...
FACTOR_TIMES_100: number = 123
HASHES: number = 3
OFFSET: number = 32
_bits: number = 8

Number of bits per fingerprint

_blockLength: number

Size of each block (filter size / HASHES)

_filter: <internal>.Buffer[]

Buffer array of fingerprints

_hashing: Hashing
_rng: PRNG
_seed: number
_size: number

Number of elements inserted in the filter

Methods

  • _getHash(element: Long, seed: number, index: number): number
  • _getOptimalFilterSize(size: number): number
  • _hash64(element: Long, seed: number): Long
  • _reduce(hash: Long, size: number): number
  • Add elements to the filter, modify the filter in place. Warning: Another call will override the previously created filter.

    example
    const xor = new XorFilter(1, 8)
    xor.add(['alice'])
    xor.has('alice') // true
    xor.has('bob') // false

    Parameters

    Returns 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

  • nextInt32(): number
  • saveAsJSON(): any

Constructors

  • new XorFilter(size: number, bits_per_fingerprint?: 8 | 16): XorFilter

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