fixes a memory leak when NewReaderIterator creates a nilFloatIterator

pull/8681/head
Stuart Carnie 2017-08-09 14:46:44 -07:00
parent 392fa03cf3
commit 91e7aaee09
1 changed files with 14 additions and 1 deletions

View File

@ -626,7 +626,7 @@ func NewReaderIterator(r io.Reader, typ DataType, stats IteratorStats) Iterator
case Boolean:
return newBooleanReaderIterator(r, stats)
default:
return &nilFloatIterator{}
return &nilFloatReaderIterator{r: r}
}
}
@ -1233,6 +1233,19 @@ func (*nilFloatIterator) Stats() IteratorStats { return IteratorStats{} }
func (*nilFloatIterator) Close() error { return nil }
func (*nilFloatIterator) Next() (*FloatPoint, error) { return nil, nil }
type nilFloatReaderIterator struct {
r io.Reader
}
func (*nilFloatReaderIterator) Stats() IteratorStats { return IteratorStats{} }
func (itr *nilFloatReaderIterator) Close() error {
if r, ok := itr.r.(io.ReadCloser); ok {
return r.Close()
}
return nil
}
func (*nilFloatReaderIterator) Next() (*FloatPoint, error) { return nil, nil }
// integerFloatTransformIterator executes a function to modify an existing point for every
// output of the input iterator.
type integerFloatTransformIterator struct {