Documentation ¶
Index ¶
- type BucketSortedMap
- func (sortedMap *BucketSortedMap) ChunksCounts() []uint32
- func (sortedMap *BucketSortedMap) Clear()
- func (sortedMap *BucketSortedMap) Count() uint32
- func (sortedMap *BucketSortedMap) CountSorted() uint32
- func (sortedMap *BucketSortedMap) Get(key string) (BucketSortedMapItem, bool)
- func (sortedMap *BucketSortedMap) GetSnapshotAscending() []BucketSortedMapItem
- func (sortedMap *BucketSortedMap) Has(key string) bool
- func (sortedMap *BucketSortedMap) IterCbSortedAscending(callback SortedMapIterCb)
- func (sortedMap *BucketSortedMap) IterCbSortedDescending(callback SortedMapIterCb)
- func (sortedMap *BucketSortedMap) Keys() []string
- func (sortedMap *BucketSortedMap) KeysSorted() []string
- func (sortedMap *BucketSortedMap) NotifyScoreChange(item BucketSortedMapItem)
- func (sortedMap *BucketSortedMap) NotifyScoreChangeByKey(key string)
- func (sortedMap *BucketSortedMap) Remove(key string)
- func (sortedMap *BucketSortedMap) ScoreChunksCounts() []uint32
- func (sortedMap *BucketSortedMap) Set(item BucketSortedMapItem)
- type BucketSortedMapItem
- type ConcurrentMap
- func (m *ConcurrentMap) Clear()
- func (m *ConcurrentMap) Count() int
- func (m *ConcurrentMap) Get(key string) (interface{}, bool)
- func (m *ConcurrentMap) Has(key string) bool
- func (m *ConcurrentMap) IterCb(fn IterCb)
- func (m *ConcurrentMap) Keys() []string
- func (m *ConcurrentMap) Remove(key string)
- func (m *ConcurrentMap) Set(key string, value interface{})
- func (m *ConcurrentMap) SetIfAbsent(key string, value interface{}) bool
- type IterCb
- type MapChunk
- type SortedMapIterCb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BucketSortedMap ¶
type BucketSortedMap struct {
// contains filtered or unexported fields
}
BucketSortedMap is
func NewBucketSortedMap ¶
func NewBucketSortedMap(nChunks uint32, nScoreChunks uint32) *BucketSortedMap
NewBucketSortedMap creates a new map.
func (*BucketSortedMap) ChunksCounts ¶
func (sortedMap *BucketSortedMap) ChunksCounts() []uint32
ChunksCounts returns the number of elements by chunk
func (*BucketSortedMap) Count ¶
func (sortedMap *BucketSortedMap) Count() uint32
Count returns the number of elements within the map
func (*BucketSortedMap) CountSorted ¶
func (sortedMap *BucketSortedMap) CountSorted() uint32
CountSorted returns the number of sorted elements within the map
func (*BucketSortedMap) Get ¶
func (sortedMap *BucketSortedMap) Get(key string) (BucketSortedMapItem, bool)
Get retrieves an element from map under given key.
func (*BucketSortedMap) GetSnapshotAscending ¶
func (sortedMap *BucketSortedMap) GetSnapshotAscending() []BucketSortedMapItem
GetSnapshotAscending gets a snapshot of the items This applies a read lock on all chunks, so that they aren't mutated during snapshot
func (*BucketSortedMap) Has ¶
func (sortedMap *BucketSortedMap) Has(key string) bool
Has looks up an item under specified key
func (*BucketSortedMap) IterCbSortedAscending ¶
func (sortedMap *BucketSortedMap) IterCbSortedAscending(callback SortedMapIterCb)
IterCbSortedAscending iterates over the sorted elements in the map
func (*BucketSortedMap) IterCbSortedDescending ¶
func (sortedMap *BucketSortedMap) IterCbSortedDescending(callback SortedMapIterCb)
IterCbSortedDescending iterates over the sorted elements in the map
func (*BucketSortedMap) Keys ¶
func (sortedMap *BucketSortedMap) Keys() []string
Keys returns all keys as []string
func (*BucketSortedMap) KeysSorted ¶
func (sortedMap *BucketSortedMap) KeysSorted() []string
KeysSorted returns all keys of the sorted items as []string
func (*BucketSortedMap) NotifyScoreChange ¶
func (sortedMap *BucketSortedMap) NotifyScoreChange(item BucketSortedMapItem)
NotifyScoreChange moves or adds the item to the corresponding score chunk
func (*BucketSortedMap) NotifyScoreChangeByKey ¶
func (sortedMap *BucketSortedMap) NotifyScoreChangeByKey(key string)
NotifyScoreChangeByKey moves or adds the item to the corresponding score chunk
func (*BucketSortedMap) Remove ¶
func (sortedMap *BucketSortedMap) Remove(key string)
Remove removes an element from the map
func (*BucketSortedMap) ScoreChunksCounts ¶
func (sortedMap *BucketSortedMap) ScoreChunksCounts() []uint32
ScoreChunksCounts returns the number of elements by chunk
func (*BucketSortedMap) Set ¶
func (sortedMap *BucketSortedMap) Set(item BucketSortedMapItem)
Set puts the item in the map This doesn't add the item to the score chunks (not necessary)
type BucketSortedMapItem ¶
type BucketSortedMapItem interface { GetKey() string ComputeScore() uint32 GetScoreChunk() *MapChunk SetScoreChunk(*MapChunk) ScoreChangeInProgressFlag() *atomic.Flag }
BucketSortedMapItem is
type ConcurrentMap ¶
type ConcurrentMap struct {
// contains filtered or unexported fields
}
ConcurrentMap is a thread safe map of type string:Anything. To avoid lock bottlenecks this map is divided to several map chunks.
func NewConcurrentMap ¶
func NewConcurrentMap(nChunks uint32) *ConcurrentMap
NewConcurrentMap creates a new concurrent map.
func (*ConcurrentMap) Count ¶
func (m *ConcurrentMap) Count() int
Count returns the number of elements within the map
func (*ConcurrentMap) Get ¶
func (m *ConcurrentMap) Get(key string) (interface{}, bool)
Get retrieves an element from map under given key.
func (*ConcurrentMap) Has ¶
func (m *ConcurrentMap) Has(key string) bool
Has looks up an item under specified key.
func (*ConcurrentMap) IterCb ¶
func (m *ConcurrentMap) IterCb(fn IterCb)
IterCb iterates over the map (cheapest way to read all elements in a map)
func (*ConcurrentMap) Keys ¶
func (m *ConcurrentMap) Keys() []string
Keys returns all keys as []string
func (*ConcurrentMap) Remove ¶
func (m *ConcurrentMap) Remove(key string)
Remove removes an element from the map.
func (*ConcurrentMap) Set ¶
func (m *ConcurrentMap) Set(key string, value interface{})
Set sets the given value under the specified key.
func (*ConcurrentMap) SetIfAbsent ¶
func (m *ConcurrentMap) SetIfAbsent(key string, value interface{}) bool
SetIfAbsent sets the given value under the specified key if no value was associated with it.
type SortedMapIterCb ¶
type SortedMapIterCb func(key string, value BucketSortedMapItem)
SortedMapIterCb is an iterator callback