From 23960207527b685609cd01259efbeb98f077b209 Mon Sep 17 00:00:00 2001 From: ramkrishna Date: Wed, 22 Apr 2015 09:24:00 +0530 Subject: [PATCH] HBASE-13502 - Deprecate/remove getRowComparator() in TableName (Ram) --- .../java/org/apache/hadoop/hbase/client/MetaCache.java | 8 +++++++- .../src/main/java/org/apache/hadoop/hbase/TableName.java | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java index b1c7ac0104b..9cfc516efa6 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaCache.java @@ -31,11 +31,13 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; +import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.RegionLocations; import org.apache.hadoop.hbase.ServerName; import org.apache.hadoop.hbase.TableName; import org.apache.hadoop.hbase.classification.InterfaceAudience; import org.apache.hadoop.hbase.util.Bytes; +import org.apache.hadoop.hbase.KeyValue.KVComparator; /** * A cache implementation for region locations from meta. @@ -85,7 +87,7 @@ public class MetaCache { // checking is actually the last region in the table. byte[] endKey = possibleRegion.getRegionLocation().getRegionInfo().getEndKey(); if (Bytes.equals(endKey, HConstants.EMPTY_END_ROW) || - tableName.getRowComparator().compareRows( + getRowComparator(tableName).compareRows( endKey, 0, endKey.length, row, 0, row.length) > 0) { return possibleRegion; } @@ -94,6 +96,10 @@ public class MetaCache { return null; } + private KVComparator getRowComparator(TableName tableName) { + return TableName.META_TABLE_NAME.equals(tableName) ? KeyValue.META_COMPARATOR + : KeyValue.COMPARATOR; + } /** * Put a newly discovered HRegionLocation into the cache. * @param tableName The table name. diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java index 17fd3b7e68b..ff86963eca7 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/TableName.java @@ -513,7 +513,11 @@ public final class TableName implements Comparable { * Get the appropriate row comparator for this table. * * @return The comparator. + * @deprecated The comparator is an internal property of the table. Should + * not have been exposed here */ + @InterfaceAudience.Private + @Deprecated public KVComparator getRowComparator() { if(TableName.META_TABLE_NAME.equals(this)) { return KeyValue.META_COMPARATOR;