From 2e0d8487e331c272fe26abd48feaffde4de9b430 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Thu, 13 Jul 2017 14:40:29 +0100 Subject: [PATCH] Return zeros if At() is called after Next() returns false. --- storage/fanout.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/storage/fanout.go b/storage/fanout.go index 786ad20aa..0f94c2974 100644 --- a/storage/fanout.go +++ b/storage/fanout.go @@ -341,9 +341,7 @@ func (m *mergeSeries) Iterator() SeriesIterator { for _, s := range m.series { iterators = append(iterators, s.Iterator()) } - return &mergeIterator{ - iterators: iterators, - } + return newMergeIterator(iterators) } type mergeIterator struct { @@ -369,6 +367,11 @@ func (c *mergeIterator) Seek(t int64) bool { } func (c *mergeIterator) At() (t int64, v float64) { + if len(c.h) == 0 { + log.Error("mergeIterator.At() called after .Next() returned false.") + return 0, 0 + } + // TODO do I need to dedupe or just merge? return c.h[0].At() }