From 0bc54c23ce125664c8aa327bb3d409df4b9a8490 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 9 Nov 2019 11:48:13 +0200 Subject: [PATCH] lib/storage: inmemoryInvertedIndex prettifying --- lib/storage/inmemory_inverted_index.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/storage/inmemory_inverted_index.go b/lib/storage/inmemory_inverted_index.go index f821714265..413c100d9a 100644 --- a/lib/storage/inmemory_inverted_index.go +++ b/lib/storage/inmemory_inverted_index.go @@ -88,7 +88,7 @@ func (iidx *inmemoryInvertedIndex) MustUpdate(idb *indexDB, byTenant map[account iidx.mu.Lock() 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) } iidx.mu.Unlock() @@ -97,7 +97,7 @@ func (iidx *inmemoryInvertedIndex) MustUpdate(idb *indexDB, byTenant map[account func (iidx *inmemoryInvertedIndex) AddMetricID(idb *indexDB, e pendingHourMetricIDEntry) { iidx.mu.Lock() 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) } iidx.mu.Unlock() @@ -114,6 +114,7 @@ func (iidx *inmemoryInvertedIndex) UpdateMetricIDsForTagFilters(metricIDs, allMe continue } tfFirst = &tfs.tfs[i] + break } iidx.mu.RLock() @@ -168,14 +169,15 @@ func (iidx *inmemoryInvertedIndex) getMetricIDsForTagFilterLocked(tf *tagFilter, return &m } -func (iidx *inmemoryInvertedIndex) updateLocked(idb *indexDB) error { +func (iidx *inmemoryInvertedIndex) addPendingEntriesLocked(idb *indexDB) error { entries := iidx.pendingEntries iidx.pendingEntries = iidx.pendingEntries[:0] kb := kbPool.Get() defer kbPool.Put(kb) - var mn MetricName + mn := GetMetricName() + defer PutMetricName(mn) for _, e := range entries { var err error metricID := e.MetricID