iter

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 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 BufferedIterator added in v0.6.1

type BufferedIterator[T any] struct {
	Iterator[T]
	// contains filtered or unexported fields
}

func (*BufferedIterator[T]) At added in v0.6.1

func (it *BufferedIterator[T]) At() T

func (*BufferedIterator[T]) Next added in v0.6.1

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

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 NewBufferedIterator added in v0.6.1

func NewBufferedIterator[T any](it Iterator[T], size int) Iterator[T]

NewBufferedIterator returns an iterator that reads asynchronously from the given iterator and buffers up to size elements.

func NewEmptyIterator added in v0.6.1

func NewEmptyIterator[T any]() Iterator[T]

func NewErrIterator

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

func NewMergeIterator added in v0.6.1

func NewMergeIterator[P Profile](max P, deduplicate bool, iters ...Iterator[P]) Iterator[P]

NewMergeIterator returns an iterator that k-way merges the given iterators. The given iterators must be sorted by timestamp and labels themselves. Optionally, the iterator can deduplicate profiles with the same timestamp and labels.

func NewSliceIterator

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

func NewTimeRangedIterator

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

func NewUnionIterator added in v0.3.0

func NewUnionIterator[T any](iters ...Iterator[T]) Iterator[T]

type MergeIterator added in v0.6.1

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

func (*MergeIterator[P]) At added in v0.6.1

func (i *MergeIterator[P]) At() P

func (*MergeIterator[P]) Close added in v0.6.1

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

func (*MergeIterator[P]) Err added in v0.6.1

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

func (*MergeIterator[P]) Next added in v0.6.1

func (i *MergeIterator[P]) Next() bool

type Profile

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

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 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