huaxiangsun commented on a change in pull request #2753:
URL: https://github.com/apache/hbase/pull/2753#discussion_r538795053
##########
File path:
hbase-client/src/main/java/org/apache/hadoop/hbase/client/RegionInfo.java
##########
@@ -363,7 +363,23 @@ static TableName getTable(final byte [] regionName) {
@InterfaceAudience.Private // For use by internals only.
public static boolean isEncodedRegionName(byte[] regionName) {
// If not parseable as region name, presume encoded. TODO: add stringency;
e.g. if hex.
- return parseRegionNameOrReturnNull(regionName) == null &&
regionName.length <= MD5_HEX_LENGTH;
+ if (parseRegionNameOrReturnNull(regionName) == null) {
+ if (regionName.length > MD5_HEX_LENGTH) {
+ return false;
+ } else if (regionName.length == MD5_HEX_LENGTH) {
+ return true;
Review comment:
Thanks @saintstack. Two issues are addressed.
For compact/flush/split with the tableName,
` # Requests a table or region or column family major compaction
def major_compact(table_or_region_name, family = nil, type = 'NORMAL')
family_bytes = nil
family_bytes = family.to_java_bytes unless family.nil?
compact_type = nil
if type == 'NORMAL'
compact_type = org.apache.hadoop.hbase.client.CompactType::NORMAL
elsif type == 'MOB'
compact_type = org.apache.hadoop.hbase.client.CompactType::MOB
else
raise ArgumentError, 'only NORMAL or MOB accepted for type!'
end
begin
if family_bytes.nil?
@admin.majorCompactRegion(table_or_region_name.to_java_bytes)
else
@admin.majorCompactRegion(table_or_region_name.to_java_bytes,
family_bytes)
end
rescue java.lang.IllegalArgumentException,
org.apache.hadoop.hbase.UnknownRegionException
if family_bytes.nil?
@admin.majorCompact(TableName.valueOf(table_or_region_name),
compact_type)
else
@admin.majorCompact(TableName.valueOf(table_or_region_name),
family_bytes, compact_type)
end
end
end
`
it first calls majorCompactRegion() with tableName as input. It expects an
IllegalArgumentException or UnknownRegionException to call majorCompact().
This normally involves a registry query to get this UnknownRegionException,
this is an expensive path.
If it knows that the input string is not an encodedRegionName or regionName,
it can throw out IllegalArgumentException without registry query.
For the case that a md5 hex being used as tableName, it has to go through
expensive path to find out that this is not an encodedRegionName, it will still
work, just optimization wont be applied in this case.
It also fixes a bug for a table name length over 32 bytes, currently,
compact/flush/split this tableName from shell will fail.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]