mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: re-use indexSearch inside Storage.prefetchMetricNames
This commit is contained in:
parent
cb5c39ee70
commit
a45f25699c
1 changed files with 6 additions and 2 deletions
|
@ -2,6 +2,7 @@ package storage
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"os"
|
||||
|
@ -735,10 +736,13 @@ func (s *Storage) prefetchMetricNames(tsids []TSID) error {
|
|||
sort.Sort(metricIDs)
|
||||
var metricName []byte
|
||||
var err error
|
||||
idb := s.idb()
|
||||
is := idb.getIndexSearch()
|
||||
defer idb.putIndexSearch(is)
|
||||
for _, metricID := range metricIDs {
|
||||
tsid := tsidsMap[metricID]
|
||||
metricName, err = s.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID)
|
||||
if err != nil {
|
||||
metricName, err = is.searchMetricName(metricName[:0], metricID, tsid.AccountID, tsid.ProjectID)
|
||||
if err != nil && err != io.EOF {
|
||||
return fmt.Errorf("error in pre-fetching metricName for metricID=%d: %s", metricID, err)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue