|
| bool | empty () const |
| | Return whether the instance is empty. More...
|
| |
| T | min () const |
| | Return the minimum value. More...
|
| |
| T | max () const |
| | Return the maximum value. More...
|
| |
| int64_t | totalValue () const |
| | Return the sum of values of all flowkeys. More...
|
| |
| void | swap (GndTruth &other) |
| | Swap content, note that calling histories are swapped as well. More...
|
| |
| RightConstIterator | begin () const |
| | Return a random access iterator pointed to the first element. More...
|
| |
| RightConstIterator | end () const |
| | Return a random access const iterator pointed to the very end. More...
|
| |
| size_t | size () const |
| | return the number of flows More...
|
| |
| size_t | count (const FlowKey< key_len > &flowkey) const |
| | return whether a flowkey is in the streaming data or not More...
|
| |
| T | at (const FlowKey< key_len > &flowkey) const |
| | Get the value of a certain key. More...
|
| |
| std::pair< RightConstIterator, RightConstIterator > | equalRange (T value) |
| | Return all flowkeys that share a single value. More...
|
| |
| void | getGroundTruth (typename std::vector< Record< key_len >>::const_iterator begin, typename std::vector< Record< key_len >>::const_iterator end, CntMethod cnt_method) |
| | Get the ground truth of the given stream. More...
|
| |
| void | getHeavyHitter (const GndTruth &flow_summary, double threshold, HXMethod hh_method) |
| | Get heavy hitters of the given stream (from flow summary) More...
|
| |
| void | getHeavyHitter (GndTruth &&flow_summary, double threshold, HXMethod hh_method) |
| | Get heavy hitters of the given stream (from flow summary) More...
|
| |
| void | getHeavyHitter (typename std::vector< Record< key_len >>::const_iterator begin, typename std::vector< Record< key_len >>::const_iterator end, CntMethod cnt_method, double threshold, HXMethod hh_method) |
| | Get heavy hitters from streaming data. More...
|
| |
| void | getHeavyChanger (const GndTruth &flow_summary_1, const GndTruth &flow_summary_2, double threshold, HXMethod hc_method) |
| | Get heavy changers of the given stream (from flow summary) More...
|
| |
| void | getHeavyChanger (GndTruth &&flow_summary_1, GndTruth &&flow_summary_2, double threshold, HXMethod hc_method) |
| | Get heavy changers of the given stream (from flow summary) More...
|
| |
| void | getHeavyChanger (typename std::vector< Record< key_len >>::const_iterator begin_1, typename std::vector< Record< key_len >>::const_iterator end_1, typename std::vector< Record< key_len >>::const_iterator begin_2, typename std::vector< Record< key_len >>::const_iterator end_2, CntMethod cnt_method, double threshold, HXMethod hc_method) |
| | Get heavy hitters from streaming data. More...
|
| |
template<int32_t key_len, typename T = int64_t>
class OmniSketch::Data::GndTruth< key_len, T >
Ground truth of the streaming data.
This class encapsulates boost::bimap, a time-efficient implementation of bidirectional map. See also this page for more information. It is left signature-compatible with std::unordered_map and right signature-compatible with std::vector. Besides, values are in descending order. Sensible users should not bother with underlying data structure, since it is the black box! Moreover, the class supports range-expression. It means that you may iterate all the flowkeys in the following manner:
for(const auto &kv: gnd_truth){
kv.get_left();
kv.get_right();
}
- Template Parameters
-
| T | type of counter |
| key_len | length of flowkey |
- Note
T is suggested to be int32_t when the counting method is chosen to be InPacket and be int64_t on InLength, so as to avoid overflow.
- Rationale: It seems to be odd that so many methods, such as finding heavy hitters, heavy changers & super spreaders, are designed to be the class methods of GndTruth, in lieu of those of StreamData. Well, the design is quite intuitive once you keep in mind that GndTruth should be provided with streaming data to find the truth. Besides, GndTruth can be extracted from another GndTruth. See example below.
Example
if(!data.succeed()) exit(-1);
flow_summary.getGndTruth(data.begin(), data.end(),
InLength);
- Warning
- On each instance of GndTruth, you should call getXXX(...) method at most once. Otherwise, you should define a new instance and call the method upon the new one. See example below. The only exception happens when you swap two GndTruth instances. In that case, their calling histories are swapped as well. See swap().
- Any instance that is about to call getHeavyChanger() has to declare
T as an signed type, no matter the size, since there could be negative values half way in arithemetic operations. In any other cases, declaring T as unsigned is fine after all.
A Second Example
if(!data.succeed()) exit(-1);
flow_summary.getGndTruth(data.begin(), data.end(),
InLength);
template<int32_t key_len, typename T >
Get heavy changers of the given stream (from flow summary)
Heavy changers are with respect to the two flow summaries. If hc_method equals TopK, the heaviest threshold flows are to be counted as heavy changers. Otherwise, all the flows whose deviation contributes to the whole a fraction strictly greater than threshold are counted.
- Parameters
-
| flow_summary_1 | the first flow summary |
| flow_summary_2 | the second flow summary |
| threshold | threshold value |
| hc_method | definition of heavy changers |
- Note
threshold should be in [1, infty) when hh_method is TopK, and should be in [0, 1] when hh_method is Percentile. Otherwise, an exception would be thrown.
template<int32_t key_len, typename T >
Get heavy hitters of the given stream (from flow summary)
If hh_method equals TopK, the heaviest threshold flows are to be counted as heavy hitters. Otherwise, all the flows who contribute a fraction strictly greater than threshold are to be counted.
- Parameters
-
| flow_summary | summary of flow, typically the one returned by getGroundTruth() |
| threshold | threshold value |
| hh_method | definition of heavy hitter |
- Note
threshold should be in [1, infty) when hh_method equals TopK, and should be in [0, 1] when hh_method equals Percentile. Otherwise, an exception would be thrown.