iter

package
v0.1.2-rc4 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadBatch

func ReadBatch[T any](ctx context.Context, iterator Iterator[T], batchSize int, fn func(context.Context, []T) error) error

ReadBatch reads profiles from the iterator in batches and call fn. If fn returns an error, the iteration is stopped and the error is returned. The array passed in fn is reused between calls, so it should be copied if needed.

func Slice

func Slice[T any](it Iterator[T]) ([]T, error)

Types

type Iterator

type Iterator[A any] interface {
	// Next advances the iterator and returns true if another value was found.
	Next() bool

	// At returns the value at the current iterator position.
	At() A

	// Err returns the last error of the iterator.
	Err() error

	Close() error
}

func CloneN

func CloneN[T any](it Iterator[T], n int) ([]Iterator[T], error)

CloneN returns N copy of the iterator. The returned iterators are independent of the original iterator. The original might be exhausted and should be discarded.

func NewErrIterator

func NewErrIterator[A any](err error) Iterator[A]

func NewSliceIterator

func NewSliceIterator[A any](s []A) Iterator[A]

func NewSortProfileIterator

func NewSortProfileIterator[P Profile](iters []Iterator[P]) Iterator[P]

NewSortProfileIterator sorts the input iterator by timestamp then labels. Each input iterator must return Profile in ascending time.

func NewTimeRangedIterator

func NewTimeRangedIterator[T Timestamp](it Iterator[T], min, max model.Time) Iterator[T]

type Profile

type Profile interface {
	Labels() phlaremodel.Labels
	Timestamp
}

type ProfileIteratorHeap

type ProfileIteratorHeap[P Profile] []Iterator[P]

func (ProfileIteratorHeap[P]) Len

func (h ProfileIteratorHeap[P]) Len() int

func (ProfileIteratorHeap[P]) Less

func (h ProfileIteratorHeap[P]) Less(i, j int) bool

func (*ProfileIteratorHeap[P]) Pop

func (h *ProfileIteratorHeap[P]) Pop() interface{}

func (*ProfileIteratorHeap[P]) Push

func (h *ProfileIteratorHeap[P]) Push(x interface{})

func (ProfileIteratorHeap[P]) Swap

func (h ProfileIteratorHeap[P]) Swap(i, j int)

type SeekIterator

type SeekIterator[A any, B any] interface {
	Iterator[A]

	// Like Next but skips over results until reading >= the given location
	Seek(pos B) bool
}

func NewErrSeekIterator

func NewErrSeekIterator[A any, B any](err error) SeekIterator[A, B]

func NewSliceSeekIterator

func NewSliceSeekIterator[A constraints.Ordered](s []A) SeekIterator[A, A]

type SortIterator

type SortIterator[P Profile] struct {
	// contains filtered or unexported fields
}

func (*SortIterator[P]) At

func (s *SortIterator[P]) At() P

func (*SortIterator[P]) Close

func (i *SortIterator[P]) Close() error

func (*SortIterator[P]) Err

func (i *SortIterator[P]) Err() error

func (*SortIterator[P]) Next

func (s *SortIterator[P]) Next() bool

type TimeRangedIterator

type TimeRangedIterator[T Timestamp] struct {
	Iterator[T]
	// contains filtered or unexported fields
}

func (*TimeRangedIterator[T]) Next

func (it *TimeRangedIterator[T]) Next() bool

type Timestamp

type Timestamp interface {
	Timestamp() model.Time
}

Jump to

Keyboard shortcuts

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