Skip to content

Commit 8a68134

Browse files
authored
client/http: expose approximate_kv_size in RegionInfo (#10568)
ref #10567 client/http: expose approximate_kv_size in RegionInfo Signed-off-by: D3Hunter <jujj603@gmail.com>
1 parent 319d880 commit 8a68134

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

client/http/types.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,21 @@ var NewKeyRange = pd.NewKeyRange
7171

7272
// RegionInfo stores the information of one region.
7373
type RegionInfo struct {
74-
ID int64 `json:"id"`
75-
StartKey string `json:"start_key"`
76-
EndKey string `json:"end_key"`
77-
Epoch RegionEpoch `json:"epoch"`
78-
Peers []RegionPeer `json:"peers"`
79-
Leader RegionPeer `json:"leader"`
80-
DownPeers []RegionPeerStat `json:"down_peers"`
81-
PendingPeers []RegionPeer `json:"pending_peers"`
82-
WrittenBytes uint64 `json:"written_bytes"`
83-
ReadBytes uint64 `json:"read_bytes"`
84-
WrittenKeys uint64 `json:"written_keys"`
85-
ReadKeys uint64 `json:"read_keys"`
86-
ApproximateSize int64 `json:"approximate_size"`
87-
ApproximateKeys int64 `json:"approximate_keys"`
74+
ID int64 `json:"id"`
75+
StartKey string `json:"start_key"`
76+
EndKey string `json:"end_key"`
77+
Epoch RegionEpoch `json:"epoch"`
78+
Peers []RegionPeer `json:"peers"`
79+
Leader RegionPeer `json:"leader"`
80+
DownPeers []RegionPeerStat `json:"down_peers"`
81+
PendingPeers []RegionPeer `json:"pending_peers"`
82+
WrittenBytes uint64 `json:"written_bytes"`
83+
ReadBytes uint64 `json:"read_bytes"`
84+
WrittenKeys uint64 `json:"written_keys"`
85+
ReadKeys uint64 `json:"read_keys"`
86+
ApproximateSize int64 `json:"approximate_size"`
87+
ApproximateKvSize int64 `json:"approximate_kv_size"`
88+
ApproximateKeys int64 `json:"approximate_keys"`
8889

8990
ReplicationStatus *ReplicationStatus `json:"replication_status,omitempty"`
9091
}

client/http/types_test.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ func TestMergeRegionsInfo(t *testing.T) {
159159
}
160160
}
161161

162+
func TestRegionInfoApproximateKvSizeDecode(t *testing.T) {
163+
re := require.New(t)
164+
165+
var region RegionInfo
166+
err := json.Unmarshal([]byte(`{"approximate_kv_size":123}`), &region)
167+
re.NoError(err)
168+
re.Equal(int64(123), region.ApproximateKvSize)
169+
}
170+
171+
func TestRegionInfoApproximateKvSizeDefaultZero(t *testing.T) {
172+
re := require.New(t)
173+
174+
var region RegionInfo
175+
err := json.Unmarshal([]byte(`{}`), &region)
176+
re.NoError(err)
177+
re.Zero(region.ApproximateKvSize)
178+
}
179+
162180
func TestRuleStartEndKey(t *testing.T) {
163181
re := require.New(t)
164182
// Empty start/end key and key hex.

0 commit comments

Comments
 (0)