in algebird-util/src/main/scala/com/twitter/algebird/util/summer/HeavyHittersCachingSummer.scala [91:118]
private[this] final def updateHH(item: Int): Unit = {
@inline
def pruneHH(): Unit = {
val iter = hh.values.iterator
while (iter.hasNext) {
val n = iter.next()
if (n < hhMinReq) {
iter.remove
}
}
}
if (hh.containsKey(item)) {
val v = hh.get(item)
val newItemCount = v + 1L
if (newItemCount < hhMinReq) {
pruneHH()
} else {
hh.put(item, newItemCount)
}
} else {
val newItemCount = frequencyEst(item) + 1L
if (newItemCount >= hhMinReq) {
hh.put(item, totalCount)
}
pruneHH()
}
}