Realm

v0

gno.land/r/moul/x/daily/countminsketchdemo/v0

Render

Count–Min Sketch

Frequency estimates in fixed space, demoing the p/moul/x/daily/countminsketch library.

The workload

195 events over 123 distinct keys: three heavy hitters and a long tail of one-offs.

A generously sized sketch (1024 × 4)

keytrueestimate
alice4040
bob2525
carol1010
user011
never-seen00

Exact here, and never-seen reads 0 — a zero estimate is definitive: that key was never added.

A deliberately tiny one (8 × 2)

Only 16 counters for 123 distinct keys, so collisions are guaranteed:

keytrueestimateerror
alice4054+14
bob2539+14
carol1024+14
user0116+15

Every error is positive. That is the guarantee: the sketch may overcount, never undercount, so an estimate is an upper bound — "at most this often", never "exactly this often".

Where the collisions are

Row 0 of the tiny sketch, and the column each key lands in:

columncounter
015
125 ← carol
216
315
454 ← alice
516
615
739 ← bob

Taking the minimum across rows is what limits the damage: an overestimate needs a collision in every row at once.

Why bother

exact mapsketch (1024 × 4)
storageone entry per distinct key, unbounded4096 counters, fixed
answerexactupper bound

On chain the second row is the point: storage driven by user input is a liability, and a sketch sized once cannot be made to grow.

Transactions

No indexed transactions for this realm yet.

Calls, deploys, and child packages in indexed history.

Call function

Calls stay disabled until vm/qfuncs lists this package. Delve only submits functions the chain publishes for gno.land/r/moul/x/daily/countminsketchdemo/v0.

Source (qfile)