kvstreams

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyEntry

func CopyEntry(dst *Entry, src Entry)

CopyEntry copies an entry from src to dst.

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

func Peek(ctx context.Context, it streams.Peekable[Entry]) (*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

func (Entry) String

func (e Entry) String() string

type Iterator

type Iterator = streams.Iterator[Entry]

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

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

func NewLiteral(xs []Entry) *Literal

func (*Literal) Next

func (s *Literal) Next(ctx context.Context, ents []Entry) (int, error)

func (*Literal) Peek

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

func (*Literal) Seek

func (s *Literal) 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

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