Documentation
¶
Index ¶
- Variables
- func Addr() *net.TCPAddr
- func CauseBy(err error) error
- func Errorf(format string, args ...interface{}) error
- func Eth0() *net.Interface
- func Fail(t T, args ...interface{})
- func FailNow(t T, args ...interface{})
- func IPv4() net.IP
- func Interface() *net.Interface
- func Interfaces() []net.Interface
- func Join(slice Slice, sep string) string
- func MurmurHash(b []byte) uint32
- func Parse(v url.Values, obj interface{}) error
- func Port() int
- type Assertion
- type Bloom
- type Element
- type Helper
- type Iterator
- type LRU
- func (l *LRU) Add(k, v interface{}) (old interface{}, evict bool)
- func (l *LRU) Exist(k interface{}) (ok bool)
- func (l *LRU) Get(k interface{}) (v interface{}, exist bool)
- func (l *LRU) GetOldest() (k, v interface{}, exist bool)
- func (l *LRU) Len() int
- func (l *LRU) Peek(k interface{}) (v interface{}, exist bool)
- func (l *LRU) Remove(k interface{}) (v interface{}, exist bool)
- func (l *LRU) RemoveOldest() (k, v interface{}, exist bool)
- func (l *LRU) Walk(f func(k, v interface{}))
- type List
- type RadixNode
- func (n *RadixNode) Clone() *RadixNode
- func (n *RadixNode) Get(k []byte) (v interface{}, ok bool)
- func (n *RadixNode) IsLeaf() bool
- func (n *RadixNode) Walk(fn func(k []byte, v interface{}) bool)
- func (n *RadixNode) WalkPath(path []byte, fn func(k []byte, v interface{}) bool)
- func (n *RadixNode) WalkPrefix(prefix []byte, fn func(k []byte, v interface{}) bool)
- type RadixTXN
- func (t *RadixTXN) Commit() *RadixTree
- func (t *RadixTXN) Delete(k []byte) (old interface{})
- func (t *RadixTXN) DeletePrefix(prefix []byte) int
- func (t *RadixTXN) Get(k []byte) (interface{}, bool)
- func (t *RadixTXN) Insert(k []byte, v interface{}) (old interface{})
- func (t *RadixTXN) MemOptimized()
- func (t *RadixTXN) Rollback() *RadixTree
- type RadixTree
- func (t *RadixTree) Get(k []byte) (interface{}, bool)
- func (t *RadixTree) OpenTXN() *RadixTXN
- func (t *RadixTree) Root() *RadixNode
- func (t *RadixTree) Size() int
- func (t *RadixTree) Walk(fn func(k []byte, v interface{}) bool)
- func (t *RadixTree) WalkPath(path []byte, fn func(k []byte, v interface{}) bool)
- func (t *RadixTree) WalkPrefix(prefix []byte, fn func(k []byte, v interface{}) bool)
- type SkipList
- type Slice
- type Stack
- type StackRecord
- type T
- type UUID
Constants ¶
This section is empty.
Variables ¶
var NIL = "00000000-0000-0000-0000-000000000000"
NIL UUID
Functions ¶
func MurmurHash ¶
MurmurHash implements a hashing algorithm similar to the Murmur hash.
Types ¶
type Assertion ¶
type Assertion interface {
IsNil()
IsEmpty()
IsNotNil()
IsNotEmpty()
IsTrue()
IsFalse()
IsEqualTo(expect interface{})
IsNotEqualTo(expect interface{})
IsDeepEqualTo(expect interface{})
IsNotDeepEqualTo(expect interface{})
}
Assertion is the interface for all comparisons.
func AssertThat ¶
AssertThat returns an assertion.
type Bloom ¶
type Bloom []byte
Bloom is the thin wrapper around a byte slice.
type Element ¶
type Element struct {
V interface{}
// contains filtered or unexported fields
}
Element is one holder in the list.
type Helper ¶
type Helper interface {
Helper()
}
Helper marks the calling function as a test helper function.
type Iterator ¶
type Iterator interface {
Next() bool
Value() interface{}
Reverse()
}
Iterator is used to traversing the elements of the list.
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU implements a non-thread safe fixed size LRU cache
func (*LRU) Add ¶
Add adds the k/v pair and returns the old value associated with the given key. It also returns true if the eviction occured.
func (*LRU) Get ¶
Get returns the value associated with the given key. Returns false if the given is not exist.
func (*LRU) Peek ¶
Peek returns the value associated with the given key. Returns false if the given is not exist. But the Peek didn't update the visit(recently used).
func (*LRU) RemoveOldest ¶
RemoveOldest removes oldest k/v pair.
type List ¶
type List struct {
// contains filtered or unexported fields
}
List is a circular doubly-linked list.
This is a figure of 2-elements list:
Front Back ¶
+------+ next +-----+ next +-----+ next +-----+ | dummy| <----> |node1| <----> |node2| <----> |dummy| +------+ prev +-----+ prev +-----+ prev +-----+
^ ^ | | push insert
func (*List) Iterator ¶
Iterator returns a Iterator for traversing the elements of the list from front to back.
type RadixNode ¶
type RadixNode struct {
// contains filtered or unexported fields
}
RadixNode is the note in radix tree.
func (*RadixNode) Get ¶
Get returns the value associated with the given key if the key is exist, otherwise false.
type RadixTXN ¶
type RadixTXN struct {
// contains filtered or unexported fields
}
RadixTXN is a transaction of the RadixDB.
func (*RadixTXN) DeletePrefix ¶
DeletePrefix deletes the k/v pair whose key is started with the given prefix.
func (*RadixTXN) Get ¶
Get returns the value associated with the given key if the key is exist, otherwise false.
func (*RadixTXN) Insert ¶
Insert inserts the k/v pair into the tree and returns the old value associated with the given key if it exists.
func (*RadixTXN) MemOptimized ¶
func (t *RadixTXN) MemOptimized()
MemOptimized will create a cache for reusing the node's clone.
type RadixTree ¶
type RadixTree struct {
// contains filtered or unexported fields
}
RadixTree implements an immutable radix tree and is immutable.
func (*RadixTree) Get ¶
Get returns the value associated with the given key if the key is exist, otherwise false.
func (*RadixTree) OpenTXN ¶
OpenTXN returns a new transaction for inserting or deleting the tree node.
type SkipList ¶
type SkipList struct {
// contains filtered or unexported fields
}
SkipList is a Skip List.
This is a picture of the 2 level skip list(height is 3):
Head Tail +-+ +-+ +-+ | |---------------->|D|--------------------->|I|------------>nil h3/ level2 +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ | |----------->|C|->|D|------>|F|----------->|I|------>|K|-->nil h2/level 1 +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ | |->|A|->|B|->|C|->|D|->|E|->|F|->|G|->|H|->|I|->|J|->|K|-->nil h1/level 0 +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+ +-+
func NewSkipList ¶
NewSkipList return an initialized Skip Skiplist.
func (*SkipList) Exist ¶
Exist returns true if the v is in the skiplist, it means there is a v1 in the skiplist is equal to the v (0 == compare(v, v1)).
func (*SkipList) Find ¶
Find returns an iterator positioned before the first v which is 'greater than or equal to the given v. There may be no such value, in which case the iterator will return false on Next.
type Slice ¶
type Slice interface {
// StringAt returns the value at given position.
StringAt(i int) string
// Len returns the length of slice.
Len() int
}
Slice indicates the object is a slice or array.
type Stack ¶
type Stack []*StackRecord
Stack is error traced info.
func (Stack) PrintGracefully ¶
PrintGracefully returns string with indent.
type StackRecord ¶
StackRecord records the context where error comes from.
func Caller ¶
func Caller(skip int) (r StackRecord, ok bool)
Caller returns the context where this function was called.
type T ¶
type T interface {
Fail()
FailNow()
Log(v ...interface{})
}
T is a interface of the testing.T.
type UUID ¶
type UUID [16]byte
UUID - unique identifier type representing a 128 bit number
