Skip to content

CuckooFilter

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:86

A cuckoo filter: a set with a tunable false-positive rate, zero false negatives, and delete. Keys are stored as short fingerprints in one of two candidate buckets (Fan et al., “Cuckoo Filter: Practically Better Than Bloom”, 2014).

new CuckooFilter(__namedParameters): CuckooFilter

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:257

Constructs a filter from CuckooParams.

CuckooParams

CuckooFilter

ParamError if a setting is invalid.

get bitsPerKey(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:521

Slot bits per expected key, m / n.

number


get buckets(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:506

Number of 4-slot buckets.

number


get capacity(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:501

Slots in the table, 4 * buckets.

number


get count(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:496

Fingerprints stored, one per add not undone by a delete.

number


get epsilon(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:531

Target false-positive rate at n keys.

number


get fingerprintBits(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:511

Width of each stored fingerprint, in bits.

number


get m(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:516

Total slot bits, fingerprintBits * capacity.

number


get seed(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:526

Hash seed.

number

add(key): void

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:281

Adds key. Every call stores a fingerprint, including for a key already present, so each add needs its own delete.

BytesLike

void

CuckooFullError if the filter has no room for it.


delete(key): boolean

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:341

Removes one copy of key: the first slot holding its fingerprint in either candidate bucket.

Only delete keys you added. A key never added can share a fingerprint and bucket with one that was, and deleting it removes that key’s fingerprint instead, a false negative the filter cannot detect: it stores fingerprints, not keys, so it cannot tell the two apart.

BytesLike

boolean

true if a matching fingerprint was removed; false, with the filter unchanged, if there was none.


equals(other): boolean

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:409

Whether other holds the same settings and slots, so the two serialize to identical bytes. Which slot a key lands in depends on insertion order, so filters holding the same keys can still differ.

CuckooFilter

The filter to compare against.

boolean

true if the two are indistinguishable.


has(key): boolean

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:356

Tests whether key may be in the filter.

BytesLike

boolean

false if key is definitely absent; true if it was added (and not deleted) or on a false positive.


rate(): number

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:370

Estimates the current false-positive rate from the load: a query compares its fingerprint against about 8 * count / capacity occupied slots across its two buckets, each matching with probability 1 / (2^f - 1).

number

The estimated false-positive rate, 0 for an empty filter.


toBytes(): Uint8Array

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:381

Serializes the filter to a DSTL type 7 frame, readable by CuckooFilter.fromBytes and by any reader of the documented format.

Uint8Array

The frame bytes.


toJSON(): FilterJSON

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:428

Serializes the filter as a JSON envelope around its CuckooFilter.toBytes frame.

FilterJSON

The JSON-safe envelope.


static create(n, epsilon, options?): CuckooFilter

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:108

Creates a filter sized for n expected keys at a target false-positive rate.

number

Expected number of keys.

number

Target false-positive rate, e.g. 0.01 for 1%.

CuckooOptions = {}

Optional seed.

CuckooFilter

A new, empty filter.


static from(keys, epsilon, options?): CuckooFilter

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:126

Builds a filter from the given keys; duplicates are ignored. It is sized for the distinct keys at the target false-positive rate, and holds each once, so a key listed twice needs one delete.

Iterable<BytesLike>

The keys to insert.

number

Target false-positive rate, e.g. 0.01 for 1%.

CuckooOptions = {}

Optional seed.

CuckooFilter

A new filter containing every key.


static fromBytes(bytes): CuckooFilter

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:161

Restores a filter from its CuckooFilter.toBytes serialization.

Uint8Array

The serialized filter.

CuckooFilter

The reconstructed filter.


static fromJSON(value): CuckooFilter

Defined in: packages/distillate/src/cuckoo/cuckoo.ts:248

Restores a filter from its CuckooFilter.toJSON envelope.

unknown

The parsed JSON envelope.

CuckooFilter

The reconstructed filter.