DecayedValue compare only uses scaledtime? Usage with SketchMap example

13 views
Skip to first unread message

Ahmad Alkilani

unread,
May 1, 2015, 10:04:32 PM5/1/15
to alge...@googlegroups.com

Hi, all the questions are somewhat related and boil down to how to use DecayedValue with SketchMap.

I'm looking at the implementation of DecayedValue and it seems like the compare function only uses scaledtime to determine ordering.

case class DecayedValue(value: Double, scaledTime: Double) extends Ordered[DecayedValue] {
def compare(that: DecayedValue): Int = {
scaledTime.compareTo(that.scaledTime)
}

....

}

Question #1:
Anyone have insight on why the implementation looks like this? Why not use the value: Double to perform the comparison? Seems there's an assumption that any "newer" DecayedValue irrespective of value is greater.


Question #2: SketchMap with DecayedValue

The use case is that I want to create a SketchMap of [String, DecayedValue] like so:

implicit def SKETCHMAPMONOID = { // Generates a monoid used to create SketchMap instances.
      SketchMap.monoid[String, DecayedValue](SketchMapParams[String](SEED, EPS, DELTA, HEAVY_HITTERS_COUNT))
    }


Constantly creating new sketchmaps and adding them together.

If I ask the SketchMap for heaviest hitters and it's using the ordering provided by DecayedValue wouldn't it just give me the most recently updated records regardless of the DecayedValue.value?


Question #3:
Is there a way to itterate over the valuesTable and update all the values in a SketchMap?
Reason to ask is that if I have a SketchMap with DecayedValues and I call SketchMap.heavyHitterKeys. I want to be sure all the DecayedValues were updated with either a new value, if present in the current window, or a 1L if nothing is present.
This ensures the DecayedValues in the SketchMap all reflect the current state as of the latest window. The current state would update a DecayedValue and keep it "alive" longer if a new value was present, and it would allow it to "decay" by updating the time with a value of 1L
if no value was present in the current window. Ultimately, the question is how to get an accurate result back from SketchMap.heavyHitterKeys when the value is of type DecayedValue

Thank you!
Reply all
Reply to author
Forward
0 new messages