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 706ed48482
commit 1d6068821e
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1
2 changed files with 4 additions and 28 deletions

View file

@ -904,8 +904,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 {
@ -924,7 +922,6 @@ func (s *Storage) mustLoadHourMetricIDs(hour uint64, name string) *hourMetricIDs
return hm
}
hm.m = m
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
}
@ -953,13 +950,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
@ -2396,12 +2388,10 @@ func (s *Storage) updateCurrHourMetricIDs(hour uint64) {
// Slow path: hm.m must be updated with non-empty s.pendingHourEntries.
var m *uint64set.Set
isFull := hm.isFull
if hm.hour == hour {
m = hm.m.Clone()
} else {
m = &uint64set.Set{}
isFull = true
}
if hour%24 != 0 {
// Do not add pending metricIDs from the previous hour to the current hour on the next day,
@ -2410,9 +2400,8 @@ func (s *Storage) updateCurrHourMetricIDs(hour uint64) {
m.Union(newMetricIDs)
}
hmNew := &hourMetricIDs{
m: m,
hour: hour,
isFull: isFull,
m: m,
hour: hour,
}
s.currHourMetricIDs.Store(hmNew)
if hm.hour != hour {
@ -2421,9 +2410,8 @@ func (s *Storage) updateCurrHourMetricIDs(hour uint64) {
}
type hourMetricIDs struct {
m *uint64set.Set
hour uint64
isFull bool
m *uint64set.Set
hour uint64
}
type generationTSID struct {

View file

@ -176,9 +176,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) {
@ -213,9 +210,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{}
@ -255,9 +249,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) {
if !hmCurr.m.Equal(pendingHourEntries) {
t.Fatalf("unexpected hmCurr.m; got %v; want %v", hmCurr.m, pendingHourEntries)
}
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) {
@ -305,9 +296,6 @@ func TestUpdateCurrHourMetricIDs(t *testing.T) {
if !hmCurr.m.Equal(m) {
t.Fatalf("unexpected hm.m; got %v; want %v", hmCurr.m, m)
}
if hmCurr.isFull {
t.Fatalf("unexpected hmCurr.isFull; got %v; want %v", hmCurr.isFull, false)
}
hmPrev := s.prevHourMetricIDs.Load().(*hourMetricIDs)
hmEmpty := &hourMetricIDs{}