Documentation ¶
Index ¶
- Constants
- Variables
- func Decode(buf []byte, v proto.Message) error
- func DecodeColumnValue(buf []byte, col *metapb.Column) ([]byte, interface{}, error)
- func DecodePrimaryKey(buf []byte, col *metapb.Column) ([]byte, []byte, error)
- func DecodePrimaryKey2(buf []byte, col *metapb.Column) ([]byte, interface{}, error)
- func DecodeStorePrefix(buff []byte) (prefix uint8, table_id uint64, err error)
- func DecodeValue2(buf []byte) ([]byte, uint32, []byte, encoding.Type, error)
- func Encode(v proto.Message) ([]byte, error)
- func EncodeColumnValue(buf []byte, col *metapb.Column, sval []byte) ([]byte, error)
- func EncodePrimaryKey(buf []byte, col *metapb.Column, sval []byte) ([]byte, error)
- func EncodeStorePrefix(prefix uint8, table_id uint64) []byte
- func EncodeValue2(buf []byte, colId uint32, typ encoding.Type, sval []byte) ([]byte, error)
- func ExecuteInParallel(q *Queue, fn func(interface{}))
- func GetIpFromContext(ctx context.Context) string
- func GetLocalIps() []string
- func Hash(data []byte, seed uint32) uint32
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func RandomBytes(r *rand.Rand, dst []byte)
- func ShorteNBytes(bytes int) string
- func SliceToString(b []byte) (s string)
- func StringToSlice(s string) (b []byte)
- type BasicReleaser
- type Buffer
- func (b *Buffer) Alloc(n int) []byte
- func (b *Buffer) Bytes() []byte
- func (b *Buffer) Grow(n int)
- func (b *Buffer) Len() int
- func (b *Buffer) Next(n int) []byte
- func (b *Buffer) Read(p []byte) (n int, err error)
- func (b *Buffer) ReadByte() (c byte, err error)
- func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)
- func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error)
- func (b *Buffer) Reset()
- func (b *Buffer) String() string
- func (b *Buffer) Truncate(n int)
- func (b *Buffer) Write(p []byte) (n int, err error)
- func (b *Buffer) WriteByte(c byte) error
- func (b *Buffer) WriteTo(w io.Writer) (n int64, err error)
- type BufferPool
- type ByteSize
- type CRC
- type Clocker
- type Duration
- type Int64Slice
- type KeyPair
- type KeyPairSlice
- type NoopReleaser
- type OffsetQueue
- type Queue
- func (q *Queue) Dispose() []interface{}
- func (q *Queue) Disposed() bool
- func (q *Queue) Empty() bool
- func (q *Queue) Get(number int64, items []interface{}) (int64, error)
- func (q *Queue) Len() int64
- func (q *Queue) Peek() (interface{}, error)
- func (q *Queue) Poll(number int64, items []interface{}, timeout time.Duration) (int64, error)
- func (q *Queue) Put(items ...interface{}) error
- func (q *Queue) PutOrUpdate(cmp func(interface{}, interface{}) bool, item interface{}) error
- type Range
- type ReleaseSetter
- type Releaser
- type StringSlice
Constants ¶
const ( Store_Prefix_Invalid uint8 = 0 Store_Prefix_KV uint8 = 1 Store_Prefix_Range uint8 = 2 Store_Prefix_RaftLog uint8 = 3 )
const ( KB = 1 << (10 * iota) MB GB )
const MinRead = 512
const TTL_COL_NAME string = "ttl"
Variables ¶
var ( // ErrDisposed is returned when an operation is performed on a disposed // queue. ErrDisposed = errors.New(`queue: disposed`) // ErrTimeout is returned when an applicable queue operation times out. ErrTimeout = errors.New(`queue: poll timed out`) // ErrEmptyQueue is returned when an non-applicable queue operation was called // due to the queue's empty item state ErrEmptyQueue = errors.New(`queue: empty queue`) )
var ( ErrReleased = errors.New("fbase/util.Releaser: resource already relesed") ErrHasReleaser = errors.New("fbase/util.Releaser: already defined") )
Functions ¶
func DecodeColumnValue ¶
DecodeColumnValue 解码列
func DecodePrimaryKey ¶ added in v0.6.3
EncodePrimaryKey 编码主键列 不编码列ID 保持排序属性
func DecodePrimaryKey2 ¶ added in v0.6.3
EncodePrimaryKey 编码主键列 不编码列ID 保持排序属性
func DecodeStorePrefix ¶
func DecodeValue2 ¶ added in v0.6.3
func EncodeColumnValue ¶
EncodeColumnValue 编码列 先列ID再列值 Note: 编码后不保持排序属性(即如果a > b, 那么编码后的字节数组 bytes.Compare(encA, encB) >0 不一定成立)
func EncodePrimaryKey ¶
EncodePrimaryKey 编码主键列 不编码列ID 保持排序属性
func EncodeStorePrefix ¶
func EncodeValue2 ¶ added in v0.6.3
func ExecuteInParallel ¶
func ExecuteInParallel(q *Queue, fn func(interface{}))
ExecuteInParallel will (in parallel) call the provided function with each item in the queue until the queue is exhausted. When the queue is exhausted execution is complete and all goroutines will be killed. This means that the queue will be disposed so cannot be used again.
func GetIpFromContext ¶
func GetLocalIps ¶
func GetLocalIps() []string
func SliceToString ¶
SliceToString slice to string with out data copy
func StringToSlice ¶
StringToSlice string to slice with out data copy
Types ¶
type BasicReleaser ¶
type BasicReleaser struct {
// contains filtered or unexported fields
}
func (*BasicReleaser) Release ¶
func (r *BasicReleaser) Release()
func (*BasicReleaser) Released ¶
func (r *BasicReleaser) Released() bool
func (*BasicReleaser) SetReleaser ¶
func (r *BasicReleaser) SetReleaser(releaser Releaser)
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool is a 'buffer pool'.
func NewBufferPool ¶
func NewBufferPool(baseline int) *BufferPool
NewBufferPool creates a new initialized 'buffer pool'.
func (*BufferPool) Close ¶
func (p *BufferPool) Close()
func (*BufferPool) Get ¶
func (p *BufferPool) Get(n int) []byte
Get returns buffer with length of n.
func (*BufferPool) String ¶
func (p *BufferPool) String() string
type ByteSize ¶
type ByteSize uint64
ByteSize is a retype uint64 for TOML and JSON.
func (ByteSize) MarshalJSON ¶
MarshalJSON returns the size as a JSON string.
func (*ByteSize) UnmarshalJSON ¶
UnmarshalJSON parses a JSON string into the bytesize.
func (*ByteSize) UnmarshalText ¶
UnmarshalText parses a Toml string into the bytesize.
type Clocker ¶
type Clocker interface {
Now() uint64
}
func NewIncrementSeqClock ¶
func NewIncrementSeqClock() Clocker
type Duration ¶
Duration is a wrapper of time.Duration for TOML and JSON.
func NewDuration ¶
NewDuration creates a Duration from time.Duration.
func (*Duration) MarshalJSON ¶
MarshalJSON returns the duration as a JSON string.
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON parses a JSON string into the duration.
func (*Duration) UnmarshalText ¶
UnmarshalText parses a TOML string into the duration.
type Int64Slice ¶
type Int64Slice []int64
func (Int64Slice) Len ¶
func (p Int64Slice) Len() int
func (Int64Slice) Less ¶
func (p Int64Slice) Less(i, j int) bool
func (Int64Slice) Swap ¶
func (p Int64Slice) Swap(i, j int)
type KeyPairSlice ¶
type KeyPairSlice []KeyPair
func (KeyPairSlice) Get ¶
func (slice KeyPairSlice) Get(i int) KeyPair
func (KeyPairSlice) Len ¶
func (slice KeyPairSlice) Len() int
func (KeyPairSlice) Less ¶
func (slice KeyPairSlice) Less(i, j int) bool
func (KeyPairSlice) Swap ¶
func (slice KeyPairSlice) Swap(i, j int)
type NoopReleaser ¶
type NoopReleaser struct{}
func (NoopReleaser) Release ¶
func (NoopReleaser) Release()
type OffsetQueue ¶
OffsetQueue is a queue for sync.
func (*OffsetQueue) Add ¶
func (q *OffsetQueue) Add(item interface{}) uint64
Add add a item to the queue
func (*OffsetQueue) Get ¶
func (q *OffsetQueue) Get(offset uint64) ([]interface{}, uint64)
Get returns all the items after the offset, and remove all items before this offset
func (*OffsetQueue) GetMaxOffset ¶
func (q *OffsetQueue) GetMaxOffset() uint64
GetMaxOffset returns the max offset in the queue
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Queue is the struct responsible for tracking the state of the queue.
func (*Queue) Dispose ¶
func (q *Queue) Dispose() []interface{}
Dispose will dispose of this queue and returns the items disposed. Any subsequent calls to Get or Put will return an error.
func (*Queue) Disposed ¶
Disposed returns a bool indicating if this queue has had disposed called on it.
func (*Queue) Get ¶
Get retrieves items from the queue. If there are some items in the queue, get will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue.
func (*Queue) Peek ¶
Peek returns a the first item in the queue by value without modifying the queue.
func (*Queue) Poll ¶
Poll retrieves items from the queue. If there are some items in the queue, Poll will return a number UP TO the number passed in as a parameter. If no items are in the queue, this method will pause until items are added to the queue or the provided timeout is reached. A non-positive timeout will block until items are added. If a timeout occurs, ErrTimeout is returned.
func (*Queue) PutOrUpdate ¶
PutOrUpdate will add the specified item to the queue, update it if exists
type Range ¶
func BytesPrefix ¶
type ReleaseSetter ¶
type ReleaseSetter interface {
SetReleaser(releaser Releaser)
}
type StringSlice ¶
type StringSlice []string
StringSlice is more friendly to json encode/decode
func (StringSlice) MarshalJSON ¶
func (s StringSlice) MarshalJSON() ([]byte, error)
MarshalJSON returns the size as a JSON string.
func (*StringSlice) UnmarshalJSON ¶
func (s *StringSlice) UnmarshalJSON(text []byte) error
UnmarshalJSON parses a JSON string into the bytesize.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package apd implements arbitrary-precision decimals.
|
Package apd implements arbitrary-precision decimals. |
Package assert contains functions for making assertions in unit tests From github.com/docker/docker/pkg/testutil/assert
|
Package assert contains functions for making assertions in unit tests From github.com/docker/docker/pkg/testutil/assert |
deepcopy deep copies maps, slices, etc.
|
deepcopy deep copies maps, slices, etc. |
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf.
|
Package hlc implements the Hybrid Logical Clock outlined in "Logical Physical Clocks and Consistent Snapshots in Globally Distributed Databases", available online at http://www.cse.buffalo.edu/tech-reports/2014-04.pdf. |
structure
|
|
maps/treemap
Implements a map backed by llrb tree.
|
Implements a map backed by llrb tree. |
trees/llrbtree
Implements Left-Leaning Red Black trees.
|
Implements Left-Leaning Red Black trees. |