tries

package
v0.0.0-...-817062f Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExist = errors.Errorf("no entry for key")

	ErrCannotCollapse = errors.Errorf("cannot collapse parent into child")
	ErrCannotSplit    = errors.Errorf("cannot split, < 2 entries")
)

Functions

This section is empty.

Types

type Builder

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

func (*Builder) Finish

func (b *Builder) Finish(ctx context.Context) (*Root, error)

func (*Builder) Put

func (b *Builder) Put(ctx context.Context, k, v []byte) error

type Entry

type Entry struct {
	Key   []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*Entry) Descriptor deprecated

func (*Entry) Descriptor() ([]byte, []int)

Deprecated: Use Entry.ProtoReflect.Descriptor instead.

func (*Entry) GetKey

func (x *Entry) GetKey() []byte

func (*Entry) GetValue

func (x *Entry) GetValue() []byte

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) ProtoReflect

func (x *Entry) ProtoReflect() protoreflect.Message

func (*Entry) Reset

func (x *Entry) Reset()

func (*Entry) String

func (x *Entry) String() string

type Index

type Index struct {
	Ref      []byte `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"`
	IsParent bool   `protobuf:"varint,2,opt,name=is_parent,json=isParent,proto3" json:"is_parent,omitempty"`
	Count    uint64 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
	// contains filtered or unexported fields
}

func (*Index) Descriptor deprecated

func (*Index) Descriptor() ([]byte, []int)

Deprecated: Use Index.ProtoReflect.Descriptor instead.

func (*Index) GetCount

func (x *Index) GetCount() uint64

func (*Index) GetIsParent

func (x *Index) GetIsParent() bool

func (*Index) GetRef

func (x *Index) GetRef() []byte

func (*Index) ProtoMessage

func (*Index) ProtoMessage()

func (*Index) ProtoReflect

func (x *Index) ProtoReflect() protoreflect.Message

func (*Index) Reset

func (x *Index) Reset()

func (*Index) String

func (x *Index) String() string

type Iterator

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

func (*Iterator) Next

func (it *Iterator) Next(ctx context.Context) (*Entry, error)

type Node

type Node struct {
	Entries []*Entry `protobuf:"bytes,1,rep,name=entries,proto3" json:"entries,omitempty"`
	// contains filtered or unexported fields
}

func (*Node) Descriptor deprecated

func (*Node) Descriptor() ([]byte, []int)

Deprecated: Use Node.ProtoReflect.Descriptor instead.

func (*Node) GetEntries

func (x *Node) GetEntries() []*Entry

func (*Node) ProtoMessage

func (*Node) ProtoMessage()

func (*Node) ProtoReflect

func (x *Node) ProtoReflect() protoreflect.Message

func (*Node) Reset

func (x *Node) Reset()

func (*Node) String

func (x *Node) String() string

type Operator

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

func NewOperator

func NewOperator() *Operator

func (*Operator) Delete

func (o *Operator) Delete(ctx context.Context, s cadata.Store, root Root, key []byte) (*Root, error)

Delete removes

func (*Operator) Get

func (o *Operator) Get(ctx context.Context, s cadata.Store, root Root, key []byte) ([]byte, error)

Get retrieves a value at key if it exists, otherwise ErrNotExist is returned

func (*Operator) MinEntry

func (o *Operator) MinEntry(ctx context.Context, s cadata.Store, root Root, gteq []byte) (*Entry, error)

MinEntry returns the first entry >= gteq

func (*Operator) New

func (o *Operator) New(ctx context.Context, s cadata.Store, ents []*Entry) (*Root, error)

New returns a new instance containing ents

func (*Operator) NewBuilder

func (o *Operator) NewBuilder(s cadata.Store, batchSize int) *Builder

func (*Operator) NewIterator

func (o *Operator) NewIterator(s cadata.Store, root Root, span Span) *Iterator

func (*Operator) Populate

func (o *Operator) Populate(ctx context.Context, s cadata.Store, root Root, set cadata.Set, fn func(*Entry) error) error

func (*Operator) Put

func (o *Operator) Put(ctx context.Context, s cadata.Store, 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 (*Operator) PutBatch

func (o *Operator) PutBatch(ctx context.Context, s cadata.Store, root Root, ents []*Entry) (*Root, error)

PutBatch performs a batch of put operations on ents atomically, returning a new instance reflecting the changes.

func (*Operator) Sync

func (o *Operator) Sync(ctx context.Context, dst, src cadata.Store, 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 (*Operator) Validate

func (o *Operator) Validate(ctx context.Context, s cadata.Store, x Root) error

func (*Operator) Walk

func (o *Operator) Walk(ctx context.Context, s cadata.Store, root Root, w Walker) error

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 Ref

type Ref struct {
	ID     cadata.ID     `json:"id"`
	DEK    *bccrypto.DEK `json:"dek"`
	Length uint32        `json:"length"`
}

type Root

type Root struct {
	Ref      Ref
	IsParent bool   `json:"is_parent"`
	Count    uint64 `json:"count"`
	Prefix   []byte `json:"prefix"`
}

type Span

type Span = state.ByteSpan

type Walker

type Walker struct {
	ShouldWalk func(root Root) bool
	EntryFn    func(*Entry) error
	NodeFn     func(root Root) error
}

Jump to

Keyboard shortcuts

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