hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mberto...@apache.org
Subject svn commit: r1485540 - /hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
Date Thu, 23 May 2013 02:16:30 GMT
Author: mbertozzi
Date: Thu May 23 02:16:30 2013
New Revision: 1485540

URL: http://svn.apache.org/r1485540
Log:
HBASE-8504 HTable.getRegionsInRange() should provide a non-cached API

Modified:
    hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java

Modified: hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java?rev=1485540&r1=1485539&r2=1485540&view=diff
==============================================================================
--- hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java (original)
+++ hbase/trunk/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java Thu
May 23 02:16:30 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();



Mime
View raw message