tree

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	Values  []types.Value
	Encoded []byte
}

func NewEncodedKey added in v0.15.0

func NewEncodedKey(enc []byte) *Key

func NewKey

func NewKey(values ...types.Value) *Key

func (*Key) Decode

func (key *Key) Decode() ([]types.Value, error)

func (*Key) Encode added in v0.15.0

func (k *Key) Encode(ns Namespace) ([]byte, error)

func (*Key) String

func (k *Key) String() string

type Namespace added in v0.15.0

type Namespace int64

type Range

type Range struct {
	Min, Max  *Key
	Exclusive bool
}

A Range of keys to iterate on. By default, Min and Max are inclusive. If Exclusive is true, Min and Max are excluded from the results.

type Tree

type Tree struct {
	Session   kv.Session
	Namespace Namespace
}

A Tree is an abstraction over a k-v store that allows manipulating data using high level keys and values of the Genji type system. Trees are used as the basis for tables and indexes. The key of a tree is a composite combination of several values, while the value can be any value of Genji's type system. The tree ensures all keys are sort-ordered according to the rules of the types package operators. A Tree doesn't support duplicate keys.

func New

func New(session kv.Session, ns Namespace) *Tree

func NewTransient added in v0.15.0

func NewTransient(session kv.Session, ns Namespace) (*Tree, func() error, error)

func (*Tree) Delete

func (t *Tree) Delete(key *Key) error

Delete a key from the tree. If the key doesn't exist, it returns kv.ErrKeyNotFound.

func (*Tree) Exists added in v0.15.0

func (t *Tree) Exists(key *Key) (bool, error)

Exists returns true if the key exists in the tree.

func (*Tree) Get

func (t *Tree) Get(key *Key) ([]byte, error)

Get a key from the tree. If the key doesn't exist, it returns kv.ErrKeyNotFound.

func (*Tree) Insert added in v0.15.0

func (t *Tree) Insert(key *Key, value []byte) error

Insert adds a key-doc combination to the tree. If the key already exists, it returns kv.ErrKeyAlreadyExists.

func (*Tree) IterateOnRange

func (t *Tree) IterateOnRange(rng *Range, reverse bool, fn func(*Key, []byte) error) error

IterateOnRange iterates on all keys that are in the given range.

func (*Tree) NewMaxTypeForType added in v0.15.0

func (t *Tree) NewMaxTypeForType(tp types.ValueType) types.ValueType

func (*Tree) NewMinValueForType added in v0.15.0

func (t *Tree) NewMinValueForType(tp types.ValueType) types.Value

func (*Tree) Put

func (t *Tree) Put(key *Key, value []byte) error

Put adds or replaces a key-doc combination to the tree. If the key already exists, its value will be replaced by the given value.

func (*Tree) Truncate

func (t *Tree) Truncate() error

Truncate the tree.

Jump to

Keyboard shortcuts

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