[Bro-Dev] [JIRA] (BIT-1144) topk_get_top returned data type
Justin Azoff (JIRA)
jira at bro-tracker.atlassian.net
Fri Feb 21 05:59:37 PST 2014
[ https://bro-tracker.atlassian.net/browse/BIT-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15574#comment-15574 ]
Justin Azoff commented on BIT-1144:
-----------------------------------
The following works:
{code}
event bro_init() {
local topk = topk_init(10);
topk_add(topk, 1);
topk_add(topk, 2);
topk_add(topk, 2);
topk_add(topk, 3);
topk_add(topk, 3);
topk_add(topk, 3);
print fmt("topk size is %d", topk_size(topk));
local top2: vector of int = topk_get_top(topk, 2);
print fmt("size of top2 is %d", |top2|);
print top2;
for (c in top2) {
print top2[c];
}
}
{code}
> topk_get_top returned data type
> -------------------------------
>
> Key: BIT-1144
> URL: https://bro-tracker.atlassian.net/browse/BIT-1144
> Project: Bro Issue Tracker
> Issue Type: Problem
> Components: Bro
> Affects Versions: 2.2
> Environment: Ubuntu, both 2.2 release and 2.2.117 from git.
> Reporter: Brian Little
> Assignee: Bernhard Amann
> Priority: Low
> Labels: topk
> Attachments: topk.bro
>
>
> I'm trying to get the top few results in a topk data type, and then loop over them to print.
> Running for over the results brings up an error:
> target to iterate over must be a table, set, vector, or string
> The docs say it is of type vector, and running |topk_result| brings back the correct count.
> example demonstration script attached
--
This message was sent by Atlassian JIRA
(v6.2-OD-09-036#6252)
More information about the bro-dev
mailing list