ptree

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyAll

func CopyAll(ctx context.Context, b *Builder, it *Iterator) error

CopyAll copies all the entries from it to b.

func DebugTree

func DebugTree(s cadata.Store, x Root)

func HasPrefix

func HasPrefix(ctx context.Context, s cadata.Store, x Root, prefix []byte) (bool, error)

HasPrefix returns true if the tree rooted at x only has keys which are prefixed with prefix

func MarshalRoot

func MarshalRoot(r Root) []byte

func MaxKey

func MaxKey(ctx context.Context, s cadata.Store, x Root, under []byte) ([]byte, error)

func PointsToEntries

func PointsToEntries(root Root) bool

func PointsToIndexes

func PointsToIndexes(root Root) bool

Types

type Builder

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

func NewBuilder

func NewBuilder(s cadata.Store, op *gdat.Operator, avgSize, maxSize int, seed *[32]byte) *Builder

func (*Builder) Finish

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

func (*Builder) Put

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

func (*Builder) SyncedBelow

func (b *Builder) SyncedBelow(depth int) bool

type Entry

type Entry = kvstreams.Entry

func ListEntries

func ListEntries(ctx context.Context, s cadata.Store, op *gdat.Operator, idx Index) ([]Entry, error)

ListEntries

type Index

type Index struct {
	Ref   Ref
	First []byte
}

func ListChildren

func ListChildren(ctx context.Context, s cadata.Store, op *gdat.Operator, root Root) ([]Index, error)

ListChildren returns the immediate children of root if any.

type IndexHandler

type IndexHandler = func(Index) error

type Iterator

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

func NewIterator

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

func (*Iterator) Next

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

func (*Iterator) Peek

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

func (*Iterator) Seek

func (it *Iterator) Seek(ctx context.Context, gteq []byte) error

type Mutation

type Mutation struct {
	Span Span
	Fn   func(*Entry) []Entry
}

Mutation represents a mutation to the stream if there is nothing in the Span, Fn will be called once with nil otherwise Fn will be called once for every item in the Span.

type Ref

type Ref = gdat.Ref

type Root

type Root struct {
	Ref   Ref    `json:"ref"`
	Depth uint8  `json:"depth"`
	First []byte `json:"first,omitempty"`
}

Root is the root of the tree

func AddPrefix

func AddPrefix(x Root, prefix []byte) Root

AddPrefix returns a new version of root with the prefix prepended to all the keys

func Mutate

func Mutate(ctx context.Context, b *Builder, root Root, mut Mutation) (*Root, error)

Mutate applies the mutation mut, to the tree root.

func ParseRoot

func ParseRoot(x []byte) (*Root, error)

func RemovePrefix

func RemovePrefix(ctx context.Context, s cadata.Store, x Root, prefix []byte) (*Root, error)

RemovePrefix returns a new version of root with the prefix removed from all the keys

type Span

type Span = kvstreams.Span

type StreamReader

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

func NewStreamReader

func NewStreamReader(s cadata.Store, op *gdat.Operator, idxs []Index) *StreamReader

func (*StreamReader) Next

func (r *StreamReader) Next(ctx context.Context, ent *Entry) error

func (*StreamReader) Peek

func (r *StreamReader) Peek(ctx context.Context, ent *Entry) error

func (*StreamReader) Seek

func (r *StreamReader) Seek(ctx context.Context, gteq []byte) error

func (*StreamReader) SeekIndexes

func (r *StreamReader) SeekIndexes(ctx context.Context, gteq []byte) error

type StreamWriter

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

func NewStreamWriter

func NewStreamWriter(s cadata.Store, op *gdat.Operator, avgSize, maxSize int, seed *[32]byte, onIndex IndexHandler) *StreamWriter

func (*StreamWriter) Append

func (w *StreamWriter) Append(ctx context.Context, ent Entry) error

func (*StreamWriter) Buffered

func (w *StreamWriter) Buffered() int

func (*StreamWriter) Flush

func (w *StreamWriter) Flush(ctx context.Context) error

Jump to

Keyboard shortcuts

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