Documentation
¶
Index ¶
- func Build[T any, C any](iter storage.Iterator, decodeKey storage.DecodeKeyFunc[C], ...) storage.IndexIterator[T, C]
- func BuildPrefixIterator[T any, C any](iter storage.Iterator, decodeKey storage.DecodeKeyFunc[C], ...) storage.IndexIterator[T, C]
- func CollectResults[T any, C any](iter storage.IndexIterator[T, C], limit uint32, filter storage.IndexFilter[*T]) ([]T, *C, error)
- type Entry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build[T any, C any](iter storage.Iterator, decodeKey storage.DecodeKeyFunc[C], reconstruct storage.ReconstructFunc[T, C]) storage.IndexIterator[T, C]
Build creates a new index iterator from a storage iterator. The returned iterator is a iter.Seq and can be used directly in for loops:
for entry, err := range Build(iter, decodeKey, reconstruct) {
if err != nil {
return err
}
value, err := entry.Value()
if err != nil {
return err
}
// use value
}
func BuildPrefixIterator ¶
func BuildPrefixIterator[T any, C any]( iter storage.Iterator, decodeKey storage.DecodeKeyFunc[C], reconstruct storage.ReconstructFunc[T, C], keyPrefix func(key []byte) ([]byte, error), ) storage.IndexIterator[T, C]
BuildPrefixIterator creates a new index iterator from a storage iterator, yielding only the first entry per group. Two consecutive keys belong to the same group when keyPrefix returns equal byte slices for both. Since the iterator is assumed to be ordered with groups contiguous and the desired entry first within each group, this yields exactly one entry per group.
func CollectResults ¶
func CollectResults[T any, C any](iter storage.IndexIterator[T, C], limit uint32, filter storage.IndexFilter[*T]) ([]T, *C, error)
CollectResults iterates over the storage iterator and collects results that match the filter. It returns when it reaches the limit or the iterator is exhausted. Returns the results matching the filter and the next cursor. A nil filter accepts all entries.
No error returns are expected during normal operation.