// If we triggered the downsampler, we need to sort the reads before returning them,
// since the ReservoirDownsampler is not guaranteed to preserve relative ordering of items.
// After consuming the downsampled items in this call to popCurrentReads(), we switch back
// to using the undownsampledCache until we fill up again.
poppedReads = downsampler.consumeFinalizedItems(); // avoid making a copy here
Collections.sort(poppedReads, new AlignmentStartComparator());
downsampler = null;
}
initializeUndownsampledCache();
return poppedReads;