merge method
Merges other into a new sketch (both must share this precision).
Register-wise max is the exact merge rule for HLL: the union's rank in a bucket is whichever sketch saw the longer leading-zero run there, so merging never loses information. Differing precision throws. Audited: 2026-06-12 11:26 EDT
Implementation
HyperLogLogUtils merge(HyperLogLogUtils other) {
if (other.precision != precision) {
throw ArgumentError.value(
other.precision,
'other.precision',
'must equal this.precision ($precision)',
);
}
final HyperLogLogUtils out = HyperLogLogUtils(precision: precision);
for (int i = 0; i < _registers.length; i++) {
out._registers[i] = math.max(_registers[i], other._registers[i]);
}
return out;
}