kvtx_iterator

package
v0.56.1 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Iterator

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

Iterator implements the KVTX Iterator interface by scanning all keys into an in-memory tree set. This implements (fills) the Iterator interface for stores that do not support iteration.

Note: iterator is tested in store/kvtx/inmem.

func NewIterator

func NewIterator(ctx context.Context, s Ops, prefix []byte, sort, reverse bool) *Iterator

NewIterator constructs a new iterator. Initial key fetch is deferred to the first Next() call.

func (*Iterator) Close

func (i *Iterator) Close()

Close releases the resources associated with the iterator.

func (*Iterator) Err

func (i *Iterator) Err() error

Err returns an error that invalidated iterator. If Err is not nil then Valid must return false.

func (*Iterator) Initialize

func (i *Iterator) Initialize() (skipNext bool, err error)

Initialize intializes the iterator, fetching all keys into memory.

func (*Iterator) Key

func (i *Iterator) Key() []byte

Key returns the current key.

func (*Iterator) Next

func (i *Iterator) Next() bool

Next moves the iterator to the next item.

func (*Iterator) Seek

func (i *Iterator) Seek(k []byte) error

Seek moves the iterator to the first key >= the provided key (or <= in reverse mode). Pass nil to seek to the beginning (or end if reversed).

func (*Iterator) Valid

func (i *Iterator) Valid() bool

Valid returns whether the iterator is positioned on a valid item or not.

func (*Iterator) Value

func (i *Iterator) Value() ([]byte, error)

Value returns the current value.

func (*Iterator) ValueCopy

func (i *Iterator) ValueCopy(bt []byte) ([]byte, error)

ValueCopy copies the key to the given byte slice and returns it. If the slice is not big enough (cap), it must create a new one and return it. Always returns a new copy (does not cache between calls).

type Ops

type Ops interface {
	// Get returns values for a key.
	Get(ctx context.Context, key []byte) (data []byte, found bool, err error)
	// ScanPrefixKeys iterates over keys only with a prefix.
	ScanPrefixKeys(ctx context.Context, prefix []byte, cb func(key []byte) error) error
}

Ops are tx ops.

Jump to

Keyboard shortcuts

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