HyperLogLog

Approximate counts of distinct items in about 12 KB a key, with a standard error of 0.81%.

10 commands in KiviDB 1.1.2. Every command.

  • PFADD: Adds elements to the HyperLogLog at key: a structure of fixed size that estimates how many different elements it has been given, however many that is.
  • PFCOUNT: Returns the estimated number of different elements added to the HyperLogLog at key.
  • PFDEBUG: Inspects or resets a HyperLogLog.
    • PFDEBUG DECODE: Returns a summary of the HyperLogLog: its encoding, how many of its 16,384 registers are not zero, the largest register, and its estimate.
    • PFDEBUG ENCODING: Returns the HyperLogLog's encoding: always dense in KiviDB, which does not use Redis's sparse encoding.
    • PFDEBUG GETREG: Returns all 16,384 registers of the HyperLogLog, each from 0 to 63.
    • PFDEBUG RESET: Sets every register of the HyperLogLog to zero, so that it counts 0; the key is kept.
    • PFDEBUG TODENSE: Converts a HyperLogLog to the dense encoding; in KiviDB it already is, and the reply is OK.
  • PFMERGE: Merges the HyperLogLogs at the source keys into destkey, so that it estimates their union.
  • PFSELFTEST: Runs KiviDB's checks of its HyperLogLog code: an empty one counts 0, 10,000 elements are estimated within 2%, and registers read back as written.