Documentation ¶
Index ¶
- type Multi
- func (i *Multi[ReferenceKey, PrimaryKey, Value]) Iterate(ctx context.Context, ...) (MultiIterator[ReferenceKey, PrimaryKey], error)
- func (i *Multi[ReferenceKey, PrimaryKey, Value]) IterateRaw(ctx context.Context, start, end []byte, order collections.Order) (...)
- func (i *Multi[K1, K2, Value]) KeyCodec() codec.KeyCodec[collections.Pair[K1, K2]]
- func (i *Multi[ReferenceKey, PrimaryKey, Value]) MatchExact(ctx context.Context, refKey ReferenceKey) (MultiIterator[ReferenceKey, PrimaryKey], error)
- func (i *Multi[ReferenceKey, PrimaryKey, Value]) Reference(ctx context.Context, pk PrimaryKey, newValue Value, ...) error
- func (i *Multi[ReferenceKey, PrimaryKey, Value]) Unreference(ctx context.Context, pk PrimaryKey, getValue func() (Value, error)) error
- func (i *Multi[ReferenceKey, PrimaryKey, Value]) Walk(ctx context.Context, ...) error
- type MultiIterator
- func (i MultiIterator[ReferenceKey, PrimaryKey]) Close() error
- func (i MultiIterator[ReferenceKey, PrimaryKey]) FullKey() (collections.Pair[ReferenceKey, PrimaryKey], error)
- func (i MultiIterator[ReferenceKey, PrimaryKey]) FullKeys() ([]collections.Pair[ReferenceKey, PrimaryKey], error)
- func (i MultiIterator[ReferenceKey, PrimaryKey]) Next()
- func (i MultiIterator[ReferenceKey, PrimaryKey]) PrimaryKey() (PrimaryKey, error)
- func (i MultiIterator[ReferenceKey, PrimaryKey]) PrimaryKeys() ([]PrimaryKey, error)
- func (i MultiIterator[ReferenceKey, PrimaryKey]) Valid() bool
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]) Unreference ¶
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.