Adding

The core of a HyperLogLog instance consists of:

  • a series of registers (mm), sometimes implemented as an array
  • a precision (pp) argument, usually between 4 and 16, specified on creation
    • The precision determines how many registers there are available
    • More registers reduce the error in the count, at the expense of more memory
  • a hash function (h(v)h(v)) which hashes the data into a 32-bit integer

The aim of HyperLogLog is to estimate the cardinality (EE) based on the current state of the registers.

Adding an item might ultimately end up changing the state of the registers, as you will see below.

Diagram

Hopefully this diagram will explain the steps that occur during an add operation. If not, maybe the playground below might give you some intuition.




Playground

Use the tool below to see what happens when you add an item into HyperLogLog

Insert (vv)

Precision (pp)

10

Try inserting some data above, or click "Random" to insert a random value