app/vmselect: return the upper bound on the number of found time series from storage.Search.Init

This is used by a single-node version in order to reduce memory allocations during search.
See bc8381613d for details.
This commit is contained in:
Aliaksandr Valialkin 2020-08-06 19:17:51 +03:00
parent b690eeff53
commit a2039b3bbc

View file

@ -155,7 +155,9 @@ func (s *Search) reset() {
// Init initializes s from the given storage, tfss and tr.
//
// MustClose must be called when the search is done.
func (s *Search) Init(storage *Storage, tfss []*TagFilters, tr TimeRange, maxMetrics int, deadline uint64) {
//
// Init returns the upper bound on the number of found time series.
func (s *Search) Init(storage *Storage, tfss []*TagFilters, tr TimeRange, maxMetrics int, deadline uint64) int {
if s.needClosing {
logger.Panicf("BUG: missing MustClose call before the next call to Init")
}
@ -175,10 +177,11 @@ func (s *Search) Init(storage *Storage, tfss []*TagFilters, tr TimeRange, maxMet
if err != nil {
s.err = err
return
return 0
}
s.storage = storage
return len(tsids)
}
// MustClose closes the Search.