mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/storage: code clarification: remove caching the found metricName in searchMetricName
This commit is contained in:
parent
c6fc3fa94d
commit
72c41323fa
2 changed files with 23 additions and 8 deletions
|
@ -1539,9 +1539,15 @@ func (db *indexDB) searchMetricNameWithCache(dst []byte, metricID uint64, accoun
|
|||
}
|
||||
|
||||
is := db.getIndexSearch(accountID, projectID, noDeadline)
|
||||
dst, err := is.searchMetricName(dst, metricID)
|
||||
var err error
|
||||
dst, err = is.searchMetricName(dst, metricID)
|
||||
db.putIndexSearch(is)
|
||||
|
||||
if err == nil {
|
||||
// There is no need in verifying whether the given metricID is deleted,
|
||||
// since the filtering must be performed before calling this func.
|
||||
db.putMetricNameToCache(metricID, dst)
|
||||
return dst, nil
|
||||
}
|
||||
if err != io.EOF {
|
||||
return dst, err
|
||||
}
|
||||
|
@ -1551,6 +1557,11 @@ func (db *indexDB) searchMetricNameWithCache(dst []byte, metricID uint64, accoun
|
|||
is := extDB.getIndexSearch(accountID, projectID, noDeadline)
|
||||
dst, err = is.searchMetricName(dst, metricID)
|
||||
extDB.putIndexSearch(is)
|
||||
if err == nil {
|
||||
// There is no need in verifying whether the given metricID is deleted,
|
||||
// since the filtering must be performed before calling this func.
|
||||
extDB.putMetricNameToCache(metricID, dst)
|
||||
}
|
||||
}) {
|
||||
return dst, err
|
||||
}
|
||||
|
@ -1794,7 +1805,15 @@ func (is *indexSearch) searchMetricNameWithCache(dst []byte, metricID uint64) ([
|
|||
if len(metricName) > len(dst) {
|
||||
return metricName, nil
|
||||
}
|
||||
return is.searchMetricName(dst, metricID)
|
||||
var err error
|
||||
dst, err = is.searchMetricName(dst, metricID)
|
||||
if err == nil {
|
||||
// There is no need in verifying whether the given metricID is deleted,
|
||||
// since the filtering must be performed before calling this func.
|
||||
is.db.putMetricNameToCache(metricID, dst)
|
||||
return dst, nil
|
||||
}
|
||||
return dst, err
|
||||
}
|
||||
|
||||
func (is *indexSearch) searchMetricName(dst []byte, metricID uint64) ([]byte, error) {
|
||||
|
@ -1810,10 +1829,6 @@ func (is *indexSearch) searchMetricName(dst []byte, metricID uint64) ([]byte, er
|
|||
}
|
||||
v := ts.Item[len(kb.B):]
|
||||
dst = append(dst, v...)
|
||||
|
||||
// There is no need in verifying whether the given metricID is deleted,
|
||||
// since the filtering must be performed before calling this func.
|
||||
is.db.putMetricNameToCache(metricID, dst)
|
||||
return dst, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -234,7 +234,7 @@ func (s *Search) NextMetricBlock() bool {
|
|||
if err != nil {
|
||||
if err == io.EOF {
|
||||
// Skip missing metricName for tsid.MetricID.
|
||||
// It should be automatically fixed. See indexDB.searchMetricName for details.
|
||||
// It should be automatically fixed. See indexDB.searchMetricNameWithCache for details.
|
||||
continue
|
||||
}
|
||||
s.err = err
|
||||
|
|
Loading…
Reference in a new issue