in algebird-core/src/main/scala/com/twitter/algebird/CountMinSketch.scala [644:659]
override def ++(other: CMS[K]): CMS[K] =
other match {
case _: CMSZero[_] => this
case other: CMSItem[K] => this + (other.item, other.totalCount)
case other: SparseCMS[K] =>
// This SparseCMS's maxExactCount is used, so ++ is not communitive
val newTable = Semigroup.plus(exactCountTable, other.exactCountTable)
if (newTable.size < maxExactCount) {
// still sparse
SparseCMS(newTable, totalCount = totalCount + other.totalCount, params = params)
} else {
toDense(newTable, params)
}
case other: CMSInstance[K] => other ++ this
}