util

package
v0.0.0-...-dac20d5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GitCommit = ""
	BuildTime = ""
	GoVersion = ""
	Version   = ""
)

set on build time

Functions

func AcquireBitmap

func AcquireBitmap() *roaring.Bitmap

AcquireBitmap create a bitmap

func AcquireBuf

func AcquireBuf() *bytes.Buffer

AcquireBuf get a bm from pool

func BMAlloc

func BMAlloc(new *roaring.Bitmap, shards ...*roaring.Bitmap)

BMAlloc alloc bm

func BMAnd

func BMAnd(bms ...*roaring.Bitmap) *roaring.Bitmap

BMAnd bitmap and

func BMAndInterface

func BMAndInterface(bms ...interface{}) *roaring.Bitmap

BMAndInterface bm and using interface{}

func BMAndnot

func BMAndnot(bms ...*roaring.Bitmap) *roaring.Bitmap

BMAndnot bitmap andnot A - (A and B)

func BMAndnotInterface

func BMAndnotInterface(bms ...interface{}) *roaring.Bitmap

BMAndnotInterface bitmap andnot using interface{}

func BMMinus

func BMMinus(bm1, bm2 *roaring.Bitmap) *roaring.Bitmap

BMMinus bm1 - bm2

func BMOr

func BMOr(bms ...*roaring.Bitmap) *roaring.Bitmap

BMOr bitmap or

func BMOrInterface

func BMOrInterface(bms ...interface{}) *roaring.Bitmap

BMOrInterface bitmap or using interface{}

func BMRemove

func BMRemove(bm1, bm2 *roaring.Bitmap)

BMRemove bm1 - bm2

func BMSplit

func BMSplit(bm *roaring.Bitmap, maxSize uint64) []*roaring.Bitmap

BMSplit split the bitmap

func BMXOr

func BMXOr(bms ...*roaring.Bitmap) *roaring.Bitmap

BMXOr bitmap xor (A union B) - (A and B)

func BMXOrInterface

func BMXOrInterface(bms ...interface{}) *roaring.Bitmap

BMXOrInterface bitmap xor using interface{}

func ExtractJSONField

func ExtractJSONField(src []byte, paths ...string) []byte

ExtractJSONField returns the field value in the json

func MustMarshalBM

func MustMarshalBM(bm *roaring.Bitmap) []byte

MustMarshalBM must marshal BM

func MustParseBM

func MustParseBM(data []byte) *roaring.Bitmap

MustParseBM parse a bitmap

func MustParseBMTo

func MustParseBMTo(data []byte, bm *roaring.Bitmap)

MustParseBMTo parse a bitmap

func PrintVersion

func PrintVersion()

PrintVersion Print out version information

func ReleaseBuf

func ReleaseBuf(value *bytes.Buffer)

ReleaseBuf release a bitmap

Types

type BSI

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

BSI bitmap based kv

func NewBSI

func NewBSI(bitSize int) *BSI

NewBSI creates BSI

func (*BSI) Clone

func (b *BSI) Clone() *BSI

Clone returns BSI copy from current

func (*BSI) Del

func (b *BSI) Del(k uint32) error

Del remove k from bsi

func (*BSI) Get

func (b *BSI) Get(k uint32) (int64, bool)

Get returns the value of k

func (*BSI) Marshal

func (b *BSI) Marshal() ([]byte, error)

Marshal marshal

func (*BSI) Set

func (b *BSI) Set(k uint32, v int64) error

Set set int64 to bsi

func (*BSI) Unmarshal

func (b *BSI) Unmarshal(data []byte) error

Unmarshal un marshal

type Cache

type Cache struct {
	sync.RWMutex

	// MaxBytes is the maximum bytes of cache entries before
	// an item is evicted. Zero means no limit.
	MaxBytes uint64

	// OnEvicted optionally specificies a callback function to be
	// executed when an entry is purged from the cache.
	OnEvicted func(key Key, value interface{})
	// contains filtered or unexported fields
}

Cache is an LRU cache.

func NewLRUCache

func NewLRUCache(maxBytes uint64) *Cache

NewLRUCache creates a new Cache. If maxBytes is zero, the cache has no limit and it's assumed that eviction is done by the caller.

func (*Cache) Add

func (c *Cache) Add(key Key, value *roaring.Bitmap, size uint64)

Add adds a value to the cache.

func (*Cache) Clear

func (c *Cache) Clear()

Clear purges all stored items from the cache.

func (*Cache) Get

func (c *Cache) Get(key Key) (value *roaring.Bitmap, ok bool)

Get looks up a key's value from the cache.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of items in the cache.

func (*Cache) Remove

func (c *Cache) Remove(key Key)

Remove removes the provided key from the cache.

type Key

type Key interface{}

A Key may be any value that is comparable. See http://golang.org/ref/spec#Comparison_operators

Jump to

Keyboard shortcuts

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