diff --git a/tools/pd-simulator/simulator/raft.go b/tools/pd-simulator/simulator/raft.go index f80d4173c801..01e7e879c29d 100644 --- a/tools/pd-simulator/simulator/raft.go +++ b/tools/pd-simulator/simulator/raft.go @@ -301,15 +301,15 @@ func generateKeys(size int) []string { func generateTableKeys(tableCount, size int) []string { v := make([]string, 0, size) groupNumber := size / tableCount - id := 0 + tableID := 0 + var key []byte for size > 0 { - id++ - tableID := id + tableID++ for rowID := 0; rowID < groupNumber && size > 0; rowID++ { - key := table.GenerateRowKey(int64(tableID), int64(rowID)) if rowID == 0 { key = table.GenerateTableKey(int64(tableID)) - continue + } else { + key = table.GenerateRowKey(int64(tableID), int64(rowID)) } key = table.EncodeBytes(key) v = append(v, string(key)) @@ -355,7 +355,7 @@ func mustDecodeMvccKey(key []byte) []byte { // generateTiDBEncodedSplitKey calculates the split key with start and end key, // the keys are encoded according to the TiDB encoding rules. -// The algorithm is the computationally the logical median. +// The split key is the logical median. func generateTiDBEncodedSplitKey(start, end []byte) []byte { if bytes.Equal(start, end) { simutil.Logger.Fatal("start key and end key should not be same")