ptree

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v0.0.2

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

Copy 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 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

type Entry

type Entry = kvstreams.Entry

func ListEntries

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

ListEntries

func MaxEntry added in v0.0.2

func MaxEntry(ctx context.Context, s cadata.Store, x Root, span Span) (*Entry, error)

MaxEntry returns the entry in span with the greatest (ordered last) key.

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 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 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