You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by mb...@apache.org on 2013/05/23 04:18:23 UTC
svn commit: r1485541 -
/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Author: mbertozzi
Date: Thu May 23 02:18:22 2013
New Revision: 1485541
URL: http://svn.apache.org/r1485541
Log:
HBASE-8504 HTable.getRegionsInRange() should provide a non-cached API
Modified:
hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Modified: hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1485541&r1=1485540&r2=1485541&view=diff
==============================================================================
--- hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/branches/0.95/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java Thu May 23 02:18:22 2013
@@ -489,8 +489,23 @@ public class HTable implements HTableInt
*/
public List<HRegionLocation> getRegionsInRange(final byte [] startKey,
final byte [] endKey) throws IOException {
- return getKeysAndRegionsInRange(startKey, endKey, false).getSecond();
- }
+ return getRegionsInRange(startKey, endKey, false);
+ }
+
+ /**
+ * Get the corresponding regions for an arbitrary range of keys.
+ * <p>
+ * @param startKey Starting row in range, inclusive
+ * @param endKey Ending row in range, exclusive
+ * @param reload true to reload information or false to use cached information
+ * @return A list of HRegionLocations corresponding to the regions that
+ * contain the specified range
+ * @throws IOException if a remote or network exception occurs
+ */
+ public List<HRegionLocation> getRegionsInRange(final byte [] startKey,
+ final byte [] endKey, final boolean reload) throws IOException {
+ return getKeysAndRegionsInRange(startKey, endKey, false, reload).getSecond();
+ }
/**
* Get the corresponding start keys and regions for an arbitrary range of
@@ -506,6 +521,24 @@ public class HTable implements HTableInt
private Pair<List<byte[]>, List<HRegionLocation>> getKeysAndRegionsInRange(
final byte[] startKey, final byte[] endKey, final boolean includeEndKey)
throws IOException {
+ return getKeysAndRegionsInRange(startKey, endKey, includeEndKey, false);
+ }
+
+ /**
+ * Get the corresponding start keys and regions for an arbitrary range of
+ * keys.
+ * <p>
+ * @param startKey Starting row in range, inclusive
+ * @param endKey Ending row in range
+ * @param includeEndKey true if endRow is inclusive, false if exclusive
+ * @param reload true to reload information or false to use cached information
+ * @return A pair of list of start keys and list of HRegionLocations that
+ * contain the specified range
+ * @throws IOException if a remote or network exception occurs
+ */
+ private Pair<List<byte[]>, List<HRegionLocation>> getKeysAndRegionsInRange(
+ final byte[] startKey, final byte[] endKey, final boolean includeEndKey,
+ final boolean reload) throws IOException {
final boolean endKeyIsEndOfTable = Bytes.equals(endKey,HConstants.EMPTY_END_ROW);
if ((Bytes.compareTo(startKey, endKey) > 0) && !endKeyIsEndOfTable) {
throw new IllegalArgumentException(
@@ -516,7 +549,7 @@ public class HTable implements HTableInt
List<HRegionLocation> regionsInRange = new ArrayList<HRegionLocation>();
byte[] currentKey = startKey;
do {
- HRegionLocation regionLocation = getRegionLocation(currentKey, false);
+ HRegionLocation regionLocation = getRegionLocation(currentKey, reload);
keysInRange.add(currentKey);
regionsInRange.add(regionLocation);
currentKey = regionLocation.getRegionInfo().getEndKey();