Documentation ¶
Index ¶
- func BytesHash64(b []byte) int64
- func CreateTLSConfig(caPath, certPath, keyPath string, insecureSkipVerify bool) (*tls.Config, error)
- func DecodeRow(b []byte) (map[int64][]byte, error)
- func EncodeRow(cols [][]byte, colIDs []int64, valBuf []byte) ([]byte, error)
- func Fatal(args ...interface{})
- func Fatalf(format string, args ...interface{})
- func Hash64(n int64) int64
- func RandBytes(r *rand.Rand, b []byte)
- func Slice(s string) (b []byte)
- func String(b []byte) (s string)
- func StringHash64(s string) int64
- type BufPool
- type ConcurrentMap
- func (m ConcurrentMap) Count() int
- func (m ConcurrentMap) Get(key int) (int64, bool)
- func (m ConcurrentMap) GetShard(key int) *ConcurrentMapShared
- func (m ConcurrentMap) Has(key int) bool
- func (m ConcurrentMap) IsEmpty() bool
- func (m ConcurrentMap) Items() map[int]int64
- func (m ConcurrentMap) Iter() <-chan Tupledeprecated
- func (m ConcurrentMap) IterBuffered() <-chan Tuple
- func (m ConcurrentMap) IterCb(fn IterCb)
- func (m ConcurrentMap) Keys() []int
- func (m ConcurrentMap) MSet(data map[int]int64)
- func (m ConcurrentMap) MarshalJSON() ([]byte, error)
- func (m ConcurrentMap) Pop(key int) (v int64, exists bool)
- func (m ConcurrentMap) Remove(key int)
- func (m ConcurrentMap) RemoveCb(key int, cb RemoveCb) bool
- func (m ConcurrentMap) Set(key int, value int64)
- func (m ConcurrentMap) SetIfAbsent(key int, value int64) bool
- func (m ConcurrentMap) Upsert(key int, value int64, cb UpsertCb) (res int64)
- type ConcurrentMapShared
- type FieldPair
- type FieldPairs
- type IterCb
- type RemoveCb
- type RowCodec
- type SpinLock
- type Tuple
- type UpsertCb
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTLSConfig ¶
func CreateTLSConfig(caPath, certPath, keyPath string, insecureSkipVerify bool) (*tls.Config, error)
CreateTLSConfig creats a TLS configuration.
func DecodeRow ¶
DecodeRow decodes a byte slice into columns. Row layout: colID1, value1, colID2, value2, ..... It is a simplified and specialized version of `github.com/pingcap/tidb/tablecodec.DecodeRow`.
func EncodeRow ¶
EncodeRow encodes row data and column ids into a slice of byte. Row layout: colID1, value1, colID2, value2, ... valBuf and values pass by caller, for reducing EncodeRow allocates temporary bufs. If you pass valBuf and values as nil, EncodeRow will allocate it. It is a simplified and specialized version of `github.com/pingcap/tidb/tablecodec.EncodeRow`.
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf prints the message and exits the program.
Types ¶
type BufPool ¶
type BufPool struct {
// contains filtered or unexported fields
}
BufPool is a bytes.Buffer pool
type ConcurrentMap ¶
type ConcurrentMap struct {
// contains filtered or unexported fields
}
A "thread" safe map of type int:int64. To avoid lock bottlenecks this map is dived to several (SHARD_COUNT) map shards.
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 int) (int64, bool)
Get retrieves an element from map under given key.
func (ConcurrentMap) GetShard ¶
func (m ConcurrentMap) GetShard(key int) *ConcurrentMapShared
GetShard returns shard under given key
func (ConcurrentMap) Has ¶
func (m ConcurrentMap) Has(key int) bool
Looks up an item under specified key
func (ConcurrentMap) IsEmpty ¶
func (m ConcurrentMap) IsEmpty() bool
IsEmpty checks if map is empty.
func (ConcurrentMap) Items ¶
func (m ConcurrentMap) Items() map[int]int64
Items returns all items as map[int]int64
func (ConcurrentMap) Iter
deprecated
func (m ConcurrentMap) Iter() <-chan Tuple
Iter returns an iterator which could be used in a for range loop.
Deprecated: using IterBuffered() will get a better performence
func (ConcurrentMap) IterBuffered ¶
func (m ConcurrentMap) IterBuffered() <-chan Tuple
IterBuffered returns a buffered iterator which could be used in a for range loop.
func (ConcurrentMap) IterCb ¶
func (m ConcurrentMap) IterCb(fn IterCb)
Callback based iterator, cheapest way to read all elements in a map.
func (ConcurrentMap) MSet ¶
func (m ConcurrentMap) MSet(data map[int]int64)
func (ConcurrentMap) MarshalJSON ¶
func (m ConcurrentMap) MarshalJSON() ([]byte, error)
Reviles ConcurrentMap "private" variables to json marshal.
func (ConcurrentMap) Pop ¶
func (m ConcurrentMap) Pop(key int) (v int64, exists bool)
Pop removes an element from the map and returns it
func (ConcurrentMap) Remove ¶
func (m ConcurrentMap) Remove(key int)
Remove removes an element from the map.
func (ConcurrentMap) RemoveCb ¶
func (m ConcurrentMap) RemoveCb(key int, cb RemoveCb) bool
RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map)
func (ConcurrentMap) Set ¶
func (m ConcurrentMap) Set(key int, value int64)
Sets the given value under the specified key.
func (ConcurrentMap) SetIfAbsent ¶
func (m ConcurrentMap) SetIfAbsent(key int, value int64) bool
Sets the given value under the specified key if no value was associated with it.
type ConcurrentMapShared ¶
type ConcurrentMapShared struct { // contains filtered or unexported fields }
A "thread" safe int to int64 map.
type FieldPairs ¶
type FieldPairs []FieldPair
FieldPairs implements sort interface for []FieldPair
func NewFieldPairs ¶
func NewFieldPairs(values map[string][]byte) FieldPairs
NewFieldPairs sorts the map by fields and return a sorted slice of FieldPair.
type IterCb ¶
Iterator callback,called for every key,value found in maps. RLock is held for all calls for a given shard therefore callback sess consistent view of a shard, but not across the shards
type RemoveCb ¶
RemoveCb is a callback executed in a map.RemoveCb() call, while Lock is held If returns true, the element will be removed from the map
type RowCodec ¶
type RowCodec struct {
// contains filtered or unexported fields
}
RowCodec is a helper struct to encode and decode TiDB format row
func NewRowCodec ¶
func NewRowCodec(p *properties.Properties) *RowCodec
NewRowCodec creates the RowCodec
type SpinLock ¶
type SpinLock struct {
// contains filtered or unexported fields
}
SpinLock implements a simple atomic spin lock, the zero value for a SpinLock is an unlocked spinlock.
func (*SpinLock) Lock ¶
func (sl *SpinLock) Lock()
Lock locks sl. If the lock is already in use, the caller blocks until Unlock is called
func (*SpinLock) TryLock ¶
TryLock will try to lock sl and return whether it succeed or not without blocking.
func (*SpinLock) Unlock ¶
func (sl *SpinLock) Unlock()
Unlock unlocks sl, unlike [Mutex.Unlock](http://golang.org/pkg/sync/#Mutex.Unlock), there's no harm calling it on an unlocked SpinLock
type Tuple ¶
Used by the Iter & IterBuffered functions to wrap two variables together over a channel,