File tree 1 file changed +14
-2
lines changed
hbase-client/src/main/java/org/apache/hadoop/hbase/client
1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,7 @@ class MutableRegionInfo implements RegionInfo {
64
64
private final int hashCode ;
65
65
private final String encodedName ;
66
66
private final byte [] encodedNameAsBytes ;
67
+ private String nameAsString = null ;
67
68
private final TableName tableName ;
68
69
69
70
private static int generateHashCode (final TableName tableName , final byte [] startKey ,
@@ -149,10 +150,21 @@ public byte[] getRegionName() {
149
150
return regionName ;
150
151
}
151
152
152
- /** Returns Region name as a String for use in logging, etc. */
153
+ /**
154
+ * Returns region name as a String for use in logging, tracing, etc. Expensive enough to compute
155
+ * that we do it on first request and save it. Used often because it's included in trace of every
156
+ * RPC.
157
+ */
153
158
@ Override
154
159
public String getRegionNameAsString () {
155
- return RegionInfo .getRegionNameAsString (this , this .regionName );
160
+ if (nameAsString == null ) {
161
+ String name = RegionInfo .getRegionNameAsString (this , this .regionName );
162
+ // may race with other threads setting this, but that's ok
163
+ nameAsString = name ;
164
+ return name ;
165
+ } else {
166
+ return nameAsString ;
167
+ }
156
168
}
157
169
158
170
/** Returns the encoded region name */
You can’t perform that action at this time.
0 commit comments