virajjasani commented on code in PR #6868:
URL: https://github.com/apache/hbase/pull/6868#discussion_r2059064826
##########
hbase-client/src/main/java/org/apache/hadoop/hbase/client/metrics/ServerSideScanMetrics.java:
##########
@@ -117,4 +121,64 @@ public Map<String, Long> getMetricsMap(boolean reset) {
// Build the immutable map so that people can't mess around with it.
return builder.build();
}
+
+ public ServerName getServerName() {
+ return this.serverName;
+ }
+
+ public void setServerName(ServerName serverName) {
+ if (this.serverName == null) {
+ this.serverName = serverName;
+ }
+ }
+
+ public void setEncodedRegionName(String encodedRegionName) {
+ if (this.encodedRegionName == null) {
+ this.encodedRegionName = encodedRegionName;
+ }
+ }
+
+ public String getEncodedRegionName() {
+ return this.encodedRegionName;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("ServerName:");
+ sb.append(this.serverName);
+ sb.append(",EncodedRegion:");
+ sb.append(this.encodedRegionName);
+ sb.append(",[");
+ boolean isFirstMetric = true;
+ for (Map.Entry<String, AtomicLong> e : this.counters.entrySet()) {
+ if (isFirstMetric) {
+ isFirstMetric = false;
+ } else {
+ sb.append(",");
+ }
+ sb.append(e.getKey());
+ sb.append(":");
+ sb.append(e.getValue().get());
+ }
+ sb.append("]");
+ return sb.toString();
+ }
Review Comment:
> the only issue is it's based on reflection and is not very efficient.
Sad, I was not aware of this. I will also be careful with it.
@sanjeet006py you can leave this as is, let's go with StringBuilder(). The
only change is, you don't need to use for loop for `this.counters.entrySet()`.
The map should be printed by StringBuilder().
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]