public static byte[][] inferBoundaries(SortedMap<byte[], Integer> bdryMap) {
    List<byte[]> keysArray = new ArrayList<>();
    int runningValue = 0;
    byte[] currStartKey = null;
    boolean firstBoundary = true;

    for (Map.Entry<byte[], Integer> item : bdryMap.entrySet()) {
      if (runningValue == 0) {
        currStartKey = item.getKey();
      }
      runningValue += item.getValue();
      if (runningValue == 0) {
        if (!firstBoundary) {
          keysArray.add(currStartKey);
        }
        firstBoundary = false;
      }
    }

    return keysArray.toArray(new byte[0][]);
  }
Infers region boundaries for a new table.
<p/>
Parameter: <br/>
bdryMap is a map between keys to an integer belonging to {+1, -1}
<ul>
<li>If a key is a start key of a file, then it maps to +1</li>
<li>If a key is an end key of a file, then it maps to -1</li>
</ul>
<p>
Algo:<br/>
<ol>
<li>Poll on the keys in order:
<ol type="a">
<li>Keep adding the mapped values to these keys (runningSum)</li>
<li>Each time runningSum reaches 0, add the start Key from when the runningSum had started to a
boundary list.</li>
</ol>
</li>
<li>Return the boundary list.</li>
</ol>
hbase-server/src/main/java/org/apache/hadoop/hbase/tool/BulkLoadHFilesTool.java