Documentation ¶
Overview ¶
Package sortedmap provides sorted maps implemented as either a Left-Leaning Red-Black Tree (in memory) or a B+Tree (pageable)
Index ¶
- Constants
- Variables
- func CompareByteSlice(key1 Key, key2 Key) (result int, err error)
- func CompareInt(key1 Key, key2 Key) (result int, err error)
- func CompareString(key1 Key, key2 Key) (result int, err error)
- func CompareTime(key1 Key, key2 Key) (result int, err error)
- func CompareUint16(key1 Key, key2 Key) (result int, err error)
- func CompareUint32(key1 Key, key2 Key) (result int, err error)
- func CompareUint64(key1 Key, key2 Key) (result int, err error)
- type BPlusTree
- type BPlusTreeCache
- type BPlusTreeCacheStats
- type BPlusTreeCallbacks
- type Compare
- type DumpCallbacks
- type Key
- type LLRBTree
- type LLRBTreeCallbacks
- type LayoutReport
- type SortedMap
- type Value
Constants ¶
const ( RED = true BLACK = false )
Variables ¶
var OnDiskByteOrder = cstruct.LittleEndian
OnDiskByteOrder specifies the endian-ness expected to be used to persist B+Tree data structures
Functions ¶
Types ¶
type BPlusTree ¶
type BPlusTree interface { SortedMap FetchLocation() (rootObjectNumber uint64, rootObjectOffset uint64, rootObjectLength uint64) FetchLayoutReport() (layoutReport LayoutReport, err error) Flush(andPurge bool) (rootObjectNumber uint64, rootObjectOffset uint64, rootObjectLength uint64, err error) Purge(full bool) (err error) Touch() (err error) TouchItem(thisItemIndexToTouch uint64) (nextItemIndexToTouch uint64, err error) Prune() (err error) Discard() (err error) }
BPlusTree interface declares the available methods available for a B+Tree
func NewBPlusTree ¶
func NewBPlusTree(maxKeysPerNode uint64, compare Compare, callbacks BPlusTreeCallbacks, bPlusTreeCache BPlusTreeCache) (tree BPlusTree)
NewBPlusTree is used to construct an in-memory B+Tree supporting the Tree interface
The supplied value of maxKeysPerNode, being precisely twice the computed value of (uint64) minKeysPerNode, must be even. In addition, minKeysPerNode must be computed to be greater than one to ensure that during node merge operations, there is always at least one sibling node with which to merge. Hence, maxKeysPerNode must also be at least four.
Note that if the B+Tree will reside only in memory, callback argument may be nil. That said, there is no advantage to using a B+Tree for an in-memory collection over the llrb-provided collection implementing the same APIs.
func OldBPlusTree ¶
func OldBPlusTree(rootObjectNumber uint64, rootObjectOffset uint64, rootObjectLength uint64, compare Compare, callbacks BPlusTreeCallbacks, bPlusTreeCache BPlusTreeCache) (tree BPlusTree, err error)
OldBPlusTree is used to re-construct a B+Tree previously persisted
type BPlusTreeCache ¶
type BPlusTreeCache interface { Stats() (bPlusTreeCacheStats *BPlusTreeCacheStats) UpdateLimits(evictLowLimit uint64, evictHighLimit uint64) }
func NewBPlusTreeCache ¶
func NewBPlusTreeCache(evictLowLimit uint64, evictHighLimit uint64) (bPlusTreeCache BPlusTreeCache)
type BPlusTreeCacheStats ¶
type BPlusTreeCallbacks ¶
type BPlusTreeCallbacks interface { DumpCallbacks GetNode(objectNumber uint64, objectOffset uint64, objectLength uint64) (nodeByteSlice []byte, err error) PutNode(nodeByteSlice []byte) (objectNumber uint64, objectOffset uint64, err error) DiscardNode(objectNumber uint64, objectOffset uint64, objectLength uint64) (err error) PackKey(key Key) (packedKey []byte, err error) UnpackKey(payloadData []byte) (key Key, bytesConsumed uint64, err error) PackValue(value Value) (packedValue []byte, err error) UnpackValue(payloadData []byte) (value Value, bytesConsumed uint64, err error) }
BPlusTreeCallbacks specifies the interface to a set of callbacks provided by the client
type DumpCallbacks ¶
type DumpCallbacks interface { DumpKey(key Key) (keyAsString string, err error) DumpValue(value Value) (valueAsString string, err error) }
DumpCallbacks specifies the interface to a set of callbacks provided by the client
type LLRBTree ¶
type LLRBTree interface { SortedMap Reset() }
func NewLLRBTree ¶
func NewLLRBTree(compare Compare, callbacks LLRBTreeCallbacks) (tree LLRBTree)
type LLRBTreeCallbacks ¶
type LLRBTreeCallbacks interface { DumpCallbacks }
LLRBTreeCallbacks specifies the interface to a set of callbacks provided by the client
type LayoutReport ¶
LayoutReport is a map where key is an objectNumber and value is objectBytes used in that objectNumber
type SortedMap ¶
type SortedMap interface { BisectLeft(key Key) (index int, found bool, err error) // Returns index of matching key:value pair or, if no match, index is to key:value just before where this key would go BisectRight(key Key) (index int, found bool, err error) // Returns index of matching key:value pair or, if no match, index is to key:value just after where this key would go DeleteByIndex(index int) (ok bool, err error) DeleteByKey(key Key) (ok bool, err error) Dump() (err error) GetByIndex(index int) (key Key, value Value, ok bool, err error) GetByKey(key Key) (value Value, ok bool, err error) Len() (numberOfItems int, err error) PatchByIndex(index int, value Value) (ok bool, err error) PatchByKey(key Key, value Value) (ok bool, err error) Put(key Key, value Value) (ok bool, err error) Validate() (err error) }