well, a test that works..

Note: merging top-k data structures is not yet possible (and is
actually quite awkward/expensive). I will have to think about
how to do that for a bit...
This commit is contained in:
Bernhard Amann 2013-04-22 02:40:42 -07:00
parent c21c18ea45
commit ce7ad003f2
5 changed files with 115 additions and 12 deletions

View file

@ -0,0 +1,7 @@
[b, c]
[d, c]
[d, e]
[f, e]
[f, e]
[g, e]
[c, e, d]

View file

@ -0,0 +1,61 @@
# @TEST-EXEC: bro -b %INPUT > out
# @TEST-EXEC: btest-diff out
event bro_init()
{
local k1 = topk_init(2);
# first - peculiarity check...
topk_add(k1, "a");
topk_add(k1, "b");
topk_add(k1, "b");
topk_add(k1, "c");
local s = topk_get_top(k1, 5);
print s;
topk_add(k1, "d");
s = topk_get_top(k1, 5);
print s;
topk_add(k1, "e");
s = topk_get_top(k1, 5);
print s;
topk_add(k1, "f");
s = topk_get_top(k1, 5);
print s;
topk_add(k1, "e");
s = topk_get_top(k1, 5);
print s;
topk_add(k1, "g");
s = topk_get_top(k1, 5);
print s;
k1 = topk_init(100);
topk_add(k1, "a");
topk_add(k1, "b");
topk_add(k1, "b");
topk_add(k1, "c");
topk_add(k1, "c");
topk_add(k1, "c");
topk_add(k1, "c");
topk_add(k1, "c");
topk_add(k1, "c");
topk_add(k1, "d");
topk_add(k1, "d");
topk_add(k1, "d");
topk_add(k1, "d");
topk_add(k1, "e");
topk_add(k1, "e");
topk_add(k1, "e");
topk_add(k1, "e");
topk_add(k1, "e");
topk_add(k1, "f");
s = topk_get_top(k1, 3);
print s;
}