lib/storage: remove unused isFull field from hourMetricIDs struct

This commit is contained in:
Aliaksandr Valialkin 2022-11-07 13:06:50 +02:00
parent 4c2963e015
commit 99e6a937a5
No known key found for this signature in database
GPG Key ID: A72BEC6CD3D0DED1
2 changed files with 0 additions and 24 deletions

View File

@ -916,8 +916,6 @@ func (s *Storage) mustLoadHourMetricIDs(hour uint64, name string) *hourMetricIDs
} }
// Unmarshal header // Unmarshal header
isFull := encoding.UnmarshalUint64(src)
src = src[8:]
hourLoaded := encoding.UnmarshalUint64(src) hourLoaded := encoding.UnmarshalUint64(src)
src = src[8:] src = src[8:]
if hourLoaded != hour { if hourLoaded != hour {
@ -971,7 +969,6 @@ func (s *Storage) mustLoadHourMetricIDs(hour uint64, name string) *hourMetricIDs
hm.m = m hm.m = m
hm.byTenant = byTenant 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) logger.Infof("loaded %s from %q in %.3f seconds; entriesCount: %d; sizeBytes: %d", name, path, time.Since(startTime).Seconds(), m.Len(), srcOrigLen)
return hm return hm
} }
@ -1000,13 +997,8 @@ func (s *Storage) mustSaveHourMetricIDs(hm *hourMetricIDs, name string) {
logger.Infof("saving %s to %q...", name, path) logger.Infof("saving %s to %q...", name, path)
startTime := time.Now() startTime := time.Now()
dst := make([]byte, 0, hm.m.Len()*8+24) dst := make([]byte, 0, hm.m.Len()*8+24)
isFull := uint64(0)
if hm.isFull {
isFull = 1
}
// Marshal header // Marshal header
dst = encoding.MarshalUint64(dst, isFull)
dst = encoding.MarshalUint64(dst, hm.hour) dst = encoding.MarshalUint64(dst, hm.hour)
// Marshal hm.m // Marshal hm.m
@ -2470,7 +2462,6 @@ func (s *Storage) updateCurrHourMetricIDs() {
// Slow path: hm.m must be updated with non-empty s.pendingHourEntries. // Slow path: hm.m must be updated with non-empty s.pendingHourEntries.
var m *uint64set.Set var m *uint64set.Set
var byTenant map[accountProjectKey]*uint64set.Set var byTenant map[accountProjectKey]*uint64set.Set
isFull := hm.isFull
if hm.hour == hour { if hm.hour == hour {
m = hm.m.Clone() m = hm.m.Clone()
byTenant = make(map[accountProjectKey]*uint64set.Set, len(hm.byTenant)) byTenant = make(map[accountProjectKey]*uint64set.Set, len(hm.byTenant))
@ -2480,7 +2471,6 @@ func (s *Storage) updateCurrHourMetricIDs() {
} else { } else {
m = &uint64set.Set{} m = &uint64set.Set{}
byTenant = make(map[accountProjectKey]*uint64set.Set) byTenant = make(map[accountProjectKey]*uint64set.Set)
isFull = true
} }
for _, x := range newEntries { for _, x := range newEntries {
@ -2501,7 +2491,6 @@ func (s *Storage) updateCurrHourMetricIDs() {
m: m, m: m,
byTenant: byTenant, byTenant: byTenant,
hour: hour, hour: hour,
isFull: isFull,
} }
s.currHourMetricIDs.Store(hmNew) s.currHourMetricIDs.Store(hmNew)
if hm.hour != hour { if hm.hour != hour {
@ -2513,7 +2502,6 @@ type hourMetricIDs struct {
m *uint64set.Set m *uint64set.Set
byTenant map[accountProjectKey]*uint64set.Set byTenant map[accountProjectKey]*uint64set.Set
hour uint64 hour uint64
isFull bool
} }
type generationTSID struct { type generationTSID struct {

View File

@ -174,9 +174,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) {
if hmCurr.m.Len() != 0 { if hmCurr.m.Len() != 0 {
t.Fatalf("unexpected length of hm.m; got %d; want %d", 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) hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs)
if !reflect.DeepEqual(hmPrev, hmOrig) { if !reflect.DeepEqual(hmPrev, hmOrig) {
@ -211,9 +208,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) {
if !reflect.DeepEqual(hmCurr, hmOrig) { if !reflect.DeepEqual(hmCurr, hmOrig) {
t.Fatalf("unexpected hmCurr; got %v; want %v", 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) hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs)
hmEmpty := &hourMetricIDs{} hmEmpty := &hourMetricIDs{}
@ -272,9 +266,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) {
if !reflect.DeepEqual(hmCurr.byTenant, byTenantExpected) { if !reflect.DeepEqual(hmCurr.byTenant, byTenantExpected) {
t.Fatalf("unexpected hmPrev.byTenant; got %v; want %v", 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) hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs)
if !reflect.DeepEqual(hmPrev, hmOrig) { if !reflect.DeepEqual(hmPrev, hmOrig) {
@ -341,9 +332,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) {
if !reflect.DeepEqual(hmCurr.byTenant, byTenantExpected) { if !reflect.DeepEqual(hmCurr.byTenant, byTenantExpected) {
t.Fatalf("unexpected hmPrev.byTenant; got %v; want %v", 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) hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs)
hmEmpty := &hourMetricIDs{} hmEmpty := &hourMetricIDs{}