Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pkg/chunk/encoding/bigchunk.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ func (b *bigchunk) Size() int {
}

func (b *bigchunk) NewIterator() Iterator {
if len(b.chunks) == 0 {
return emptyIterator{}
}

return &bigchunkIterator{
bigchunk: b,
curr: b.chunks[0].Iterator(),
Expand Down Expand Up @@ -332,3 +336,12 @@ func firstAndLastTimes(c chunkenc.Chunk) (int64, int64, error) {
}
return first, last, iter.Err()
}

// emptyIterator has no samples.
type emptyIterator struct{}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using NewNopIterator() from TSDB instead of this?
AFAICS only Batch() would behave differently, and that might indicate a bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewNopIterator() returns a tsdb.Iterator as seen here: https://github.com/prometheus/tsdb/blob/719b57db44f5e5dbad7d813a5645c222c3ba7647/chunkenc/chunk.go#L55-L65

Not sure how it'll be simpler to use that than just add a few lines here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because then you won't add any lines here?

I'm pretty sure it returns a chunkenc.Iterator, i.e. it fits in curr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #1461 to make clear what I meant.


func (emptyIterator) Scan() bool { return false }
func (emptyIterator) FindAtOrAfter(model.Time) bool { return false }
func (emptyIterator) Value() model.SamplePair { return model.SamplePair{} }
func (emptyIterator) Batch(size int) Batch { return Batch{} }
func (emptyIterator) Err() error { return nil }