From a2039b3bbca91f29f726ad01dce8b2bf7a1132da Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 6 Aug 2020 19:17:51 +0300 Subject: [PATCH] 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 bc8381613d4caab185089394d9df4bd7deb11934 for details. --- lib/storage/search.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/storage/search.go b/lib/storage/search.go index d02871ba34..cc73bd2dc4 100644 --- a/lib/storage/search.go +++ b/lib/storage/search.go @@ -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.