ptree

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxKeySize   = 4096
	MaxTreeDepth = 255
)

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(ctx context.Context, cmp CompareFunc, s cadata.Store, x Root, w io.Writer) error

func HasPrefix

func HasPrefix(ctx context.Context, cmp CompareFunc, 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

PointsToEntries returns true if root points to non-index Entries

func PointsToIndexes

func PointsToIndexes(root Root) bool

PointsToIndexes returns true if root points to indexes.

Types

type Builder

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

func NewBuilder

func NewBuilder(op *gdat.Operator, avgSize, maxSize int, seed *[16]byte, cmp CompareFunc, s cadata.Store) *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 CompareFunc added in v0.0.4

type CompareFunc = func(a, b []byte) int

CompareFunc compares 2 keys

type Entry

type Entry = kvstreams.Entry

func ListEntries

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

ListEntries returns a slice of all the entries pointed to by idx, directly. If idx points to other indexes directly, then ListEntries returns the entries for those indexes.

func MaxEntry added in v0.0.2

func MaxEntry(ctx context.Context, cmp CompareFunc, 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, op *gdat.Operator, cmp CompareFunc, s cadata.Store, 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(op *gdat.Operator, cmp CompareFunc, s cadata.Store, 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, cmp CompareFunc, 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, cmp CompareFunc, 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 *[16]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