Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HeavyKeeper ¶
type HeavyKeeper struct {
// contains filtered or unexported fields
}
HeavyKeeper implements the Top-K algorithm described in "HeavyKeeper: An Accurate Algorithm for Finding Top-k Elephant Flows" at https://www.usenix.org/system/files/conference/atc18/atc18-gong.pdf
HeavyKeeper is not safe for concurrent use.
func New ¶
func New(k int, decay float64) *HeavyKeeper
New returns a HeavyKeeper that tracks the k largest flows. Decay determines the chance that a collision will cause the existing flow count to decay. A decay of 0.9 is a good starting point.
Width is `k * log(k)` (minimum of 256) and depth is `log(k)` (minimum of 3).
func (*HeavyKeeper) Count ¶
func (hk *HeavyKeeper) Count(flow string) (count uint32, ok bool)
Count returns the estimated count of the given flow if it is in the top K flows.
func (*HeavyKeeper) DecayAll ¶
func (hk *HeavyKeeper) DecayAll(pct float64)
DecayAll decays all flows by the given percentage.
func (*HeavyKeeper) Reset ¶
func (hk *HeavyKeeper) Reset()
Reset returns the HeavyKeeper to a like-new state with no flows and no counts.
func (*HeavyKeeper) Sample ¶
func (hk *HeavyKeeper) Sample(flow string, incr uint32) bool
Sample increments the given flow's count by the given amount. It returns true if the flow is in the top K elements.
func (*HeavyKeeper) Top ¶
func (hk *HeavyKeeper) Top() []FlowCount