// numSplits <= 0 ?
int nLeaves = readers.size();
BlockDistribution lastBd = new BlockDistribution();
ArrayList<KeyDistribution> btKeyDistributions = new ArrayList<KeyDistribution>();
for (int i = 0; i < nLeaves; ++i) {
KeyDistribution btKeyDistri =
readers.get(i).getKeyDistribution(
(numSplits <= 0) ? -1 :
Math.max(numSplits * 5 / nLeaves, numSplits), nLeaves, lastBd);
btKeyDistributions.add(btKeyDistri);
}
int btSize = btKeyDistributions.size();
KeyDistribution[] btKds = new KeyDistribution[btSize];
Object[] btArray = btKeyDistributions.toArray();
for (int i = 0; i < btSize; i++)
btKds[i] = (KeyDistribution) btArray[i];
KeyDistribution keyDistri = KeyDistribution.merge(btKds);
if (keyDistri == null) {
// should never happen.
SortedTableSplit split = new SortedTableSplit(null, null, null, conf);
return new InputSplit[] { split };
}
keyDistri.resize(lastBd);
RawComparable[] keys = keyDistri.getKeys();
for (int i = 0; i <= keys.length; ++i) {
RawComparable begin = (i == 0) ? null : keys[i - 1];
RawComparable end = (i == keys.length) ? null : keys[i];
BlockDistribution bd;
if (i < keys.length)
bd = keyDistri.getBlockDistribution(keys[i]);
else
bd = lastBd;
BytesWritable beginB = null, endB = null;
if (begin != null)
beginB = new BytesWritable(begin.buffer());