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(
        "Invalid range: " + Bytes.toStringBinary(startKey) + " > " + Bytes.toStringBinary(endKey));
    }
    List<byte[]> keysInRange = new ArrayList<>();
    List<HRegionLocation> regionsInRange = new ArrayList<>();
    byte[] currentKey = startKey;
    do {
      HRegionLocation regionLocation =
        FutureUtils.get(conn.getRegionLocator(getName()).getRegionLocation(currentKey, reload));
      keysInRange.add(currentKey);
      regionsInRange.add(regionLocation);
      currentKey = regionLocation.getRegion().getEndKey();
    } while (
      !Bytes.equals(currentKey, HConstants.EMPTY_END_ROW)
        && (endKeyIsEndOfTable || Bytes.compareTo(currentKey, endKey) < 0
          || (includeEndKey && Bytes.compareTo(currentKey, endKey) == 0))
    );
    return new Pair<>(keysInRange, regionsInRange);
  }
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
hbase-client/src/main/java/org/apache/hadoop/hbase/client/TableOverAsyncTable.java