Merging distinct counts across regions 00:00:01 One visitor crosses two regions Two regions each say they saw two distinct visitors. How many visited the whole service? In our tiny experiment East saw A and B, and kept a regional HyperLogLog sketch. West saw B and C. Within each region there are two different identifiers. B is the same account on both visits, so count it once when the question covers both regions. Adding the exact counts gives four, but the true union only has three distinct visitors: A, B, and C. Write the identifiers on three paper tickets before compressing anything. B is the same identity in both regions. That visible overlap will let us check what the merged sketch is supposed to represent. 00:00:45 A repeated hash is the same evidence With compatible hashing, precision and normalized identity, B chooses the same register and proposes the same rank in both places. Sharing a hash convention lets two regions describe comparable evidence. Neither sketch stores the full list, so we can't just combine them by adding counts or merging lists. The merge must avoid double-counting B, even though it appeared in both regions. Use exactly the same normalized input bytes too. If one region hashes a lower-case identifier and the other hashes an upper-case spelling of the same account, the mathematical merge will faithfully preserve the wrong notion of identity. 00:01:22 Take registerwise maxima Compare corresponding registers and retain the larger rank at each position. A smaller rank is intentionally discarded because the register in a single combined stream would also have retained only the larger observation. We do not add the register values; instead, we take the maximum at each position. The merged register array is the same array this compatible sketch would build by reading the union stream. Run the cardinality estimator once on that merged array. Give one illustrative register rank three in East and rank five in West. The union stores five. Another pair might be four and two, so that register stores four. Each region contributes its strongest evidence wherever it occurred. 00:02:05 Estimate once after merging Here the exact reference set has three members. A small approximate sketch might report something else. Equality of the register arrays says nothing about whether a scalar estimate will equal three exactly. Adding regional estimates fails when identities overlap, like B appearing in both regions. Merging the same regional sketch twice leaves the result unchanged because the maximum of a value with itself is that same value. New observations from a later sketch can still raise registers. The maximum operation is commutative, associative and idempotent. You can merge East first or West first, group intermediate results by continent, or retry a merge without changing the register maxima for the same underlying inputs. 00:02:49 Protect the counting contract For an ordinary component-wise merge, require compatible precision, encoding, hash function and seed. Also check that the populations and time windows combine into the question being reported. A supported conversion from higher to lower precision may be possible for particular implementations. Never silently line up unrelated register numbers or simply truncate the arrays to make lengths match. Save the merge metadata and test that a direct pass and a regional merge produce identical register states on a known input. Then assess the estimator’s separate statistical uncertainty. Record the window semantics as carefully as the precision. Unioning Monday and Tuesday can deliberately answer a two-day question. Accidentally mixing a daily sketch with a trailing-week sketch answers a different question from daily regional reach.