fancycounter

package module
v0.0.0-...-44bd1ab Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 1 Imported by: 0

README

Fancy Counter

Do you need to count occurences of certain numbers within large lists of numbers to find out which of those numbers occur the most often?

Do you need it to be fast?

Well I've got a data structure for you!

Introducing... The Fancy Counter!

Its a stack of roaring bitmaps that effectively comprise a compressed N bit integer for the number of each item in the set (up to the maximum value configured when setting the thing up)

This is used in Bluesky's Discover algorithm for suggesting who to follow based on who the people you are following follow.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FancyCounter

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

func NewFancyCounter

func NewFancyCounter(limitPowTwo int) *FancyCounter

func (*FancyCounter) Add

func (fc *FancyCounter) Add(v uint64)

func (*FancyCounter) AddFromCounter

func (fc *FancyCounter) AddFromCounter(ofc *FancyCounter)

func (*FancyCounter) AddFromCounterDestructive

func (fc *FancyCounter) AddFromCounterDestructive(ofc *FancyCounter)

AddFromCounterDestructive is a faster version of AddFromCounter that uses (and mutates) the input bitmaps

func (*FancyCounter) AddMany

func (fc *FancyCounter) AddMany(inp *roaring64.Bitmap)

func (*FancyCounter) AddN

func (fc *FancyCounter) AddN(v uint64, n int)

func (*FancyCounter) Clear

func (fc *FancyCounter) Clear()

func (*FancyCounter) DebugGetVals

func (fc *FancyCounter) DebugGetVals() map[uint64]int

func (*FancyCounter) GetNthTopSet

func (fc *FancyCounter) GetNthTopSet(n int) *roaring64.Bitmap

func (*FancyCounter) GetTopBits

func (fc *FancyCounter) GetTopBits() *roaring64.Bitmap

func (*FancyCounter) Limit

func (fc *FancyCounter) Limit() int

func (*FancyCounter) MulAllByPow2

func (fc *FancyCounter) MulAllByPow2(n int)

func (*FancyCounter) Remove

func (fc *FancyCounter) Remove(v uint64)

func (*FancyCounter) RemoveLessThanThresh

func (fc *FancyCounter) RemoveLessThanThresh(thresh uint64)

func (*FancyCounter) RemoveMany

func (fc *FancyCounter) RemoveMany(rm *roaring64.Bitmap)

func (*FancyCounter) Thresh

func (fc *FancyCounter) Thresh() int

Jump to

Keyboard shortcuts

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