sketch

package
v0.0.0-...-abeb0ca Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const IntMask = (1 << IntSize) - 1
View Source
const IntSize = 64

Variables

This section is empty.

Functions

func MakeHashes

func MakeHashes(depth uint32) []uint64

func MakeTable

func MakeTable(dx, dy uint32) [][]uint32

func MultiplyShift

func MultiplyShift(m uint, a uint64, x uint64) uint64

func RandomOddInt

func RandomOddInt() uint64

func SerializeUint64

func SerializeUint64(n uint64) []byte

Types

type GroupSketch

type GroupSketch struct {
	SketchWithChildren
	Default string
	Parent  Interface
}

func MakeGroupSketch

func MakeGroupSketch(def string, sketches map[string]Interface) *GroupSketch

func (*GroupSketch) Top

func (gs *GroupSketch) Top(n int) []Item

func (*GroupSketch) Update

func (ms *GroupSketch) Update(term string)

type Interface

type Interface interface {
	Update(term string)
	Top(n int) []Item
	StartAutoRotation()
	StopAutoRotation()
}

type Item

type Item struct {
	Est uint32
	Key string
}

func (*Item) Less

func (t *Item) Less(other interface{}) bool

type Items

type Items []Item

func (Items) Len

func (s Items) Len() int

func (Items) Less

func (s Items) Less(i, j int) bool

func (Items) Swap

func (s Items) Swap(i, j int)

type MultiSketch

type MultiSketch struct {
	Len      int
	Period   int
	Sketches []*Sketch
	K        int
	Depth    uint32
	Width    uint32
	// contains filtered or unexported fields
}

func MakeMultiSketch

func MakeMultiSketch(l int, period int, k int, depth uint32, width uint32) *MultiSketch

func (*MultiSketch) Rotate

func (ms *MultiSketch) Rotate()

func (*MultiSketch) StartAutoRotation

func (ms *MultiSketch) StartAutoRotation()

func (*MultiSketch) StopAutoRotation

func (ms *MultiSketch) StopAutoRotation()

func (*MultiSketch) Top

func (ms *MultiSketch) Top(n int) []Item

func (*MultiSketch) Update

func (ms *MultiSketch) Update(term string)

type Sketch

type Sketch struct {
	K             int
	LgWidth       uint
	Count         [][]uint32
	HashFunctions []uint64
	Depth         uint32
	Heap          *pqueue.Queue
	Map           map[string]Item
	// contains filtered or unexported fields
}

func MakeSketch

func MakeSketch(k int, depth uint32, width uint32) *Sketch

func (*Sketch) DHash

func (self *Sketch) DHash(key string, hf uint64) uint64

func (*Sketch) Estimate

func (self *Sketch) Estimate(key string) uint32

func (*Sketch) Hash

func (self *Sketch) Hash(key string) uint64

func (*Sketch) StartAutoRotation

func (s *Sketch) StartAutoRotation()

func (*Sketch) StopAutoRotation

func (s *Sketch) StopAutoRotation()

func (*Sketch) Top

func (sk *Sketch) Top(n int) []Item

func (*Sketch) Update

func (self *Sketch) Update(key string)

func (*Sketch) UpdateHeap

func (self *Sketch) UpdateHeap(key string, est uint32)

type SketchWithChildren

type SketchWithChildren struct {
	Sketches map[string]Interface
}

func (*SketchWithChildren) StartAutoRotation

func (s *SketchWithChildren) StartAutoRotation()

func (*SketchWithChildren) StopAutoRotation

func (s *SketchWithChildren) StopAutoRotation()

Jump to

Keyboard shortcuts

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