Return zeros if At() is called after Next() returns false.

This commit is contained in:
Tom Wilkie 2017-07-13 14:40:29 +01:00
parent 014bd31a86
commit 2e0d8487e3

View file

@ -341,9 +341,7 @@ func (m *mergeSeries) Iterator() SeriesIterator {
for _, s := range m.series { for _, s := range m.series {
iterators = append(iterators, s.Iterator()) iterators = append(iterators, s.Iterator())
} }
return &mergeIterator{ return newMergeIterator(iterators)
iterators: iterators,
}
} }
type mergeIterator struct { type mergeIterator struct {
@ -369,6 +367,11 @@ func (c *mergeIterator) Seek(t int64) bool {
} }
func (c *mergeIterator) At() (t int64, v float64) { 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? // TODO do I need to dedupe or just merge?
return c.h[0].At() return c.h[0].At()
} }