base/bif/cardinality-counter.bif.zeek

GLOBAL

Functions to create and manipulate probabilistic cardinality counters.

Namespace

GLOBAL

Summary

Functions

hll_cardinality_add: function

Adds an element to a HyperLogLog cardinality counter.

hll_cardinality_copy: function

Copy a HLL cardinality counter.

hll_cardinality_estimate: function

Estimate the current cardinality of an HLL cardinality counter.

hll_cardinality_init: function

Initializes a probabilistic cardinality counter that uses the HyperLogLog algorithm.

hll_cardinality_merge_into: function

Merges a HLL cardinality counter into another.

Detailed Interface

Functions

hll_cardinality_add
Type

function (handle: opaque of cardinality, elem: any) : bool

Adds an element to a HyperLogLog cardinality counter.

Parameters
  • handle – the HLL handle.

  • elem – the element to add.

Returns

true on success.

See also: hll_cardinality_estimate, hll_cardinality_merge_into, hll_cardinality_init, hll_cardinality_copy

hll_cardinality_copy
Type

function (handle: opaque of cardinality) : opaque of cardinality

Copy a HLL cardinality counter.

Parameters

handle – cardinality counter to copy.

Returns

copy of handle.

See also: hll_cardinality_estimate, hll_cardinality_merge_into, hll_cardinality_add, hll_cardinality_init

hll_cardinality_estimate
Type

function (handle: opaque of cardinality) : double

Estimate the current cardinality of an HLL cardinality counter.

Parameters

handle – the HLL handle.

Returns

the cardinality estimate. Returns -1.0 if the counter is empty.

See also: hll_cardinality_merge_into, hll_cardinality_add, hll_cardinality_init, hll_cardinality_copy

hll_cardinality_init
Type

function (err: double, confidence: double) : opaque of cardinality

Initializes a probabilistic cardinality counter that uses the HyperLogLog algorithm.

Parameters
  • err – the desired error rate (e.g. 0.01).

  • confidence – the desired confidence for the error rate (e.g., 0.95).

Returns

a HLL cardinality handle.

See also: hll_cardinality_estimate, hll_cardinality_merge_into, hll_cardinality_add, hll_cardinality_copy

hll_cardinality_merge_into
Type

function (handle1: opaque of cardinality, handle2: opaque of cardinality) : bool

Merges a HLL cardinality counter into another.

Note

The same restrictions as for Bloom filter merging apply, see bloomfilter_merge.

Parameters
  • handle1 – the first HLL handle, which will contain the merged result.

  • handle2 – the second HLL handle, which will be merged into the first.

Returns

true on success.

See also: hll_cardinality_estimate, hll_cardinality_add, hll_cardinality_init, hll_cardinality_copy