indexes

package
v0.0.0-...-027dd3d Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: AGPL-3.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 Multi

type Multi[ReferenceKey, PrimaryKey, Value any] struct {
	// contains filtered or unexported fields
}

Multi defines the most common index. It can be used to create a reference between a field of value and its primary key. Multiple primary keys can be mapped to the same reference key as the index does not enforce uniqueness constraints.

func NewMulti

func NewMulti[ReferenceKey, PrimaryKey, Value any](
	schema *collections.SchemaBuilder,
	prefix collections.Prefix,
	name string,
	refCodec codec.KeyCodec[ReferenceKey],
	pkCodec codec.KeyCodec[PrimaryKey],
	getRefKeyFunc func(pk PrimaryKey, value Value) (ReferenceKey, error),
) *Multi[ReferenceKey, PrimaryKey, Value]

NewMulti instantiates a new Multi instance given a schema, a Prefix, the humanized name for the index, the reference key key codec and the primary key key codec. The getRefKeyFunc is a function that given the primary key and value returns the referencing key.

func (*Multi[ReferenceKey, PrimaryKey, Value]) Iterate

func (i *Multi[ReferenceKey, PrimaryKey, Value]) Iterate(ctx context.Context, ranger collections.Ranger[collections.Pair[ReferenceKey, PrimaryKey]]) (MultiIterator[ReferenceKey, PrimaryKey], error)

func (*Multi[ReferenceKey, PrimaryKey, Value]) IterateRaw

func (i *Multi[ReferenceKey, PrimaryKey, Value]) IterateRaw(ctx context.Context, start, end []byte, order collections.Order) (_ collections.Iterator[collections.Pair[ReferenceKey, PrimaryKey], collections.NoValue], err error)

func (*Multi[K1, K2, Value]) KeyCodec

func (i *Multi[K1, K2, Value]) KeyCodec() codec.KeyCodec[collections.Pair[K1, K2]]

func (*Multi[ReferenceKey, PrimaryKey, Value]) MatchExact

func (i *Multi[ReferenceKey, PrimaryKey, Value]) MatchExact(ctx context.Context, refKey ReferenceKey) (MultiIterator[ReferenceKey, PrimaryKey], error)

MatchExact returns a MultiIterator containing all the primary keys referenced by the provided reference key.

func (*Multi[ReferenceKey, PrimaryKey, Value]) Reference

func (i *Multi[ReferenceKey, PrimaryKey, Value]) Reference(ctx context.Context, pk PrimaryKey, newValue Value, lazyOldValue func() (Value, error)) error

func (*Multi[ReferenceKey, PrimaryKey, Value]) Unreference

func (i *Multi[ReferenceKey, PrimaryKey, Value]) Unreference(ctx context.Context, pk PrimaryKey, getValue func() (Value, error)) error

func (*Multi[ReferenceKey, PrimaryKey, Value]) Walk

func (i *Multi[ReferenceKey, PrimaryKey, Value]) Walk(
	ctx context.Context,
	ranger collections.Ranger[collections.Pair[ReferenceKey, PrimaryKey]],
	walkFunc func(indexingKey ReferenceKey, indexedKey PrimaryKey) (stop bool, err error),
) error

type MultiIterator

type MultiIterator[ReferenceKey, PrimaryKey any] collections.KeySetIterator[collections.Pair[ReferenceKey, PrimaryKey]]

MultiIterator is just a KeySetIterator with key as Pair[ReferenceKey, PrimaryKey].

func (MultiIterator[ReferenceKey, PrimaryKey]) Close

func (i MultiIterator[ReferenceKey, PrimaryKey]) Close() error

Close closes the iterator.

func (MultiIterator[ReferenceKey, PrimaryKey]) FullKey

func (i MultiIterator[ReferenceKey, PrimaryKey]) FullKey() (collections.Pair[ReferenceKey, PrimaryKey], error)

FullKey returns the current full reference key as Pair[ReferenceKey, PrimaryKey].

func (MultiIterator[ReferenceKey, PrimaryKey]) FullKeys

func (i MultiIterator[ReferenceKey, PrimaryKey]) FullKeys() ([]collections.Pair[ReferenceKey, PrimaryKey], error)

FullKeys fully consumes the iterator and returns all the list of full reference keys.

func (MultiIterator[ReferenceKey, PrimaryKey]) Next

func (i MultiIterator[ReferenceKey, PrimaryKey]) Next()

Next advances the iterator.

func (MultiIterator[ReferenceKey, PrimaryKey]) PrimaryKey

func (i MultiIterator[ReferenceKey, PrimaryKey]) PrimaryKey() (PrimaryKey, error)

PrimaryKey returns the iterator's current primary key.

func (MultiIterator[ReferenceKey, PrimaryKey]) PrimaryKeys

func (i MultiIterator[ReferenceKey, PrimaryKey]) PrimaryKeys() ([]PrimaryKey, error)

PrimaryKeys fully consumes the iterator and returns the list of primary keys.

func (MultiIterator[ReferenceKey, PrimaryKey]) Valid

func (i MultiIterator[ReferenceKey, PrimaryKey]) Valid() bool

Valid asserts if the iterator is still valid or not.

Jump to

Keyboard shortcuts

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