container

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotExistErr = errors.New("not exist")
View Source
var NotPartition = errors.New("not partition")

Functions

This section is empty.

Types

type BlockingKMapContainer

type BlockingKMapContainer struct {
	Tolerate float64
	// contains filtered or unexported fields
}

多线程读写安全的container,支持增量

func CreateBlockingKSetContainer

func CreateBlockingKSetContainer(tolerate float64) *BlockingKMapContainer

func (*BlockingKMapContainer) Del

func (bm *BlockingKMapContainer) Del(key MapKey, value interface{})

func (*BlockingKMapContainer) Get

func (bm *BlockingKMapContainer) Get(key MapKey) (interface{}, error)

func (*BlockingKMapContainer) Len

func (bm *BlockingKMapContainer) Len() int

func (*BlockingKMapContainer) LoadBase

func (bm *BlockingKMapContainer) LoadBase(iterator DataIterator) error

func (*BlockingKMapContainer) LoadInc

func (bm *BlockingKMapContainer) LoadInc(iterator DataIterator) error

func (*BlockingKMapContainer) Range

func (bm *BlockingKMapContainer) Range(f func(key, value interface{}) bool)

func (*BlockingKMapContainer) Set

func (bm *BlockingKMapContainer) Set(key MapKey, value interface{}) error

type BlockingMapContainer

type BlockingMapContainer struct {
	InnerData *ConcurrentSliceMap2

	Tolerate float64
	// contains filtered or unexported fields
}

多线程读写安全的container,支持增量

func CreateBlockingMapContainer

func CreateBlockingMapContainer(numPartision int, tolerate float64) *BlockingMapContainer

func (*BlockingMapContainer) Del

func (bm *BlockingMapContainer) Del(key MapKey, value interface{})

func (*BlockingMapContainer) Get

func (bm *BlockingMapContainer) Get(key MapKey) (interface{}, error)

func (*BlockingMapContainer) Len

func (bm *BlockingMapContainer) Len() int

func (*BlockingMapContainer) LoadBase

func (bm *BlockingMapContainer) LoadBase(iterator DataIterator) error

func (*BlockingMapContainer) LoadInc

func (bm *BlockingMapContainer) LoadInc(iterator DataIterator) error

func (*BlockingMapContainer) Range

func (bm *BlockingMapContainer) Range(f func(key, value interface{}) bool)

func (*BlockingMapContainer) Set

func (bm *BlockingMapContainer) Set(key MapKey, value interface{}) error

type BufferedKListContainer

type BufferedKListContainer struct {
	ErrorNum int
	// contains filtered or unexported fields
}

双bufMap, 仅提供Get/LoadBase接口

func CreateBufferedKListContainer

func CreateBufferedKListContainer() *BufferedKListContainer

func (*BufferedKListContainer) Del

func (bm *BufferedKListContainer) Del(key MapKey, value interface{})

func (*BufferedKListContainer) Get

func (bm *BufferedKListContainer) Get(key MapKey) (interface{}, error)

func (*BufferedKListContainer) LoadBase

func (bm *BufferedKListContainer) LoadBase(iterator DataIterator) error

func (*BufferedKListContainer) LoadInc

func (bm *BufferedKListContainer) LoadInc(iterator DataIterator) error

func (*BufferedKListContainer) Set

func (bm *BufferedKListContainer) Set(key MapKey, value interface{}) error

type BufferedMapContainer

type BufferedMapContainer struct {
	Tolerate float64
	// contains filtered or unexported fields
}

双bufMap, 仅提供Get/LoadBase接口

func (*BufferedMapContainer) Del

func (bm *BufferedMapContainer) Del(key MapKey, value interface{})

func (*BufferedMapContainer) Get

func (bm *BufferedMapContainer) Get(key MapKey) (interface{}, error)

func (*BufferedMapContainer) Len

func (bm *BufferedMapContainer) Len() int

func (*BufferedMapContainer) LoadBase

func (bm *BufferedMapContainer) LoadBase(iterator DataIterator) error

func (*BufferedMapContainer) LoadInc

func (bm *BufferedMapContainer) LoadInc(iterator DataIterator) error

func (*BufferedMapContainer) Range

func (bm *BufferedMapContainer) Range(f func(key, value interface{}) bool)

func (*BufferedMapContainer) Set

func (bm *BufferedMapContainer) Set(key MapKey, value interface{}) error

type ConcurrentSliceMap added in v0.3.1

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

func CreateConcurrentSliceMap added in v0.3.1

func CreateConcurrentSliceMap(lenOfBucket int) *ConcurrentSliceMap

CreateConcurrentSliceMap is to create a ConcurrentSliceMap with the setting number of the partitions & len of the Buckets NumOfPartitions will auto add capacity

func (*ConcurrentSliceMap) Delete added in v0.3.1

func (m *ConcurrentSliceMap) Delete(key interface{})

func (*ConcurrentSliceMap) Len added in v0.3.1

func (m *ConcurrentSliceMap) Len() int

func (*ConcurrentSliceMap) Load added in v0.3.1

func (m *ConcurrentSliceMap) Load(key interface{}) (interface{}, bool)

func (*ConcurrentSliceMap) Range added in v0.3.1

func (m *ConcurrentSliceMap) Range(f func(key, value interface{}) bool)

func (*ConcurrentSliceMap) Store added in v0.3.1

func (m *ConcurrentSliceMap) Store(key interface{}, v interface{})

type ConcurrentSliceMap2 added in v0.3.2

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

func CreateConcurrentSliceMap2 added in v0.3.2

func CreateConcurrentSliceMap2(lenOfBucket int) *ConcurrentSliceMap2

CreateConcurrentSliceMap2 is to create a ConcurrentSliceMap2 with the setting number of the partitions & len of the Buckets NumOfPartitions will auto add capacity

func (*ConcurrentSliceMap2) Delete added in v0.3.2

func (m *ConcurrentSliceMap2) Delete(key interface{})

func (*ConcurrentSliceMap2) Len added in v0.3.2

func (m *ConcurrentSliceMap2) Len() int

func (*ConcurrentSliceMap2) Load added in v0.3.2

func (m *ConcurrentSliceMap2) Load(key interface{}) (interface{}, bool)

func (*ConcurrentSliceMap2) Range added in v0.3.2

func (m *ConcurrentSliceMap2) Range(f func(key, value interface{}) bool)

func (*ConcurrentSliceMap2) Store added in v0.3.2

func (m *ConcurrentSliceMap2) Store(key interface{}, v interface{})

type Container

type Container interface {
	Get(key MapKey) (interface{}, error)
	Set(key MapKey, value interface{}) error
	Del(key MapKey, value interface{})

	Len() int
	Range(f func(key, value interface{}) bool)

	LoadBase(dataIter DataIterator) error
	LoadInc(dataIter DataIterator) error
}

type DataIterator

type DataIterator interface {
	HasNext() (bool, error)
	Next() (DataMode, MapKey, interface{}, error)
}

type DataMode

type DataMode int
const (
	DataModeAdd    DataMode = 0
	DataModeUpdate DataMode = 1
	DataModeDel    DataMode = 2
)

type Int64Key

type Int64Key struct {
	Data int64
}

func I64Key

func I64Key(key int64) *Int64Key

func (*Int64Key) PartitionKey

func (i *Int64Key) PartitionKey() int64

func (*Int64Key) Value

func (i *Int64Key) Value() interface{}

type MapKey

type MapKey interface {
	PartitionKey() int64
	Value() interface{}
}

key of the map, because of go-lang not support generic type, So, here defined an interface for int Data or string Data key

type StringKey

type StringKey struct {
	Data string
}

StringKey is for the string type key

func StrKey

func StrKey(key string) *StringKey

StrKey is to convert a string to StringKey

func (*StringKey) PartitionKey

func (s *StringKey) PartitionKey() int64

PartitionID is created by string's hash

func (*StringKey) Value

func (s *StringKey) Value() interface{}

Value is the raw string

Jump to

Keyboard shortcuts

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