Documentation ¶
Index ¶
- Constants
- Variables
- func Compare(cmp CompareFn, this, that unsafe.Pointer) int
- func CompareBS(this, that unsafe.Pointer) int
- func CompareBytes(this, that unsafe.Pointer) int
- func CompareInt(this, that unsafe.Pointer) int
- func NewByteKeyItem(k []byte) unsafe.Pointer
- type AcceptFn
- type AccessBarrier
- type ActionBuffer
- type BarrierSession
- type BarrierSessionDestructor
- type BatchOpCallback
- type BatchOpIterator
- type Builder
- type CompareFn
- type Config
- type FreeFn
- type ItemSizeFn
- type Iterator
- func (it *Iterator) Close()
- func (it *Iterator) Delete()
- func (it *Iterator) Get() unsafe.Pointer
- func (it *Iterator) GetNode() *Node
- func (it *Iterator) Next()
- func (it *Iterator) Seek(itm unsafe.Pointer) bool
- func (it *Iterator) SeekFirst()
- func (it *Iterator) SeekPrev(itm unsafe.Pointer, skip func(unsafe.Pointer) bool)
- func (it *Iterator) SeekWithCmp(itm unsafe.Pointer, cmp CompareFn, eqCmp CompareFn) bool
- func (it *Iterator) SeekWithSkip(itm unsafe.Pointer, skipItm func(unsafe.Pointer) bool) bool
- func (it *Iterator) Valid() bool
- type MallocFn
- type MergeIterator
- type Node
- type NodeCallback
- type NodeRef
- type Segment
- type Skiplist
- func (s *Skiplist) Delete(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) bool
- func (s *Skiplist) DeleteNode(n *Node, cmp CompareFn, buf *ActionBuffer, sts *Stats) bool
- func (s *Skiplist) ExecBatchOps(opItr BatchOpIterator, head, tail *Node, callb BatchOpCallback, cmp CompareFn, ...) error
- func (s *Skiplist) FreeBuf(b *ActionBuffer)
- func (s *Skiplist) FreeNode(n *Node, sts *Stats)
- func (s *Skiplist) GetAccesBarrier() *AccessBarrier
- func (s *Skiplist) GetRangeSplitItems(nways int) []unsafe.Pointer
- func (s *Skiplist) GetStats() StatsReport
- func (s *Skiplist) Insert(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) (success bool)
- func (s *Skiplist) Insert2(itm unsafe.Pointer, inscmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, ...) (*Node, bool)
- func (s *Skiplist) Insert3(itm unsafe.Pointer, insCmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, ...) (*Node, bool)
- func (s *Skiplist) MakeBuf() *ActionBuffer
- func (s *Skiplist) MemoryInUse() int64
- func (s *Skiplist) NewIterator(cmp CompareFn, buf *ActionBuffer) *Iterator
- func (s *Skiplist) NewLevel(randFn func() float32) int
- func (s *Skiplist) Size(n *Node) int
- type Stats
- type StatsReport
- type ValidNodeFn
Constants ¶
const MaxLevel = 32
MaxLevel is the limit for the skiplist levels
Variables ¶
var Debug bool
Debug flag enables additional stats gathering
Functions ¶
func CompareBytes ¶
CompareBytes is a byte item comparator
func CompareInt ¶
CompareInt is a helper integer item comparator
func NewByteKeyItem ¶
NewByteKeyItem creates a new item from bytes
Types ¶
type AccessBarrier ¶
AccessBarrier is the SMR core data structure for the skiplist
func (*AccessBarrier) Acquire ¶
func (ab *AccessBarrier) Acquire() *BarrierSession
Acquire marks enter of an accessor in the skiplist
func (*AccessBarrier) FlushSession ¶
func (ab *AccessBarrier) FlushSession(ref unsafe.Pointer)
FlushSession closes the current barrier session and starts the new session. The caller should provide the destructor pointer for the new session.
func (*AccessBarrier) Release ¶
func (ab *AccessBarrier) Release(bs *BarrierSession)
Release marks leaving of an accessor in the skiplist
type ActionBuffer ¶
type ActionBuffer struct {
// contains filtered or unexported fields
}
ActionBuffer is a temporary buffer used by skiplist operations
type BarrierSession ¶
type BarrierSession struct {
// contains filtered or unexported fields
}
BarrierSession handle tracks the live accessors of a barrier session
type BarrierSessionDestructor ¶
BarrierSessionDestructor is a callback for SMR based reclaim of objects
type BatchOpCallback ¶
type BatchOpIterator ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder performs concurrent bottom-up skiplist build
func NewBuilderWithConfig ¶
NewBuilderWithConfig creates a builder from a config
func (*Builder) NewSegment ¶
NewSegment creates a new skiplist segment
func (*Builder) SetItemSizeFunc ¶
func (b *Builder) SetItemSizeFunc(fn ItemSizeFn)
SetItemSizeFunc configures items size function
type Config ¶
type Config struct { ItemSize ItemSizeFn UseMemoryMgmt bool Malloc MallocFn Free FreeFn BarrierDestructor BarrierSessionDestructor }
Config holds skiplist configuration
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns default skiplist configuration
func (*Config) SetItemSizeFunc ¶
func (cfg *Config) SetItemSizeFunc(fn ItemSizeFn)
SetItemSizeFunc configures item size function
type ItemSizeFn ¶
ItemSizeFn returns size of a skiplist item
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator is used for lookup and range operations on skiplist
func (*Iterator) Delete ¶
func (it *Iterator) Delete()
Delete removes the current item from the skiplist
func (*Iterator) SeekPrev ¶
SeekPrev moves iterator to the provided item or an item less than the lookup item
func (*Iterator) SeekWithCmp ¶
SeekWithCmp moves iterator to a provided item by using custom comparator
func (*Iterator) SeekWithSkip ¶
SeekWithSkip performs Seek() with optional skipping of nodes while reading nodes as part of finding the item.
type MergeIterator ¶
type MergeIterator struct {
// contains filtered or unexported fields
}
MergeIterator aggregates multiple iterators
func NewMergeIterator ¶
func NewMergeIterator(iters []*Iterator) *MergeIterator
NewMergeIterator creates an iterator that merges multiple iterators
func (*MergeIterator) GetNode ¶
func (mit *MergeIterator) GetNode() *Node
GetNode returns node for the current item
func (*MergeIterator) Seek ¶
func (mit *MergeIterator) Seek(itm unsafe.Pointer) bool
Seek moves cursor to the specified item, if present
func (*MergeIterator) SeekFirst ¶
func (mit *MergeIterator) SeekFirst()
SeekFirst moves cursor to the first item
func (*MergeIterator) Valid ¶
func (mit *MergeIterator) Valid() bool
Valid returns false when cursor reaches end
type Node ¶
Node represents skiplist node header
type NodeRef ¶
type NodeRef struct {
// contains filtered or unexported fields
}
NodeRef is a wrapper for node pointer
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
Segment is a skiplist segment
func (*Segment) SetNodeCallback ¶
func (s *Segment) SetNodeCallback(fn NodeCallback)
SetNodeCallback sets callback for segment builder
type Skiplist ¶
Skiplist - core data structure
func NewWithConfig ¶
NewWithConfig creates a config from given config
func (*Skiplist) DeleteNode ¶
DeleteNode an item from the skiplist by specifying its node
func (*Skiplist) ExecBatchOps ¶
func (s *Skiplist) ExecBatchOps(opItr BatchOpIterator, head, tail *Node, callb BatchOpCallback, cmp CompareFn, validNode ValidNodeFn, sts *Stats) error
func (*Skiplist) FreeBuf ¶
func (s *Skiplist) FreeBuf(b *ActionBuffer)
FreeBuf frees an action buffer
func (*Skiplist) GetAccesBarrier ¶
func (s *Skiplist) GetAccesBarrier() *AccessBarrier
GetAccesBarrier returns current active access barrier
func (*Skiplist) GetRangeSplitItems ¶
GetRangeSplitItems returns `nways` split range pivots of the skiplist items Explicit barrier and release should be used by the caller before and after this function call
func (*Skiplist) GetStats ¶
func (s *Skiplist) GetStats() StatsReport
GetStats returns skiplist stats
func (*Skiplist) Insert ¶
func (s *Skiplist) Insert(itm unsafe.Pointer, cmp CompareFn, buf *ActionBuffer, sts *Stats) (success bool)
Insert adds an item into the skiplist
func (*Skiplist) Insert2 ¶
func (s *Skiplist) Insert2(itm unsafe.Pointer, inscmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, randFn func() float32, sts *Stats) (*Node, bool)
Insert2 is a more verbose version of Insert
func (*Skiplist) Insert3 ¶
func (s *Skiplist) Insert3(itm unsafe.Pointer, insCmp CompareFn, eqCmp CompareFn, buf *ActionBuffer, itemLevel int, skipFindPath bool, sts *Stats) (*Node, bool)
Insert3 is more verbose version of Insert2
func (*Skiplist) MakeBuf ¶
func (s *Skiplist) MakeBuf() *ActionBuffer
MakeBuf creates an action buffer
func (*Skiplist) MemoryInUse ¶
MemoryInUse returns memory used by skiplist
func (*Skiplist) NewIterator ¶
func (s *Skiplist) NewIterator(cmp CompareFn, buf *ActionBuffer) *Iterator
NewIterator creates an iterator for skiplist
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
Stats keeps stats for a skiplist instance
type StatsReport ¶
type StatsReport struct { ReadConflicts uint64 InsertConflicts uint64 NextPointersPerNode float64 NodeDistribution [MaxLevel + 1]int64 NodeCount int SoftDeletes int64 Memory int64 NodeAllocs int64 NodeFrees int64 }
StatsReport is used for reporting skiplist statistics
func (*StatsReport) Apply ¶
func (report *StatsReport) Apply(s *Stats)
Apply updates the report with provided paritial stats
func (StatsReport) String ¶
func (report StatsReport) String() string