Example #1
0
func TestWindowedCmsSanity(t *testing.T) {
	w, _ := streaming.MakeWindowedCMS(0.001, 0.0001, 5, 1000, 100)
	k1 := []byte("hello")
	w.Update(k1, 1.0)

	cnt, _ := w.Count(k1)

	if math.Abs(cnt-1.0) > eps {
		t.Errorf("cnt should be 1.0, but was %d", cnt)
	}
}
Example #2
0
func TestWindowedCmsOutOfWindow(t *testing.T) {
	w, _ := streaming.MakeWindowedCMS(0.001, 0.0001, 5, 2, 1)
	k1 := []byte("hello")
	k2 := []byte("hello2")
	w.Update(k1, 1.0)
	w.Update(k2, 1.0)
	w.Update(k2, 1.0)

	cnt, _ := w.Count(k1)

	if math.Abs(cnt-0.0) > eps {
		t.Errorf("cnt should be 0.0, but was %d", cnt)
	}
}