From 99e6a937a50dfcb0217cd14281a4a74da5d0e420 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Mon, 7 Nov 2022 13:06:50 +0200 Subject: [PATCH] lib/storage: remove unused isFull field from hourMetricIDs struct --- lib/storage/storage.go | 12 ------------ lib/storage/storage_test.go | 12 ------------ 2 files changed, 24 deletions(-) diff --git a/lib/storage/storage.go b/lib/storage/storage.go index efeb2ae76e..b57737d619 100644 --- a/lib/storage/storage.go +++ b/lib/storage/storage.go @@ -916,8 +916,6 @@ func (s *Storage) mustLoadHourMetricIDs(hour uint64, name string) *hourMetricIDs } // Unmarshal header - isFull := encoding.UnmarshalUint64(src) - src = src[8:] hourLoaded := encoding.UnmarshalUint64(src) src = src[8:] if hourLoaded != hour { @@ -971,7 +969,6 @@ func (s *Storage) mustLoadHourMetricIDs(hour uint64, name string) *hourMetricIDs hm.m = m hm.byTenant = byTenant - hm.isFull = isFull != 0 logger.Infof("loaded %s from %q in %.3f seconds; entriesCount: %d; sizeBytes: %d", name, path, time.Since(startTime).Seconds(), m.Len(), srcOrigLen) return hm } @@ -1000,13 +997,8 @@ func (s *Storage) mustSaveHourMetricIDs(hm *hourMetricIDs, name string) { logger.Infof("saving %s to %q...", name, path) startTime := time.Now() dst := make([]byte, 0, hm.m.Len()*8+24) - isFull := uint64(0) - if hm.isFull { - isFull = 1 - } // Marshal header - dst = encoding.MarshalUint64(dst, isFull) dst = encoding.MarshalUint64(dst, hm.hour) // Marshal hm.m @@ -2470,7 +2462,6 @@ func (s *Storage) updateCurrHourMetricIDs() { // Slow path: hm.m must be updated with non-empty s.pendingHourEntries. var m *uint64set.Set var byTenant map[accountProjectKey]*uint64set.Set - isFull := hm.isFull if hm.hour == hour { m = hm.m.Clone() byTenant = make(map[accountProjectKey]*uint64set.Set, len(hm.byTenant)) @@ -2480,7 +2471,6 @@ func (s *Storage) updateCurrHourMetricIDs() { } else { m = &uint64set.Set{} byTenant = make(map[accountProjectKey]*uint64set.Set) - isFull = true } for _, x := range newEntries { @@ -2501,7 +2491,6 @@ func (s *Storage) updateCurrHourMetricIDs() { m: m, byTenant: byTenant, hour: hour, - isFull: isFull, } s.currHourMetricIDs.Store(hmNew) if hm.hour != hour { @@ -2513,7 +2502,6 @@ type hourMetricIDs struct { m *uint64set.Set byTenant map[accountProjectKey]*uint64set.Set hour uint64 - isFull bool } type generationTSID struct { diff --git a/lib/storage/storage_test.go b/lib/storage/storage_test.go index 6ef66309e7..18fd931884 100644 --- a/lib/storage/storage_test.go +++ b/lib/storage/storage_test.go @@ -174,9 +174,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) { if hmCurr.m.Len() != 0 { t.Fatalf("unexpected length of hm.m; got %d; want %d", hmCurr.m.Len(), 0) } - if !hmCurr.isFull { - t.Fatalf("unexpected hmCurr.isFull; got %v; want %v", hmCurr.isFull, true) - } hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs) if !reflect.DeepEqual(hmPrev, hmOrig) { @@ -211,9 +208,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) { if !reflect.DeepEqual(hmCurr, hmOrig) { t.Fatalf("unexpected hmCurr; got %v; want %v", hmCurr, hmOrig) } - if hmCurr.isFull { - t.Fatalf("unexpected hmCurr.isFull; got %v; want %v", hmCurr.isFull, false) - } hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs) hmEmpty := &hourMetricIDs{} @@ -272,9 +266,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) { if !reflect.DeepEqual(hmCurr.byTenant, byTenantExpected) { t.Fatalf("unexpected hmPrev.byTenant; got %v; want %v", hmCurr.byTenant, byTenantExpected) } - if !hmCurr.isFull { - t.Fatalf("unexpected hmCurr.isFull; got %v; want %v", hmCurr.isFull, true) - } hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs) if !reflect.DeepEqual(hmPrev, hmOrig) { @@ -341,9 +332,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) { if !reflect.DeepEqual(hmCurr.byTenant, byTenantExpected) { t.Fatalf("unexpected hmPrev.byTenant; got %v; want %v", hmCurr.byTenant, byTenantExpected) } - if hmCurr.isFull { - t.Fatalf("unexpected hmCurr.isFull; got %v; want %v", hmCurr.isFull, false) - } hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs) hmEmpty := &hourMetricIDs{}