mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
make size of topk-list configureable when using sumstats
This commit is contained in:
parent
2f48008c42
commit
c0890f2a0f
3 changed files with 21 additions and 2 deletions
|
@ -3,16 +3,27 @@
|
|||
module SumStats;
|
||||
|
||||
export {
|
||||
redef record Reducer += {
|
||||
## number of elements to keep in the top-k list
|
||||
topk_size: count &default=500;
|
||||
};
|
||||
|
||||
redef enum Calculation += {
|
||||
TOPK
|
||||
};
|
||||
|
||||
redef record ResultVal += {
|
||||
topk: opaque of topk &default=topk_init(500);
|
||||
topk: opaque of topk &optional;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
hook init_resultval_hook(r: Reducer, rv: ResultVal)
|
||||
{
|
||||
if ( TOPK in r$apply && ! rv?$topk )
|
||||
rv$topk = topk_init(r$topk_size);
|
||||
}
|
||||
|
||||
hook observe_hook(r: Reducer, val: double, obs: Observation, rv: ResultVal)
|
||||
{
|
||||
if ( TOPK in r$apply )
|
||||
|
@ -24,7 +35,7 @@ hook observe_hook(r: Reducer, val: double, obs: Observation, rv: ResultVal)
|
|||
|
||||
hook compose_resultvals_hook(result: ResultVal, rv1: ResultVal, rv2: ResultVal)
|
||||
{
|
||||
result$topk = topk_init(500);
|
||||
result$topk = topk_init(topk_size(rv1$topk));
|
||||
|
||||
topk_merge(result$topk, rv1$topk);
|
||||
topk_merge(result$topk, rv2$topk);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue