HBASE-8504 HTable.getRegionsInRange() should provide a non-cached API
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1485540 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5583d1fb12
commit
f6a5cabe6d
|
@ -489,7 +489,22 @@ public class HTable implements HTableInterface {
|
||||||
*/
|
*/
|
||||||
public List<HRegionLocation> getRegionsInRange(final byte [] startKey,
|
public List<HRegionLocation> getRegionsInRange(final byte [] startKey,
|
||||||
final byte [] endKey) throws IOException {
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -506,6 +521,24 @@ public class HTable implements HTableInterface {
|
||||||
private Pair<List<byte[]>, List<HRegionLocation>> getKeysAndRegionsInRange(
|
private Pair<List<byte[]>, List<HRegionLocation>> getKeysAndRegionsInRange(
|
||||||
final byte[] startKey, final byte[] endKey, final boolean includeEndKey)
|
final byte[] startKey, final byte[] endKey, final boolean includeEndKey)
|
||||||
throws IOException {
|
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);
|
final boolean endKeyIsEndOfTable = Bytes.equals(endKey,HConstants.EMPTY_END_ROW);
|
||||||
if ((Bytes.compareTo(startKey, endKey) > 0) && !endKeyIsEndOfTable) {
|
if ((Bytes.compareTo(startKey, endKey) > 0) && !endKeyIsEndOfTable) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
|
@ -516,7 +549,7 @@ public class HTable implements HTableInterface {
|
||||||
List<HRegionLocation> regionsInRange = new ArrayList<HRegionLocation>();
|
List<HRegionLocation> regionsInRange = new ArrayList<HRegionLocation>();
|
||||||
byte[] currentKey = startKey;
|
byte[] currentKey = startKey;
|
||||||
do {
|
do {
|
||||||
HRegionLocation regionLocation = getRegionLocation(currentKey, false);
|
HRegionLocation regionLocation = getRegionLocation(currentKey, reload);
|
||||||
keysInRange.add(currentKey);
|
keysInRange.add(currentKey);
|
||||||
regionsInRange.add(regionLocation);
|
regionsInRange.add(regionLocation);
|
||||||
currentKey = regionLocation.getRegionInfo().getEndKey();
|
currentKey = regionLocation.getRegionInfo().getEndKey();
|
||||||
|
|
Loading…
Reference in New Issue