Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 0.69 KB | None | 0 0
  1. diff --git src/main/scala/io/radanalytics/equoid/topk.scala src/main/scala/io/radanalytics/equoid/topk.scala
  2. index 25801e7..639071e 100644
  3. --- src/main/scala/io/radanalytics/equoid/topk.scala
  4. +++ src/main/scala/io/radanalytics/equoid/topk.scala
  5. @@ -23,10 +23,13 @@ class TopK[V] (
  6.      val ucms: CountMinSketch = ecms.mergeInPlace(this.cms)
  7.      ucms.add(v, 1)
  8.      val vf = ucms.estimateCount(v).toInt
  9. -    val (utopk, ufmin) = if (topk.size < k) {
  10. -      (topk + (v -> vf), math.min(vf, fmin))
  11. +    val (utopk, ufmin) = if (topk.size < k || topk.contains(v)) {
  12. +      (topk + (v -> vf), vf)
  13.      } else if (vf <= fmin) (topk, fmin) else {
  14.        val del = topk.minBy { case (_, f) => f }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement