iters

package
v0.0.0-...-f83b220 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect

func Collect[K, V any](it badgerutils.Iterator[K, V]) ([]V, error)

Collect collects all the items from the iterator and returns them as a slice.

func ConsumeAndCount

func ConsumeAndCount(it NopIterator) uint

ConsumeAndCount consumes the iterator and returns the count of items in the iterator.

func First

func First[K, V any](iter badgerutils.Iterator[K, V]) (value V, err error)

First returns the first value of the iterator.

func FirstItem

func FirstItem(iter badgerutils.BadgerIterator) (item *badger.Item, err error)

FirstItem returns the first item of the iterator.

func Slice

func Slice[T any](s []T) badgerutils.Iterator[[]byte, T]

Types

type AggregateIterator

type AggregateIterator[K, V, S any] struct {
	// contains filtered or unexported fields
}

AggregateIterator is an iterator that aggregates the values of base iterator as it iterates without interfering with the base iterator.

func Aggregate

func Aggregate[K, V, S any](base badgerutils.Iterator[K, V], f func(S, V, *badger.Item) S) *AggregateIterator[K, V, S]

Aggregate creates a new aggregate iterator.

func Count

func Count[K, V any](it badgerutils.Iterator[K, V]) *AggregateIterator[K, V, uint]

Count returns an aggregate iterator that counts the number of items in the base iterator.

func (*AggregateIterator[K, V, S]) Close

func (it *AggregateIterator[K, V, S]) Close()

Close implements the Iterator interface.

func (*AggregateIterator[K, V, S]) Item

func (it *AggregateIterator[K, V, S]) Item() *badger.Item

Item implements the Iterator interface.

func (*AggregateIterator[K, V, S]) Key

func (it *AggregateIterator[K, V, S]) Key() K

func (*AggregateIterator[K, V, S]) Next

func (it *AggregateIterator[K, V, S]) Next()

Next implements the Iterator interface.

func (*AggregateIterator[K, V, S]) Result

func (it *AggregateIterator[K, V, S]) Result() S

Result returns the aggregated result.

func (*AggregateIterator[K, V, S]) Rewind

func (it *AggregateIterator[K, V, S]) Rewind()

Rewind implements the Iterator interface.

func (*AggregateIterator[K, V, S]) Seek

func (it *AggregateIterator[K, V, S]) Seek(key []byte)

Seek implements the Iterator interface.

func (*AggregateIterator[K, V, S]) Valid

func (it *AggregateIterator[K, V, S]) Valid() bool

Valid implements the Iterator interface.

func (*AggregateIterator[K, V, S]) Value

func (it *AggregateIterator[K, V, S]) Value() (value V, err error)

Value implements the Iterator interface.

type Enumerator

type Enumerator[K constraints.Integer, V any] struct {
	// contains filtered or unexported fields
}

Enumerator is an iterator that enumerates a counter as the keys for the base value iterator.

func Enumerate

func Enumerate[K constraints.Integer, V any](it badgerutils.ValueIterator[V]) *Enumerator[K, V]

Enumerate creates a new enumerator.

func (*Enumerator[K, V]) Close

func (e *Enumerator[K, V]) Close()

Close implements the Iterator interface.

func (*Enumerator[K, V]) Item

func (e *Enumerator[K, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*Enumerator[K, V]) Key

func (e *Enumerator[K, V]) Key() K

Key returns the current key.

func (*Enumerator[K, V]) Next

func (e *Enumerator[K, V]) Next()

Next implements the Iterator interface.

func (*Enumerator[K, V]) Rewind

func (e *Enumerator[K, V]) Rewind()

Rewind implements the Iterator interface.

func (*Enumerator[K, V]) Seek

func (e *Enumerator[K, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*Enumerator[K, V]) Valid

func (e *Enumerator[K, V]) Valid() bool

Valid implements the Iterator interface.

func (*Enumerator[K, V]) Value

func (e *Enumerator[K, V]) Value() (V, error)

Value returns the current value.

type FilterIterator

type FilterIterator[K, V any] struct {
	// contains filtered or unexported fields
}

FilterIterator is an iterator that filters the items based on a predicate.

func Filter

func Filter[K, V any](base badgerutils.Iterator[K, V], f func(V, *badger.Item) bool) *FilterIterator[K, V]

Filter creates a new filter iterator.

func (*FilterIterator[K, V]) Close

func (it *FilterIterator[K, V]) Close()

Close implements the Iterator interface.

func (*FilterIterator[K, V]) Item

func (it *FilterIterator[K, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*FilterIterator[K, V]) Key

func (it *FilterIterator[K, V]) Key() K

Key implements the Iterator interface.

func (*FilterIterator[K, V]) Next

func (it *FilterIterator[K, V]) Next()

Next implements the Iterator interface.

func (*FilterIterator[K, V]) Rewind

func (it *FilterIterator[K, V]) Rewind()

Rewind implements the Iterator interface.

func (*FilterIterator[K, V]) Seek

func (it *FilterIterator[K, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*FilterIterator[K, V]) Valid

func (it *FilterIterator[K, V]) Valid() bool

Valid implements the Iterator interface.

func (*FilterIterator[K, V]) Value

func (it *FilterIterator[K, V]) Value() (value V, err error)

Value implements the Iterator interface.

type FlattenIterator

type FlattenIterator[K1, K2, V any] struct {
	// contains filtered or unexported fields
}

FlattenIterator is an iterator that flattens a set of iterators into a single iterator.

func Flatten

func Flatten[K1, K2, V any](base badgerutils.Iterator[K1, badgerutils.Iterator[K2, V]]) *FlattenIterator[K1, K2, V]

Flatten creates a new flatten iterator.

func (*FlattenIterator[K1, K2, V]) Close

func (it *FlattenIterator[K1, K2, V]) Close()

Close implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Item

func (it *FlattenIterator[K1, K2, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Key

func (it *FlattenIterator[K1, K2, V]) Key() (key K2)

Key implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Next

func (it *FlattenIterator[K1, K2, V]) Next()

Next implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Rewind

func (it *FlattenIterator[K1, K2, V]) Rewind()

Rewind implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Seek

func (it *FlattenIterator[K1, K2, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Valid

func (it *FlattenIterator[K1, K2, V]) Valid() bool

Valid implements the Iterator interface.

func (*FlattenIterator[K1, K2, V]) Value

func (it *FlattenIterator[K1, K2, V]) Value() (value V, err error)

Value returns the current value of the iterator.

type Getter

type Getter[K, V any] interface {
	Get(key K) (*V, error)
}

Getter is a constraint for gives a value V given a key K.

type JoinIterator

type JoinIterator[K, A, B, C any] struct {
	// contains filtered or unexported fields
}

JoinIterator is an iterator that joins two iterators by pairing the respective items and values and mapping them to a new type using the given custom function. Note that Item() will return nil and Seek() is not implemented for this iterator because of nature of the join operation.

func Join

func Join[K, A, B, C any](iterA badgerutils.Iterator[K, A], iterB badgerutils.Iterator[K, B], f func(A, *badger.Item, B, *badger.Item) (C, bool)) *JoinIterator[K, A, B, C]

Join creates a new JoinIterator.

func (*JoinIterator[K, A, B, C]) Close

func (it *JoinIterator[K, A, B, C]) Close()

Close implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Item

func (it *JoinIterator[K, A, B, C]) Item() *badger.Item

Item implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Key

func (it *JoinIterator[K, A, B, C]) Key() []byte

Key implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Next

func (it *JoinIterator[K, A, B, C]) Next()

Next implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Rewind

func (it *JoinIterator[K, A, B, C]) Rewind()

Rewind implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Seek

func (it *JoinIterator[K, A, B, C]) Seek(key []byte)

Seek implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Valid

func (it *JoinIterator[K, A, B, C]) Valid() bool

Valid implements the Iterator interface.

func (*JoinIterator[K, A, B, C]) Value

func (it *JoinIterator[K, A, B, C]) Value() (value C, err error)

Value implements the Iterator interface.

type LimitIterator

type LimitIterator[K, V any] struct {
	// contains filtered or unexported fields
}

LimitIterator is an iterator that limits the number of items when calling Next.

func Limit

func Limit[K, V any](base badgerutils.Iterator[K, V], n int) *LimitIterator[K, V]

Limit creates a new limit iterator.

func (*LimitIterator[K, V]) Close

func (it *LimitIterator[K, V]) Close()

Close implements the Iterator interface.

func (*LimitIterator[K, V]) Item

func (it *LimitIterator[K, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*LimitIterator[K, V]) Key

func (it *LimitIterator[K, V]) Key() K

Key implements the Iterator interface.

func (*LimitIterator[K, V]) Next

func (it *LimitIterator[K, V]) Next()

Next implements the Iterator interface.

func (*LimitIterator[K, V]) Rewind

func (it *LimitIterator[K, V]) Rewind()

Rewind implements the Iterator interface.

func (*LimitIterator[K, V]) Seek

func (it *LimitIterator[K, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*LimitIterator[K, V]) Valid

func (it *LimitIterator[K, V]) Valid() bool

Valid implements the Iterator interface.

func (*LimitIterator[K, V]) Value

func (it *LimitIterator[K, V]) Value() (value V, err error)

Value implements the Iterator interface.

type LookupIterator

type LookupIterator[IK, K, V any] struct {
	// contains filtered or unexported fields
}

LookupIterator is an iterator that looks up the value from a store.

func Lookup

func Lookup[IK, K, V any](
	store Getter[K, V],
	iter badgerutils.Iterator[IK, K],
) *LookupIterator[IK, K, V]

Lookup creates a new lookup iterator.

func (*LookupIterator[IK, K, V]) Close

func (it *LookupIterator[IK, K, V]) Close()

Close implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Item

func (it *LookupIterator[IK, K, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Key

func (it *LookupIterator[IK, K, V]) Key() K

Key implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Next

func (it *LookupIterator[IK, K, V]) Next()

Next implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Rewind

func (it *LookupIterator[IK, K, V]) Rewind()

Rewind implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Seek

func (it *LookupIterator[IK, K, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Valid

func (it *LookupIterator[IK, K, V]) Valid() bool

Valid implements the Iterator interface.

func (*LookupIterator[IK, K, V]) Value

func (it *LookupIterator[IK, K, V]) Value() (value *V, err error)

Value implements the Iterator interface.

type MapIterator

type MapIterator[K, V, U any] struct {
	// contains filtered or unexported fields
}

MapIterator is an iterator that maps the value from T to U.

func Map

func Map[K, V, U any](base badgerutils.Iterator[K, V], f func(V, *badger.Item) (U, error)) *MapIterator[K, V, U]

Map creates a new map iterator.

func (*MapIterator[K, V, U]) Close

func (it *MapIterator[K, V, U]) Close()

Close implements the Iterator interface.

func (*MapIterator[K, V, U]) Item

func (it *MapIterator[K, V, U]) Item() *badger.Item

Item implements the Iterator interface.

func (*MapIterator[K, V, U]) Key

func (it *MapIterator[K, V, U]) Key() K

Key implements the Iterator interface.

func (*MapIterator[K, V, U]) Next

func (it *MapIterator[K, V, U]) Next()

Next implements the Iterator interface.

func (*MapIterator[K, V, U]) Rewind

func (it *MapIterator[K, V, U]) Rewind()

Rewind implements the Iterator interface.

func (*MapIterator[K, V, U]) Seek

func (it *MapIterator[K, V, U]) Seek(key []byte)

Seek implements the Iterator interface.

func (*MapIterator[K, V, U]) Valid

func (it *MapIterator[K, V, U]) Valid() bool

Valid implements the Iterator interface.

func (*MapIterator[K, V, U]) Value

func (it *MapIterator[K, V, U]) Value() (value U, err error)

Value implements the Iterator interface.

type NopIterator

type NopIterator interface {
	Rewind()
	Valid() bool
	Next()
	Close()
}

NopIterator is an iterator that only implements the Rewind, Valid, and Next methods.

type RewindSeekIterator

type RewindSeekIterator[K, V any] struct {
	// contains filtered or unexported fields
}

RewindSeekIterator is an iterator that can seeks to the specified key on rewind.

func RewindSeek

func RewindSeek[K, V any](base badgerutils.Iterator[K, V], key []byte) *RewindSeekIterator[K, V]

RewindSeek creates a new rewind seek iterator.

func (*RewindSeekIterator[K, V]) Close

func (it *RewindSeekIterator[K, V]) Close()

Close implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Item

func (it *RewindSeekIterator[K, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Key

func (it *RewindSeekIterator[K, V]) Key() K

Key implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Next

func (it *RewindSeekIterator[K, V]) Next()

Next implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Rewind

func (it *RewindSeekIterator[K, V]) Rewind()

Rewind implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Seek

func (it *RewindSeekIterator[K, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Valid

func (it *RewindSeekIterator[K, V]) Valid() bool

Valid implements the Iterator interface.

func (*RewindSeekIterator[K, V]) Value

func (it *RewindSeekIterator[K, V]) Value() (V, error)

Value implements the Iterator interface.

type SeverIterator

type SeverIterator[K, V any] struct {
	// contains filtered or unexported fields
}

SeverIterator is an iterator that severs (stops) the iteration when the predicate is true.

func Sever

func Sever[K, V any](base badgerutils.Iterator[K, V], f func(K, V, *badger.Item) bool) *SeverIterator[K, V]

Sever creates a new sever iterator.

func (*SeverIterator[K, V]) Close

func (it *SeverIterator[K, V]) Close()

Close implements the Iterator interface.

func (*SeverIterator[K, V]) Item

func (it *SeverIterator[K, V]) Item() *badger.Item

Item implements the Iterator interface.

func (*SeverIterator[K, V]) Key

func (it *SeverIterator[K, V]) Key() K

Key implements the Iterator interface.

func (*SeverIterator[K, V]) Next

func (it *SeverIterator[K, V]) Next()

Next implements the Iterator interface.

func (*SeverIterator[K, V]) Rewind

func (it *SeverIterator[K, V]) Rewind()

Rewind implements the Iterator interface.

func (*SeverIterator[K, V]) Seek

func (it *SeverIterator[K, V]) Seek(key []byte)

Seek implements the Iterator interface.

func (*SeverIterator[K, V]) Valid

func (it *SeverIterator[K, V]) Valid() bool

Valid implements the Iterator interface.

func (*SeverIterator[K, V]) Value

func (it *SeverIterator[K, V]) Value() (value V, err error)

Value implements the Iterator interface.

type SkipIterator

type SkipIterator[K, V, S any] struct {
	// contains filtered or unexported fields
}

SkipIterator is an iterator that skips first items that doesn't satisfy the condition.

func Skip

func Skip[K, V any, S any](base badgerutils.Iterator[K, V], f func(S, K, V, *badger.Item) (S, bool)) *SkipIterator[K, V, S]

Skip creates a new skip iterator.

func SkipN

func SkipN[K, V any](base badgerutils.Iterator[K, V], n int) *SkipIterator[K, V, int]

SkipN creates a new skip iterator that skips the first n items.

func (*SkipIterator[K, V, S]) Close

func (it *SkipIterator[K, V, S]) Close()

Close implements the Iterator interface.

func (*SkipIterator[K, V, S]) Item

func (it *SkipIterator[K, V, S]) Item() *badger.Item

Item implements the Iterator interface.

func (*SkipIterator[K, V, S]) Key

func (it *SkipIterator[K, V, S]) Key() K

Key implements the Iterator interface.

func (*SkipIterator[K, V, S]) Next

func (it *SkipIterator[K, V, S]) Next()

Next implements the Iterator interface.

func (*SkipIterator[K, V, S]) Rewind

func (it *SkipIterator[K, V, S]) Rewind()

Rewind implements the Iterator interface.

func (*SkipIterator[K, V, S]) Seek

func (it *SkipIterator[K, V, S]) Seek(key []byte)

Seek implements the Iterator interface.

func (*SkipIterator[K, V, S]) Valid

func (it *SkipIterator[K, V, S]) Valid() bool

Valid implements the Iterator interface.

func (*SkipIterator[K, V, S]) Value

func (it *SkipIterator[K, V, S]) Value() (value V, err error)

Value implements the Iterator interface.

type Union

type Union[T, U any] struct {
	T T
	U U
}

Union is a type that holds two values of different types.

func UnionJoinFunc

func UnionJoinFunc[T, U any](a T, _ *badger.Item, b U, _ *badger.Item) (Union[T, U], bool)

UnionJoinFunc is a function that joins two items of different types into a Union.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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