iter

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoopIterator = noOpIterator{}

Functions

func ReadBatch

func ReadBatch(i EntryIterator, size uint32) (*logproto.QueryResponse, uint32, error)

ReadBatch reads a set of entries off an iterator.

func ReadSampleBatch

func ReadSampleBatch(i SampleIterator, size uint32) (*logproto.SampleQueryResponse, uint32, error)

ReadBatch reads a set of entries off an iterator.

Types

type CacheEntryIterator

type CacheEntryIterator interface {
	EntryIterator
	Wrapped() EntryIterator
	Reset()
}

func NewCachedIterator

func NewCachedIterator(it EntryIterator, cap int) CacheEntryIterator

NewCachedIterator creates an iterator that cache iteration result and can be iterated again after closing it without re-using the underlaying iterator `it`.

type CacheSampleIterator

type CacheSampleIterator interface {
	SampleIterator
	Wrapped() SampleIterator
	Reset()
}

func NewCachedSampleIterator

func NewCachedSampleIterator(it SampleIterator, cap int) CacheSampleIterator

newSampleCachedIterator creates an iterator that cache iteration result and can be iterated again after closing it without re-using the underlaying iterator `it`.

type EntryIterator

type EntryIterator interface {
	Iterator
	Entry() logproto.Entry
}

EntryIterator iterates over entries in time-order.

func NewEntryReversedIter

func NewEntryReversedIter(it EntryIterator) (EntryIterator, error)

NewEntryReversedIter returns an iterator which loads all entries and iterates backward. The labels of entries is always empty.

func NewNonOverlappingIterator

func NewNonOverlappingIterator(iterators []EntryIterator) EntryIterator

NewNonOverlappingIterator gives a chained iterator over a list of iterators.

func NewQueryClientIterator

func NewQueryClientIterator(client logproto.Querier_QueryClient, direction logproto.Direction) EntryIterator

NewQueryClientIterator returns an iterator over a QueryClient.

func NewQueryResponseIterator

func NewQueryResponseIterator(resp *logproto.QueryResponse, direction logproto.Direction) EntryIterator

NewQueryResponseIterator returns an iterator over a QueryResponse.

func NewReversedIter

func NewReversedIter(it EntryIterator, limit uint32, preload bool) (EntryIterator, error)

NewReversedIter returns an iterator which loads all or up to N entries of an existing iterator, and then iterates over them backward. Preload entries when they are being queried with a timeout.

func NewSortEntryIterator

func NewSortEntryIterator(is []EntryIterator, direction logproto.Direction) EntryIterator

NewSortEntryIterator returns a new EntryIterator that sorts entries by timestamp (depending on the direction) the input iterators. The iterator only order entries across given `is` iterators, it does not sort entries within individual iterator. This means using this iterator with a single iterator will result in the same result as the input iterator. When timestamp is equal, the iterator sorts samples by their label alphabetically.

func NewStreamIterator

func NewStreamIterator(stream logproto.Stream) EntryIterator

NewStreamIterator iterates over entries in a stream.

func NewStreamsIterator

func NewStreamsIterator(streams []logproto.Stream, direction logproto.Direction) EntryIterator

NewStreamsIterator returns an iterator over logproto.Stream

func NewTimeRangedIterator

func NewTimeRangedIterator(it EntryIterator, mint, maxt time.Time) EntryIterator

NewTimeRangedIterator returns an iterator which filters entries by time range. Note: Only works with iterators that go forwards.

type HeapIterator

type HeapIterator interface {
	EntryIterator
	Peek() time.Time
	Len() int
	Push(EntryIterator)
}

HeapIterator iterates over a heap of iterators with ability to push new iterators and get some properties like time of entry at peek and len Not safe for concurrent use

func NewMergeEntryIterator

func NewMergeEntryIterator(ctx context.Context, is []EntryIterator, direction logproto.Direction) HeapIterator

NewMergeEntryIterator returns a new iterator which uses a heap to merge together entries for multiple iterators and deduplicate entries if any. The iterator only order and merge entries across given `is` iterators, it does not merge entries within individual iterator. This means using this iterator with a single iterator will result in the same result as the input iterator. If you don't need to deduplicate entries, use `NewSortEntryIterator` instead.

type Iterator

type Iterator interface {
	// Returns true if there is more data to iterate.
	Next() bool
	// Labels returns the labels for the current entry.
	// The labels can be mutated by the query engine and not reflect the original stream.
	Labels() string
	// StreamHash returns the hash of the original stream for the current entry.
	StreamHash() uint64
	Error() error
	Close() error
}

Iterator iterates over data in time-order.

type PeekingEntryIterator

type PeekingEntryIterator interface {
	EntryIterator
	Peek() (string, logproto.Entry, bool)
}

PeekingEntryIterator is an entry iterator that can look ahead an entry using `Peek` without advancing its cursor.

func NewPeekingIterator

func NewPeekingIterator(iter EntryIterator) PeekingEntryIterator

NewPeekingIterator creates a new peeking iterator.

type PeekingSampleIterator

type PeekingSampleIterator interface {
	SampleIterator
	Peek() (string, logproto.Sample, bool)
}

PeekingSampleIterator is a sample iterator that can peek sample without moving the current sample.

func NewPeekingSampleIterator

func NewPeekingSampleIterator(iter SampleIterator) PeekingSampleIterator

type QuerySampleClient

type QuerySampleClient interface {
	Recv() (*logproto.SampleQueryResponse, error)
	Context() context.Context
	CloseSend() error
}

QuerySampleClient is GRPC stream client with only method used by the SampleQueryClientIterator

type SampleIterator

type SampleIterator interface {
	Iterator
	// todo(ctovena) we should add `Seek(t int64) bool`
	// This way we can skip when ranging over samples.
	Sample() logproto.Sample
}

SampleIterator iterates over samples in time-order.

func NewMergeSampleIterator

func NewMergeSampleIterator(ctx context.Context, is []SampleIterator) SampleIterator

NewMergeSampleIterator returns a new iterator which uses a heap to merge together samples for multiple iterators and deduplicate if any. The iterator only order and merge entries across given `is` iterators, it does not merge entries within individual iterator. This means using this iterator with a single iterator will result in the same result as the input iterator. If you don't need to deduplicate sample, use `NewSortSampleIterator` instead.

func NewMultiSeriesIterator

func NewMultiSeriesIterator(series []logproto.Series) SampleIterator

NewMultiSeriesIterator returns an iterator over multiple logproto.Series

func NewNonOverlappingSampleIterator

func NewNonOverlappingSampleIterator(iterators []SampleIterator) SampleIterator

NewNonOverlappingSampleIterator gives a chained iterator over a list of iterators.

func NewSampleQueryClientIterator

func NewSampleQueryClientIterator(client QuerySampleClient) SampleIterator

NewQueryClientIterator returns an iterator over a QueryClient.

func NewSampleQueryResponseIterator

func NewSampleQueryResponseIterator(resp *logproto.SampleQueryResponse) SampleIterator

NewSampleQueryResponseIterator returns an iterator over a SampleQueryResponse.

func NewSeriesIterator

func NewSeriesIterator(series logproto.Series) SampleIterator

NewSeriesIterator iterates over sample in a series.

func NewSortSampleIterator

func NewSortSampleIterator(is []SampleIterator) SampleIterator

NewSortSampleIterator returns a new SampleIterator that sorts samples by ascending timestamp the input iterators. The iterator only order sample across given `is` iterators, it does not sort samples within individual iterator. This means using this iterator with a single iterator will result in the same result as the input iterator. When timestamp is equal, the iterator sorts samples by their label alphabetically.

func NewTimeRangedSampleIterator

func NewTimeRangedSampleIterator(it SampleIterator, mint, maxt int64) SampleIterator

NewTimeRangedSampleIterator returns an iterator which filters entries by time range.

func SampleIteratorWithClose

func SampleIteratorWithClose(it SampleIterator, closeFn func() error) SampleIterator

Jump to

Keyboard shortcuts

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