private void checkRegionIndexValid(int idx, List<Pair<byte[], byte[]>> startEndKeys,
    TableName tableName) throws IOException {
    if (idx < 0) {
      throw new IOException("The first region info for table " + tableName
        + " can't be found in hbase:meta.Please use hbck tool to fix it first.");
    } else if (
      (idx == startEndKeys.size() - 1)
        && !Bytes.equals(startEndKeys.get(idx).getSecond(), HConstants.EMPTY_BYTE_ARRAY)
    ) {
      throw new IOException("The last region info for table " + tableName
        + " can't be found in hbase:meta.Please use hbck tool to fix it first.");
    } else if (
      idx + 1 < startEndKeys.size() && !(Bytes.compareTo(startEndKeys.get(idx).getSecond(),
        startEndKeys.get(idx + 1).getFirst()) == 0)
    ) {
      throw new IOException("The endkey of one region for table " + tableName
        + " is not equal to the startkey of the next region in hbase:meta."
        + "Please use hbck tool to fix it first.");
    }
  }
we can consider there is a region hole or overlap in following conditions. 1) if idx < 0,then
first region info is lost. 2) if the endkey of a region is not equal to the startkey of the
next region. 3) if the endkey of the last region is not empty.
hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java