topk

package
v0.0.0-...-604a874 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const DecayTableLen = 1 << 8

Variables

This section is empty.

Functions

This section is empty.

Types

type HeavyKeeper

type HeavyKeeper struct {
	// contains filtered or unexported fields
}

HeavyKeeper algorithm structure.

See: https://www.usenix.org/system/files/conference/atc18/atc18-gong.pdf

func (*HeavyKeeper) Add

func (hk *HeavyKeeper) Add(item string, incr uint32) (string, bool)

func (*HeavyKeeper) Expelled

func (hk *HeavyKeeper) Expelled() <-chan Item

func (*HeavyKeeper) Fading

func (hk *HeavyKeeper) Fading()

func (*HeavyKeeper) List

func (hk *HeavyKeeper) List() []Item

func (*HeavyKeeper) Total

func (hk *HeavyKeeper) Total() uint64

type Item

type Item struct {
	Key   string
	Count uint32
}

TopK item.

type TopK

type TopK interface {

	// Add adds an item to the list of top k.
	// It returns two values:
	//	- The first return value represents if the item had been added successfully.
	//	- The second return value is the expelled item if any item was expelled.
	Add(item string, incr uint32) (string, bool)

	// Lists returns all the items in the top k.
	List() []Item

	// Total returns the total count of the items.
	Total() uint64

	// Expelled watches at the expelled items.
	Expelled() <-chan Item

	// Fading reduces count for the specified scene.
	Fading()
}

TopK algorithm interface.

func NewHeavyKeeper

func NewHeavyKeeper(k, width, depth uint32, decay float64, minCount uint32) TopK

NewHeavyKeeper creates a new HeavyKeeper instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL