Documentation ¶
Index ¶
- func AssertTrue(b bool)
- func AssertTruef(b bool, format string, a ...interface{})
- func Ceil(size uint32, align uint32) uint32
- func Check(err error)
- func EqualUint32(a, b []uint32) bool
- func Floor(size uint32, align uint32) uint32
- func HumanReadableSize(t uint64) string
- func HumanReadableThroughput(t float64) string
- func Max(a, b int) int
- func Max64(a, b int64) int64
- func Min(a, b int) int
- func MustMarshal(msg proto.Message) []byte
- func MustUnMarshal(data []byte, msg proto.Message)
- func NewMemory(size int) *memory
- func ParseReplicationString(replication string) (int, int, error)
- func SetRandStringBytes(data []byte)
- func SizeOfBlocks(blocks [][]byte) uint32
- func SizeVarint(x uint64) (n int)
- func SplitAndTrim(s string, sep string) []string
- type CRC
- type FileNameSplitAlogrithm
- type HexStringSplitAlgorithm
- type HistogramStatus
- type Index
- type IndexFunc
- type Indexer
- type Indexers
- type Indices
- type KeyError
- type KeyFunc
- type LockedSource
- type PrefixSplitAlgorithm
- type RandomTicker
- type Range
- type Result
- type SafeMutex
- type SplitAlgorithm
- type Stopper
- type Store
- type ThreadSafeStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertTrue ¶
func AssertTrue(b bool)
AssertTrue asserts that b is true. Otherwise, it would log fatal.
func AssertTruef ¶
func EqualUint32 ¶
func HumanReadableSize ¶
func HumanReadableThroughput ¶
func MustMarshal ¶
func MustUnMarshal ¶
func SetRandStringBytes ¶
func SetRandStringBytes(data []byte)
func SizeOfBlocks ¶
func SizeVarint ¶
func SplitAndTrim ¶
Types ¶
type FileNameSplitAlogrithm ¶
type FileNameSplitAlogrithm struct {
// contains filtered or unexported fields
}
func (*FileNameSplitAlogrithm) Split ¶
func (a *FileNameSplitAlogrithm) Split(start, end []byte, numSplits int) ([]Range, error)
func (*FileNameSplitAlogrithm) SplitAllRegions ¶
func (a *FileNameSplitAlogrithm) SplitAllRegions(numSplits int) ([]Range, error)
type HexStringSplitAlgorithm ¶
type HexStringSplitAlgorithm struct{}
func NewHexStringSplitAlgorithm ¶
func NewHexStringSplitAlgorithm() *HexStringSplitAlgorithm
func (*HexStringSplitAlgorithm) Split ¶
func (algo *HexStringSplitAlgorithm) Split(start, end []byte, numSplits int) ([]Range, error)
split's code is from https://github.com/apache/hbase/blob/35aa57e4452c6f0a7f5037371edca64163913345/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java start and end must be hex string
func (*HexStringSplitAlgorithm) SplitAllRegions ¶
func (algo *HexStringSplitAlgorithm) SplitAllRegions(numSplits int) ([]Range, error)
type HistogramStatus ¶
type HistogramStatus struct {
// contains filtered or unexported fields
}
func NewLantencyStatus ¶
func NewLantencyStatus(start int64, end int64) *HistogramStatus
func (*HistogramStatus) Histgram ¶
func (ls *HistogramStatus) Histgram(percentiles []float64, w io.Writer) []int64
func (*HistogramStatus) Record ¶
func (ls *HistogramStatus) Record(n int64) error
type Indexer ¶
type Indexer interface { Store // Index returns the stored objects whose set of indexed values // intersects the set of indexed values of the given object, for // the named index Index(indexName string, obj interface{}) ([]interface{}, error) // IndexKeys returns the storage keys of the stored objects whose // set of indexed values for the named index includes the given // indexed value IndexKeys(indexName, indexedValue string) ([]string, error) // ListIndexFuncValues returns all the indexed values of the given index ListIndexFuncValues(indexName string) []string // ByIndex returns the stored objects whose set of indexed values // for the named index includes the given indexed value ByIndex(indexName, indexedValue string) ([]interface{}, error) // GetIndexer return the indexers GetIndexers() Indexers // AddIndexers adds more indexers to this store. If you call this after you already have data // in the store, the results are undefined. AddIndexers(newIndexers Indexers) error }
func NewIndexer ¶
NewIndexer returns an Indexer implemented simply with a map and a lock.
type KeyError ¶
type KeyError struct { Obj interface{} Err error }
KeyError will be returned any time a KeyFunc gives an error; it includes the object at fault.
type KeyFunc ¶
KeyFunc knows how to make a key from an object. Implementations should be deterministic.
type LockedSource ¶
type LockedSource struct {
// contains filtered or unexported fields
}
thread-safe rand
func (*LockedSource) Int63 ¶
func (r *LockedSource) Int63() int64
func (*LockedSource) Seed ¶
func (r *LockedSource) Seed(seed int64)
type PrefixSplitAlgorithm ¶
type PrefixSplitAlgorithm struct {
// contains filtered or unexported fields
}
func NewPrefixSplitAlgorithm ¶
func NewPrefixSplitAlgorithm(prefixs [][]byte, numSplits int, endfix SplitAlgorithm) *PrefixSplitAlgorithm
func (*PrefixSplitAlgorithm) Split ¶
func (algo *PrefixSplitAlgorithm) Split(start, end []byte, numSplits int) ([]Range, error)
func (*PrefixSplitAlgorithm) SplitAllReginos ¶
func (algo *PrefixSplitAlgorithm) SplitAllReginos(numSplits int) ([]Range, error)
type RandomTicker ¶
RandomTicker is similar to time.Ticker but ticks at random intervals between the min and max duration values (stored internally as int64 nanosecond counts).
func NewRandomTicker ¶
func NewRandomTicker(min, max time.Duration) *RandomTicker
NewRandomTicker returns a pointer to an initialized instance of the RandomTicker. Min and max are durations of the shortest and longest allowed ticks. Ticker will run in a goroutine until explicitly stopped.
func (*RandomTicker) Stop ¶
func (rt *RandomTicker) Stop()
Stop terminates the ticker goroutine and closes the C channel.
type SafeMutex ¶
type SafeMutex struct {
// contains filtered or unexported fields
}
SafeMutex can be used in place of sync.RWMutex. It allows code to assert whether the mutex is locked.
func (*SafeMutex) AlreadyLocked ¶
AlreadyLocked returns true if safe mutex is already being held.
func (*SafeMutex) AssertLock ¶
func (s *SafeMutex) AssertLock()
AssertLock asserts whether the lock is being held.
func (*SafeMutex) AssertRLock ¶
func (s *SafeMutex) AssertRLock()
AssertRLock asserts whether the reader lock is being held.
type SplitAlgorithm ¶
type Stopper ¶
type Stopper struct {
// contains filtered or unexported fields
}
Stopper is a manager struct for managing worker goroutines.
func (*Stopper) Close ¶
func (s *Stopper) Close()
Close closes the internal shouldStopc chan struct{} to signal all worker goroutines that they should stop.
func (*Stopper) RunWorker ¶
func (s *Stopper) RunWorker(f func())
RunWorker creates a new goroutine and invoke the f func in that new worker goroutine.
func (*Stopper) ShouldStop ¶
func (s *Stopper) ShouldStop() <-chan struct{}
ShouldStop returns a chan struct{} used for indicating whether the Stop() function has been called on Stopper.
type Store ¶
type Store interface { // Add adds the given object to the accumulator associated with the given object's key Add(obj interface{}) error // Update updates the given object in the accumulator associated with the given object's key Update(obj interface{}) error // Delete deletes the given object from the accumulator associated with the given object's key Delete(obj interface{}) error // List returns a list of all the currently non-empty accumulators List() []interface{} // ListKeys returns a list of all the keys currently associated with non-empty accumulators ListKeys() []string // Get returns the accumulator associated with the given object's key Get(obj interface{}) (item interface{}, exists bool, err error) // GetByKey returns the accumulator associated with the given key GetByKey(key string) (item interface{}, exists bool, err error) // Replace will delete the contents of the store, using instead the // given list. Store takes ownership of the list, you should not reference // it after calling this function. Replace([]interface{}, string) error // Resync is meaningless in the terms appearing here but has // meaning in some implementations that have non-trivial // additional behavior (e.g., DeltaFIFO). Resync() error }
Store is a generic object storage and processing interface. A Store holds a map from string keys to accumulators, and has operations to add, update, and delete a given object to/from the accumulator currently associated with a given key. A Store also knows how to extract the key from a given object, so many operations are given only the object.
In the simplest Store implementations each accumulator is simply the last given object, or empty after Delete, and thus the Store's behavior is simple storage.
Reflector knows how to watch a server and update a Store. This package provides a variety of implementations of Store.
type ThreadSafeStore ¶
type ThreadSafeStore interface { Add(key string, obj interface{}) Update(key string, obj interface{}) Delete(key string) Get(key string) (item interface{}, exists bool) List() []interface{} ListKeys() []string Replace(map[string]interface{}, string) Index(indexName string, obj interface{}) ([]interface{}, error) IndexKeys(indexName, indexKey string) ([]string, error) ListIndexFuncValues(name string) []string ByIndex(indexName, indexKey string) ([]interface{}, error) GetIndexers() Indexers // AddIndexers adds more indexers to this store. If you call this after you already have data // in the store, the results are undefined. AddIndexers(newIndexers Indexers) error // Resync is a no-op and is deprecated Resync() error }
ThreadSafeStore is an interface that allows concurrent indexed access to a storage backend. It is like Indexer but does not (necessarily) know how to extract the Store key from a given object.
TL;DR caveats: you must not modify anything returned by Get or List as it will break the indexing feature in addition to not being thread safe.
The guarantees of th`read safety provided by List/Get are only valid if the caller treats returned items as read-only. For example, a pointer inserted in the store through `Add` will be returned as is by `Get`. Multiple clients might invoke `Get` on the same key and modify the pointer in a non-thread-safe way. Also note that modifying objects stored by the indexers (if any) will *not* automatically lead to a re-index. So it's not a good idea to directly modify the objects returned by Get/List, in general.
func NewThreadSafeStore ¶
func NewThreadSafeStore(indexers Indexers, indices Indices) ThreadSafeStore
NewThreadSafeStore creates a new instance of ThreadSafeStore.