mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-20 23:39:48 +01:00
lib/storage: inmemoryInvertedIndex prettifying
This commit is contained in:
parent
46e67bb78c
commit
0bc54c23ce
@ -88,7 +88,7 @@ func (iidx *inmemoryInvertedIndex) MustUpdate(idb *indexDB, byTenant map[account
|
|||||||
|
|
||||||
iidx.mu.Lock()
|
iidx.mu.Lock()
|
||||||
iidx.pendingEntries = append(iidx.pendingEntries, entries...)
|
iidx.pendingEntries = append(iidx.pendingEntries, entries...)
|
||||||
if err := iidx.updateLocked(idb); err != nil {
|
if err := iidx.addPendingEntriesLocked(idb); err != nil {
|
||||||
logger.Panicf("FATAL: cannot update inmemoryInvertedIndex with pendingEntries: %s", err)
|
logger.Panicf("FATAL: cannot update inmemoryInvertedIndex with pendingEntries: %s", err)
|
||||||
}
|
}
|
||||||
iidx.mu.Unlock()
|
iidx.mu.Unlock()
|
||||||
@ -97,7 +97,7 @@ func (iidx *inmemoryInvertedIndex) MustUpdate(idb *indexDB, byTenant map[account
|
|||||||
func (iidx *inmemoryInvertedIndex) AddMetricID(idb *indexDB, e pendingHourMetricIDEntry) {
|
func (iidx *inmemoryInvertedIndex) AddMetricID(idb *indexDB, e pendingHourMetricIDEntry) {
|
||||||
iidx.mu.Lock()
|
iidx.mu.Lock()
|
||||||
iidx.pendingEntries = append(iidx.pendingEntries, e)
|
iidx.pendingEntries = append(iidx.pendingEntries, e)
|
||||||
if err := iidx.updateLocked(idb); err != nil {
|
if err := iidx.addPendingEntriesLocked(idb); err != nil {
|
||||||
logger.Panicf("FATAL: cannot update inmemoryInvertedIndex with pendingEntries: %s", err)
|
logger.Panicf("FATAL: cannot update inmemoryInvertedIndex with pendingEntries: %s", err)
|
||||||
}
|
}
|
||||||
iidx.mu.Unlock()
|
iidx.mu.Unlock()
|
||||||
@ -114,6 +114,7 @@ func (iidx *inmemoryInvertedIndex) UpdateMetricIDsForTagFilters(metricIDs, allMe
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
tfFirst = &tfs.tfs[i]
|
tfFirst = &tfs.tfs[i]
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
iidx.mu.RLock()
|
iidx.mu.RLock()
|
||||||
@ -168,14 +169,15 @@ func (iidx *inmemoryInvertedIndex) getMetricIDsForTagFilterLocked(tf *tagFilter,
|
|||||||
return &m
|
return &m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iidx *inmemoryInvertedIndex) updateLocked(idb *indexDB) error {
|
func (iidx *inmemoryInvertedIndex) addPendingEntriesLocked(idb *indexDB) error {
|
||||||
entries := iidx.pendingEntries
|
entries := iidx.pendingEntries
|
||||||
iidx.pendingEntries = iidx.pendingEntries[:0]
|
iidx.pendingEntries = iidx.pendingEntries[:0]
|
||||||
|
|
||||||
kb := kbPool.Get()
|
kb := kbPool.Get()
|
||||||
defer kbPool.Put(kb)
|
defer kbPool.Put(kb)
|
||||||
|
|
||||||
var mn MetricName
|
mn := GetMetricName()
|
||||||
|
defer PutMetricName(mn)
|
||||||
for _, e := range entries {
|
for _, e := range entries {
|
||||||
var err error
|
var err error
|
||||||
metricID := e.MetricID
|
metricID := e.MetricID
|
||||||
|
Loading…
Reference in New Issue
Block a user