Documentation
¶
Index ¶
- Variables
- func IsErrNotFound(err error) bool
- type Entry
- type ErrNotFound
- type Index
- type Iterator
- type Machine
- func (o *Machine) BatchEdit(ctx context.Context, s schema.RW, root Root, opsSeq iter.Seq[Op]) (*Root, error)
- func (o *Machine) Delete(ctx context.Context, s schema.RWD, root Root, key []byte) (*Root, error)
- func (o *Machine) Get(ctx context.Context, s schema.RO, root Root, key []byte, dst *[]byte) error
- func (o *Machine) MinEntry(ctx context.Context, s schema.RO, root Root, gteq []byte) (*Entry, error)
- func (o *Machine) NewEmpty(ctx context.Context, s schema.WO) (*Root, error)
- func (o *Machine) NewIterator(s schema.RO, root Root, span Span) *Iterator
- func (m *Machine) NewTx(prevRoot Root) *Tx
- func (m *Machine) NewTxOnEmpty(ctx context.Context, s schema.WO) (*Tx, error)
- func (o *Machine) Populate(ctx context.Context, s schema.RO, root Root, set cadata.Set, ...) error
- func (o *Machine) PostSlice(ctx context.Context, s schema.WO, ents []*Entry) (*Root, error)
- func (o *Machine) Put(ctx context.Context, s schema.RW, root Root, key, value []byte) (*Root, error)
- func (o *Machine) Sync(ctx context.Context, dst schema.WO, src schema.RO, root Root, ...) error
- func (o *Machine) Validate(ctx context.Context, s schema.RO, x Index) error
- func (o *Machine) Walk(ctx context.Context, s schema.RO, root Root, w Walker) error
- type Node
- type Op
- type Ref
- type Root
- type Span
- type Tx
- func (tx *Tx) Delete(ctx context.Context, key []byte) error
- func (tx *Tx) Flush(ctx context.Context, s schema.RW) (*Root, error)
- func (tx *Tx) Get(ctx context.Context, s schema.RO, key []byte, dst *[]byte) error
- func (tx *Tx) Put(ctx context.Context, s schema.RW, key []byte, value []byte) error
- func (tx *Tx) Queued() int
- type Walker
Constants ¶
This section is empty.
Variables ¶
var ( ErrCannotCollapse = errors.Errorf("cannot collapse parent into child") ErrCannotSplit = errors.Errorf("cannot split, < 2 entries") )
Functions ¶
func IsErrNotFound ¶
Types ¶
type ErrNotFound ¶
type ErrNotFound = state.ErrNotFound[[]byte]
ErrNotFound is returned when a key cannot be found.
type Index ¶
type Index struct {
// Ref is the reference to the node.
Ref Ref
// Prefix is the common prefix of all the entries in the referenced node.
Prefix []byte
// Count is the cumulative number of entries transitively reachable from this node.
Count uint64
// IsParent is true if the node at Ref is a parent node.
IsParent bool
}
Index represents metadata about a trie node reference
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine holds caches and configuration for operating on tries.
func (*Machine) BatchEdit ¶
func (o *Machine) BatchEdit(ctx context.Context, s schema.RW, root Root, opsSeq iter.Seq[Op]) (*Root, error)
BatchEdit applies a batch of operations to a root, returning a new root. All ops produced by opsSeq will be collected and sorted.
func (*Machine) MinEntry ¶
func (o *Machine) MinEntry(ctx context.Context, s schema.RO, root Root, gteq []byte) (*Entry, error)
MinEntry returns the first entry >= gteq
func (*Machine) NewIterator ¶
func (*Machine) NewTxOnEmpty ¶
func (*Machine) Put ¶
func (o *Machine) Put(ctx context.Context, s schema.RW, root Root, key, value []byte) (*Root, error)
Put returns a copy of root where key maps to value, and all other mappings are unchanged.
func (*Machine) Sync ¶
func (o *Machine) Sync(ctx context.Context, dst schema.WO, src schema.RO, root Root, fn func(*Entry) error) error
Sync ensures that data structure exists in dst, using src to retrieve missing pieces. Sync is only correct if dangling references can be guarenteed to not exist in dst.
func (*Machine) Walk ¶
Walk walks a Trie calling methods on Walker throughout the traversal. w.ShouldWalk is called before walking a node, if false is returned the node is skipped w.EntryFn is called for every entry in a node w.NodeFn is called for the node after all the entries reachable from it have been walked.
type Node ¶
type Node struct {
Entries []*Entry
}
Node represents a trie node containing multiple entries
type Op ¶
Op is a single operation on the trie.
type Tx ¶
type Tx struct {
// contains filtered or unexported fields
}
Tx is a transaction on a trie data structure. Tx buffers operations, and presents a logical view of the trie. Tx is not thread-safe.
func (*Tx) Flush ¶
Flush applies the edits to the previous root, and returns the new root. The transaction can continue, after this.
type Walker ¶
type Walker struct {
// ShouldWalk is called immediately before traversing a node.
// ShouldWalk must be set; always return true to naively walk everything.
ShouldWalk func(root Root) bool
// EntryFn, if set, is called for every entry.
EntryFn func(*Entry) error
// NodeFn, must be set and is called after visiting every node.
NodeFn func(root Root) error
}