topk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const LOOKUP_TABLE = 256

Variables

This section is empty.

Functions

This section is empty.

Types

type HeavyKeeper

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

Topk implement by heavykeeper algorithm.

func (*HeavyKeeper) Add

func (topk *HeavyKeeper) Add(key string, incr uint32) (string, bool)

Add add item into heavykeeper and return if item had beend add into minheap. if item had been add into minheap and some item was expelled, return the expelled item.

func (*HeavyKeeper) Expelled

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

func (*HeavyKeeper) Fading

func (topk *HeavyKeeper) Fading()

func (*HeavyKeeper) List

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

func (*HeavyKeeper) Total

func (topk *HeavyKeeper) Total() uint64

type Item

type Item struct {
	Key   string
	Count uint32
}

Item is topk item.

type Topk

type Topk interface {
	// Add item and return if item is in the topk.
	Add(item string, incr uint32) (string, bool)
	// List all topk items.
	List() []Item
	// Expelled watch at the expelled items.
	Expelled() <-chan Item
	Fading()
}

Topk algorithm interface.

func NewHeavyKeeper

func NewHeavyKeeper(k, width, depth uint32, decay float64, min uint32) Topk

Jump to

Keyboard shortcuts

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