lib/storage: re-use indexSearch inside Storage.prefetchMetricNames

This commit is contained in:
Aliaksandr Valialkin 2020-01-31 00:54:28 +02:00
parent cb5c39ee70
commit a45f25699c

View file

@ -2,6 +2,7 @@ package storage
import ( import (
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"math" "math"
"os" "os"
@ -735,10 +736,13 @@ func (s *Storage) prefetchMetricNames(tsids []TSID) error {
sort.Sort(metricIDs) sort.Sort(metricIDs)
var metricName []byte var metricName []byte
var err error var err error
idb := s.idb()
is := idb.getIndexSearch()
defer idb.putIndexSearch(is)
for _, metricID := range metricIDs { for _, metricID := range metricIDs {
tsid := tsidsMap[metricID] tsid := tsidsMap[metricID]
metricName, err = s.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID) metricName, err = is.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID)
if err != nil { if err != nil && err != io.EOF {
return fmt.Errorf("error in pre-fetching metricName for metricID=%d: %s", metricID, err) return fmt.Errorf("error in pre-fetching metricName for metricID=%d: %s", metricID, err)
} }
} }