kvstreams

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: 7 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EOS = fmt.Errorf("end of stream")

EOS signals the end of a stream

Functions

func Diff

func Diff(ctx context.Context, s cadata.Store, leftIt, rightIt Iterator, span Span, fn DiffFn) error

Diff calls fn with all the keys and values that are different between the two Iterators

func ForEach

func ForEach(ctx context.Context, it Iterator, fn func(ent Entry) error) error

func KeyAfter

func KeyAfter(x []byte) []byte

KeyAfter returns the key immediately after x. There will be no key less than the result and greater than x

func PrefixEnd

func PrefixEnd(prefix []byte) []byte

PrefixEnd return the key > all the keys with prefix p, but < any other key

Types

type DiffFn

type DiffFn = func(key, leftValue, rightValue []byte) error

type Entry

type Entry struct {
	Key, Value []byte
}

Entry is a single entry in a stream/tree

func Collect added in v0.0.2

func Collect(ctx context.Context, it Iterator) ([]Entry, error)

func Peek

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

func (Entry) Clone

func (e Entry) Clone() Entry

Clone makes a copy of Entry where Key and Value do not point to memory overlapping with the original

type Iterator

type Iterator interface {
	Next(ctx context.Context, ent *Entry) error
	Seek(ctx context.Context, gteq []byte) error
	Peek(ctx context.Context, ent *Entry) error
}

Iterator iterates over entries

e.g.

if err := it.Seek(ctx, key); err != nil {
  return err
}

var ent Entry

for err := it.Next(ctx, &ent); err != EOS; err = it.Next(ctx, &ent) {
  if err != nil {
	   return err
  }
  // use ent here. ent will be valid until the next call to it.Next
}

type Literal added in v0.0.2

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

Literal is a stream literal, satisfying the Iterator interface. It can be constructed with a slice using NewLiteral

func NewLiteral added in v0.0.2

func NewLiteral(xs []Entry) *Literal

func (*Literal) Next added in v0.0.2

func (s *Literal) Next(ctx context.Context, ent *Entry) error

func (*Literal) Peek added in v0.0.2

func (s *Literal) Peek(ctx context.Context, ent *Entry) error

func (*Literal) Seek added in v0.0.2

func (s *Literal) Seek(ctx context.Context, gteq []byte) error

type Merger

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

func NewMerger

func NewMerger(s cadata.Store, streams []Iterator) *Merger

func (*Merger) Next

func (sm *Merger) Next(ctx context.Context, ent *Entry) error

func (*Merger) Peek

func (sm *Merger) Peek(ctx context.Context, ent *Entry) error

func (*Merger) Seek

func (m *Merger) Seek(ctx context.Context, gteq []byte) error

type Span

type Span = state.ByteSpan

A span of keys [Begin, End) If you want to include a specific end key, use the KeyAfter function. nil is interpretted as no bound, not as a 0 length key. This behaviour is only releveant for End.

func CloneSpan added in v0.0.3

func CloneSpan(x Span) Span

func PrefixSpan

func PrefixSpan(p []byte) Span

PrefixSpan returns a Span that includes all keys with prefix p

func SingleItemSpan

func SingleItemSpan(x []byte) Span

func TotalSpan

func TotalSpan() Span

Jump to

Keyboard shortcuts

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