protected void drainBuffer(int firstKey, int secondKey) {
IntegerBuffer buffer = buffers.get(firstKey).get(secondKey);
int[] arr;
synchronized (buffer) {
arr = buffer.toIntArray();
buffers.get(firstKey).put(secondKey, new IntegerBuffer(BUFFER_CAPACITY));
}
Arrays.sort(arr);
DiscreteDistribution dist = new DiscreteDistribution(arr);
mergeWith(firstKey, secondKey, dist);