Merge remote-tracking branch 'origin/topic/jsiwek/gh-973-fix-topk-get-top-return-type'

* origin/topic/jsiwek/gh-973-fix-topk-get-top-return-type:
  GH-973: Fix the return type of topk_get_top()
This commit is contained in:
Tim Wojtulewicz 2020-06-03 13:29:12 -07:00
commit b4aa5d9456
5 changed files with 31 additions and 26 deletions

View file

@ -1,3 +1,10 @@
3.2.0-dev.742 | 2020-06-03 13:29:12 -0700
* GH-973: Fix the return type of topk_get_top()
e.g. when using `string` elements it should return `vector of string`,
not `vector of list of string` like it did before. (Jon Siwek, Corelight)
3.2.0-dev.740 | 2020-06-03 13:17:26 -0700 3.2.0-dev.740 | 2020-06-03 13:17:26 -0700
* Deprecate Val(double, TypeTag) ctor, add TimeVal/DoubleVal subclasses * Deprecate Val(double, TypeTag) ctor, add TimeVal/DoubleVal subclasses

View file

@ -1 +1 @@
3.2.0-dev.740 3.2.0-dev.742

View file

@ -191,9 +191,7 @@ IntrusivePtr<VectorVal> TopkVal::GetTopK(int k) const // returns vector
return nullptr; return nullptr;
} }
auto vector_index = make_intrusive<TypeList>(type); auto v = make_intrusive<VectorType>(type);
vector_index->Append(type);
auto v = make_intrusive<VectorType>(std::move(vector_index));
auto t = make_intrusive<VectorVal>(std::move(v)); auto t = make_intrusive<VectorVal>(std::move(v));
// this does no estimation if the results is correct! // this does no estimation if the results is correct!

View file

@ -1,4 +1,4 @@
[b, c] [b, c], vector of string
4 4
0 0
0 0
@ -6,7 +6,7 @@
0 0
2 2
1 1
[d, c] [d, c], vector of string
5 5
0 0
0 0
@ -14,25 +14,25 @@
1 1
3 3
2 2
[d, e] [d, e], vector of string
6 6
3 3
2 2
3 3
2 2
[f, e] [f, e], vector of string
7 7
4 4
3 3
3 3
2 2
[f, e] [f, e], vector of string
8 8
4 4
3 3
4 4
2 2
[g, e] [g, e], vector of string
9 9
0 0
0 0
@ -40,7 +40,7 @@
2 2
5 5
4 4
[c, e, d] [c, e, d], vector of string
19 19
6 6
0 0
@ -48,14 +48,14 @@
0 0
4 4
0 0
[c, e] [c, e], vector of string
6 6
0 0
5 5
0 0
0 0
0 0
[c, e] [c, e], vector of string
22 22
12 12
0 0
@ -63,7 +63,7 @@
0 0
0 0
0 0
[c, e] [c, e], vector of string
19 19
6 6
0 0
@ -71,7 +71,7 @@
0 0
4 4
0 0
[c, e, d] [c, e, d], vector of string
38 38
12 12
0 0

View file

@ -13,7 +13,7 @@ event zeek_init()
topk_add(k1, "c"); topk_add(k1, "c");
local s = topk_get_top(k1, 5); local s = topk_get_top(k1, 5);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "a"); print topk_count(k1, "a");
print topk_epsilon(k1, "a"); print topk_epsilon(k1, "a");
@ -24,7 +24,7 @@ event zeek_init()
topk_add(k1, "d"); topk_add(k1, "d");
s = topk_get_top(k1, 5); s = topk_get_top(k1, 5);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "b"); print topk_count(k1, "b");
print topk_epsilon(k1, "b"); print topk_epsilon(k1, "b");
@ -35,7 +35,7 @@ event zeek_init()
topk_add(k1, "e"); topk_add(k1, "e");
s = topk_get_top(k1, 5); s = topk_get_top(k1, 5);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "d"); print topk_count(k1, "d");
print topk_epsilon(k1, "d"); print topk_epsilon(k1, "d");
@ -44,7 +44,7 @@ event zeek_init()
topk_add(k1, "f"); topk_add(k1, "f");
s = topk_get_top(k1, 5); s = topk_get_top(k1, 5);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "f"); print topk_count(k1, "f");
print topk_epsilon(k1, "f"); print topk_epsilon(k1, "f");
@ -53,7 +53,7 @@ event zeek_init()
topk_add(k1, "e"); topk_add(k1, "e");
s = topk_get_top(k1, 5); s = topk_get_top(k1, 5);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "f"); print topk_count(k1, "f");
print topk_epsilon(k1, "f"); print topk_epsilon(k1, "f");
@ -62,7 +62,7 @@ event zeek_init()
topk_add(k1, "g"); topk_add(k1, "g");
s = topk_get_top(k1, 5); s = topk_get_top(k1, 5);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "f"); print topk_count(k1, "f");
print topk_epsilon(k1, "f"); print topk_epsilon(k1, "f");
@ -92,7 +92,7 @@ event zeek_init()
topk_add(k1, "e"); topk_add(k1, "e");
topk_add(k1, "f"); topk_add(k1, "f");
s = topk_get_top(k1, 3); s = topk_get_top(k1, 3);
print s; print s, type_name(s);
print topk_sum(k1); print topk_sum(k1);
print topk_count(k1, "c"); print topk_count(k1, "c");
print topk_epsilon(k1, "c"); print topk_epsilon(k1, "c");
@ -105,7 +105,7 @@ event zeek_init()
topk_merge_prune(k3, k1); topk_merge_prune(k3, k1);
s = topk_get_top(k3, 3); s = topk_get_top(k3, 3);
print s; print s, type_name(s);
print topk_count(k3, "c"); print topk_count(k3, "c");
print topk_epsilon(k3, "c"); print topk_epsilon(k3, "c");
print topk_count(k3, "e"); print topk_count(k3, "e");
@ -116,7 +116,7 @@ event zeek_init()
topk_merge_prune(k3, k1); topk_merge_prune(k3, k1);
s = topk_get_top(k3, 3); s = topk_get_top(k3, 3);
print s; print s, type_name(s);
print topk_sum(k3); # this gives a warning and a wrong result. print topk_sum(k3); # this gives a warning and a wrong result.
print topk_count(k3, "c"); print topk_count(k3, "c");
print topk_epsilon(k3, "c"); print topk_epsilon(k3, "c");
@ -127,7 +127,7 @@ event zeek_init()
k3 = topk_init(2); k3 = topk_init(2);
topk_merge(k3, k1); topk_merge(k3, k1);
print s; print s, type_name(s);
print topk_sum(k3); print topk_sum(k3);
print topk_count(k3, "c"); print topk_count(k3, "c");
print topk_epsilon(k3, "c"); print topk_epsilon(k3, "c");
@ -139,7 +139,7 @@ event zeek_init()
topk_merge(k3, k1); topk_merge(k3, k1);
s = topk_get_top(k3, 3); s = topk_get_top(k3, 3);
print s; print s, type_name(s);
print topk_sum(k3); print topk_sum(k3);
print topk_count(k3, "c"); print topk_count(k3, "c");
print topk_epsilon(k3, "c"); print topk_epsilon(k3, "c");