Skip to content

Commit 2ce4446

Browse files
authored
hot_region: assign historyLoads to LoadPred.Current (#9271)
close #9270 Signed-off-by: okJiang <[email protected]>
1 parent abcb383 commit 2ce4446

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

pkg/statistics/store_collection_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ func TestSummaryStoreInfos(t *testing.T) {
140140
expect := []float64{2, 4, 10}
141141
for _, detail := range details {
142142
loads := detail.LoadPred.Current.HistoryLoads
143+
re.Len(loads, len(expectHistoryLoads))
143144
storeID := detail.GetID()
144145
for i := range loads {
145146
for j := range loads[0] {
@@ -149,6 +150,7 @@ func TestSummaryStoreInfos(t *testing.T) {
149150
}
150151
}
151152

153+
re.Len(detail.LoadPred.Expect.HistoryLoads, len(expectHistoryLoads))
152154
for i, loads := range detail.LoadPred.Expect.HistoryLoads {
153155
for _, load := range loads {
154156
if load != 0 {

pkg/statistics/store_hot_peers_infos.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,13 @@ func summaryStoresLoadByEngine(
176176

177177
var historyLoads [][]float64
178178
if storesHistoryLoads != nil {
179-
for i, historyLoads := range storesHistoryLoads.Get(id, rwTy, kind) {
180-
if allStoreHistoryLoadSum[i] == nil || len(allStoreHistoryLoadSum[i]) < len(historyLoads) {
181-
allStoreHistoryLoadSum[i] = make([]float64, len(historyLoads))
179+
historyLoads = storesHistoryLoads.Get(id, rwTy, kind)
180+
181+
for i, loads := range historyLoads {
182+
if allStoreHistoryLoadSum[i] == nil || len(allStoreHistoryLoadSum[i]) < len(loads) {
183+
allStoreHistoryLoadSum[i] = make([]float64, len(loads))
182184
}
183-
for j, historyLoad := range historyLoads {
185+
for j, historyLoad := range loads {
184186
allStoreHistoryLoadSum[i][j] += historyLoad
185187
}
186188
}

0 commit comments

Comments
 (0)