btree

package
v0.0.0-...-371cdc4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorKeyAlreadyExists = errors.New("key already exists")
View Source
var ErrorKeyNotFound = errors.New("key not found")
View Source
var ErrorRootImmutable = errors.New("root block is immutable")

Functions

This section is empty.

Types

type BTree

type BTree struct {
	// Maximum size in bytes of a key
	MaxKeySize int

	// Size in bytes of a value
	EntrySize int

	// The number of keys stored at each B-tree node. Each node has up to FanOut+1
	// child nodes. FanOut must be set to an even number. Set FanOut to 0 to have
	// it automatically set to the largest possible when calling Open().
	FanOut int
	// contains filtered or unexported fields
}

Represents a B-tree structure. Set the public variables then call Init(). You can then start querying or writing records to the tree.

func (*BTree) ByIndex

func (tr *BTree) ByIndex(index IndexType) (KeyType, ValueType, error)

func (*BTree) CreateEmpty

func (tr *BTree) CreateEmpty(tag interface{}) (TreeIndex, error)

func (*BTree) Delete

func (tr *BTree) Delete(tag interface{}, treeIndex TreeIndex, key KeyType) error

func (*BTree) Find

func (tr *BTree) Find(treeIndex TreeIndex, key KeyType) (ValueType, IndexType, error)

func (*BTree) FreeTree

func (tr *BTree) FreeTree(treeIndex TreeIndex, ignoreReadOnly bool) error

func (*BTree) Insert

func (tr *BTree) Insert(tag interface{}, treeIndex TreeIndex, key KeyType, value ValueType, overwrite bool) error

func (*BTree) LowerBound

func (tr *BTree) LowerBound(treeIndex TreeIndex, key KeyType) (KeyType, ValueType, IndexType, error)

func (*BTree) Open

func (tr *BTree) Open(bf blockfile.BlockAllocator) error

Open a B-tree with a single writable block allocator.

func (*BTree) Scan

func (tr *BTree) Scan(treeIndex TreeIndex, startKey KeyType, entryCallback func(index IndexType, key KeyType, value ValueType) bool) (bool, error)

Start scanning entries at the given offset (pass 0 to start at the beginning). Scan() will invoke entryCallback for each entry. If entryCallback returns false the scan will terminate. A scan can be resumed starting at a given entry by passing back the offset parameter sent to the callback function.

func (*BTree) WriteRecords

func (tr *BTree) WriteRecords(tag interface{}, data map[string]ValueType) (TreeIndex, error)

type IndexType

type IndexType = int64

type KeyType

type KeyType = []byte

type KeyValuePair

type KeyValuePair struct {
	Key   KeyType
	Value ValueType
}

type TreeIndex

type TreeIndex = int64

type ValueType

type ValueType = []byte

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL