implement merging for top-k.

I am not (entirely) sure that this is mathematically correct, but
I am (more and more) getting the feeling that it... might be.

In any case - this was the last step and now it should work
in cluster settings.
This commit is contained in:
Bernhard Amann 2013-04-24 06:17:51 -07:00
parent 6f863d2259
commit 2f48008c42
7 changed files with 173 additions and 8 deletions

View file

@ -4,3 +4,7 @@ error: getCount for element that is not in top-k
error: getEpsilon for element that is not in top-k
error: getCount for element that is not in top-k
error: getEpsilon for element that is not in top-k
error: getCount for element that is not in top-k
error: getEpsilon for element that is not in top-k
error: getCount for element that is not in top-k
error: getEpsilon for element that is not in top-k

View file

@ -35,3 +35,23 @@
5
4
[c, e, d]
6
0
5
0
4
0
[c, e]
6
0
5
0
0
0
[c, e]
12
0
10
0
0
0

View file

@ -87,6 +87,34 @@ event bro_init()
topk_add(k1, "f");
s = topk_get_top(k1, 3);
print s;
print topk_count(k1, "c");
print topk_epsilon(k1, "c");
print topk_count(k1, "e");
print topk_epsilon(k1, "d");
print topk_count(k1, "d");
print topk_epsilon(k1, "d");
local k3 = topk_init(2);
topk_merge(k3, k1);
s = topk_get_top(k3, 3);
print s;
print topk_count(k3, "c");
print topk_epsilon(k3, "c");
print topk_count(k3, "e");
print topk_epsilon(k3, "e");
print topk_count(k3, "d");
print topk_epsilon(k3, "d");
topk_merge(k3, k1);
s = topk_get_top(k3, 3);
print s;
print topk_count(k3, "c");
print topk_epsilon(k3, "c");
print topk_count(k3, "e");
print topk_epsilon(k3, "e");
print topk_count(k3, "d");
print topk_epsilon(k3, "d");
}