AlgoViz

Merging distinct counts across regions

medium 4 min

Compatible HyperLogLog sketches merge by taking the maximum for every corresponding register.

Video lesson · Chapter 1 of 5

One visitor crosses two regions

0:00 / 3:42

One traveller appears in both regions

1:11Reel

Theory

Read or listen first. About 1 min.

What it is

Two regions can sketch overlapping visitors independently. When both use compatible settings, each pair of corresponding registers describes the same part of the hash space.

Merge matching registers column by column

East2135West1432Union????Each column represents one shared bucket.
Both regions use the same precision, register layout and hash function. Each column therefore describes the same hash bucket.

Why it exists

A per-register maximum keeps the strongest observation from either region. Common visitors contribute the same evidence they would have contributed to a single shared sketch.

Words to know

Register-wise maximum
A merge that keeps the larger stored rank at every matching register position.

How it works

Step through the idea, or press Play.

Step 1 of 3

Record both visits. The same device is seen in two regions.

Understand it

Worked example

Merging distinct counts across regions in practice

A device visits two regions in one hour. Adding exact regional distinct counts counts it twice. In a merged sketch its repeated hash has the same address and rank, so the second observation adds no register information.

Related case

Three questions for a tiny memory budget

A telemetry service needs to skip pointless disk reads, estimate traffic for a known endpoint, and count unique devices across regions. Each question allows a different error.

One device crosses regions
A device visits two regionsDevice 9first visitRegion AemptyRegion BemptyCount distinct devices across regions

Estimate the union of observed identities.

Sources