mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 02:58:20 +00:00

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.
31 lines
518 B
Text
31 lines
518 B
Text
@load base/frameworks/sumstats
|
|
|
|
module SumStats;
|
|
|
|
export {
|
|
redef enum Calculation += {
|
|
TOPK
|
|
};
|
|
|
|
redef record ResultVal += {
|
|
topk: opaque of topk &default=topk_init(500);
|
|
};
|
|
|
|
}
|
|
|
|
hook observe_hook(r: Reducer, val: double, obs: Observation, rv: ResultVal)
|
|
{
|
|
if ( TOPK in r$apply )
|
|
{
|
|
topk_add(rv$topk, obs);
|
|
}
|
|
}
|
|
|
|
|
|
hook compose_resultvals_hook(result: ResultVal, rv1: ResultVal, rv2: ResultVal)
|
|
{
|
|
result$topk = topk_init(500);
|
|
|
|
topk_merge(result$topk, rv1$topk);
|
|
topk_merge(result$topk, rv2$topk);
|
|
}
|