ds

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultShardCount = 32
)

Variables

This section is empty.

Functions

func SimpleSharding

func SimpleSharding(key uint32) uint32

Types

type AdaptiveRadixTree

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

func NewART

func NewART() *AdaptiveRadixTree

func (*AdaptiveRadixTree) Delete

func (t *AdaptiveRadixTree) Delete(key []byte) (val interface{}, updated bool)

func (*AdaptiveRadixTree) Get

func (t *AdaptiveRadixTree) Get(key []byte) interface{}

func (*AdaptiveRadixTree) Iterator

func (t *AdaptiveRadixTree) Iterator() art.Iterator

func (*AdaptiveRadixTree) PrefixScan

func (t *AdaptiveRadixTree) PrefixScan(prefix []byte, count int) (keys [][]byte)

PrefixScan returns keys start with specific prefix Count refers to the maximum number of retrieved keys. No limitation if count is smaller than 0.

func (*AdaptiveRadixTree) Put

func (t *AdaptiveRadixTree) Put(key []byte, value interface{}) (oldVal interface{}, updated bool)

func (*AdaptiveRadixTree) Size

func (t *AdaptiveRadixTree) Size() int

type ConcurrentMap

type ConcurrentMap[K comparable] struct {
	// contains filtered or unexported fields
}

func NewConcurrentMap

func NewConcurrentMap(mapShardCount int) *ConcurrentMap[string]

NewConcurrentMap returns a ConcurrentMap[string] with string keys by default.

func NewWithCustomShardingFunction

func NewWithCustomShardingFunction[K comparable](mapShardCount int, sharding func(key K) uint32) *ConcurrentMap[K]

NewWithCustomShardingFunction creates a new concurrent map.

func (*ConcurrentMap[K]) Get

func (cm *ConcurrentMap[K]) Get(key K) (any, bool)

Get gets the value under a given key.

func (*ConcurrentMap[K]) GetShard

func (cm *ConcurrentMap[K]) GetShard(key K) *MapShard[K]

GetShard returns the MapShard under the given key.

func (*ConcurrentMap[K]) GetShardByReading

func (cm *ConcurrentMap[K]) GetShardByReading(key K) *MapShard[K]

GetShardByReading returns the MapShard under the given key after RLocking. Remember to unlock the shard!

func (*ConcurrentMap[K]) GetShardByWriting

func (cm *ConcurrentMap[K]) GetShardByWriting(key K) *MapShard[K]

GetShardByWriting returns the MapShard under the given key after Locking. Remember to unlock the shard!

func (*ConcurrentMap[K]) Has

func (cm *ConcurrentMap[K]) Has(key K) bool

Has returns if the map contains a specific key.

func (*ConcurrentMap[K]) Pop

func (cm *ConcurrentMap[K]) Pop(key K) (any, bool)

Pop deletes an element from the map and returns it.

func (*ConcurrentMap[K]) Remove

func (cm *ConcurrentMap[K]) Remove(key K)

Remove deletes an element from the map.

func (*ConcurrentMap[K]) Set

func (cm *ConcurrentMap[K]) Set(key K, value any)

Set sets the key and value under a specific MapShard.

func (*ConcurrentMap[K]) Size

func (cm *ConcurrentMap[K]) Size() int

Size returns the number of keys

type MapShard

type MapShard[K comparable] struct {
	sync.RWMutex // r&w lock for every shard
	// contains filtered or unexported fields
}

func (*MapShard[K]) Get

func (ms *MapShard[K]) Get(key K) (any, bool)

Get gets the value under a given key.

func (*MapShard[K]) Has

func (ms *MapShard[K]) Has(key K) bool

Has returns if the map contains a specific key.

func (*MapShard[K]) Pop

func (ms *MapShard[K]) Pop(key K) (any, bool)

Pop deletes an element from the map and returns it.

func (*MapShard[K]) Remove

func (ms *MapShard[K]) Remove(key K)

Remove deletes an element from the map.

func (*MapShard[K]) Set

func (ms *MapShard[K]) Set(key K, value any)

Set sets the key and value under a specific MapShard.

Jump to

Keyboard shortcuts

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