keyDistri.resize(numSplits);
Assert.assertEquals(totalBytes, keyDistri.length());
RawComparable[] rawComparables = keyDistri.getKeys();
keys = new BytesWritable[rawComparables.length];
for (int i = 0; i < keys.length; ++i) {
keys[i] = new BytesWritable();
keys[i].setSize(rawComparables[i].size());
System.arraycopy(rawComparables[i].buffer(),
rawComparables[i].offset(), keys[i].get(), 0, rawComparables[i]
.size());
}
} else {
int targetSize = Math.min(totalRows / 10, numSplits);
// revert to manually cooked up keys.
Set<Integer> keySets = new TreeSet<Integer>();
while (keySets.size() < targetSize) {
keySets.add(random.nextInt(totalRows));
}
keys = new BytesWritable[targetSize];
if (!keySets.isEmpty()) {
int j = 0;
for (int i : keySets.toArray(new Integer[keySets.size()])) {
keys[j] = makeKey(i);
++j;
}
}
}
int total = 0;
for (int i = 0; i < keys.length; ++i) {
reader = new ColumnGroup.Reader(path, conf);
reader.setProjection(strProjection);
BytesWritable begin = (i == 0) ? null : keys[i - 1];
BytesWritable end = (i == keys.length - 1) ? null : keys[i];
total += doReadOnly(reader.getScanner(begin, end, true));
}
Assert.assertEquals(total, totalRows);
}