tree

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToUint64Slice

func BytesToUint64Slice(b []byte) []uint64

BytesToUint64Slice converts a byte slice to a uint64 slice.

Types

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

Tree represents the structure for custom mmaped B+ tree. It supports keys in range [1, math.MaxUint64-1] and values [1, math.Uint64].

func FromBuffer added in v1.8.0

func FromBuffer(b []byte) *Tree

func NewTree

func NewTree(path string) *Tree

NewTree returns an in-memory B+ tree.

func (*Tree) Bytes added in v1.8.0

func (t *Tree) Bytes() []byte

func (*Tree) Close

func (t *Tree) Close() error

Close releases the memory used by the tree.

func (*Tree) DeleteBelow

func (t *Tree) DeleteBelow(ts uint64)

DeleteBelow deletes all keys with value under ts.

func (*Tree) Get

func (t *Tree) Get(k uint64) uint64

Get looks for key and returns the corresponding value. If key is not found, 0 is returned.

func (*Tree) Iterate

func (t *Tree) Iterate(fn func(node))

Iterate iterates over the tree and executes the fn on each node.

func (*Tree) IterateKV

func (t *Tree) IterateKV(f func(key, val uint64) (newVal uint64))

IterateKV iterates through all keys and values in the tree. If newVal is non-zero, it will be set in the tree.

func (*Tree) Print

func (t *Tree) Print()

Print iterates over the tree and prints all valid KVs.

func (*Tree) Reset

func (t *Tree) Reset()

Reset resets the tree and truncates it to maxSz.

func (*Tree) Set

func (t *Tree) Set(k, v uint64)

Set sets the key-value pair in the tree.

func (*Tree) Stats

func (t *Tree) Stats() TreeStats

Stats returns stats about the tree.

type TreeStats

type TreeStats struct {
	Allocated    int     // Derived.
	Bytes        int     // Derived.
	NumLeafKeys  int     // Calculated.
	NumPages     int     // Derived.
	NumPagesFree int     // Calculated.
	Occupancy    float64 // Derived.
	PageSize     int     // Derived.
}

Jump to

Keyboard shortcuts

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