A reusable reader that performs a merge sort on the sorted files
A reusable reader that performs a merge sort on the sorted files
Note: We use RandomAccessFile to hold onto the FileDescriptor of the temp file and open FileInputStreams based on the FileDescriptor. This allows us to delete the unlink the temp file from the file system while retaining a reference to it here so we can still read it. Then when the FileDescriptor gets garbage collected OR the JVM shuts down the file will be automatically deleted.
(Since version ) see corresponding Javadoc for more information.
Keeps an in-memory buffer gets sorted once a size threshold is passed and written to a temp file. This is repeated until result() is called. Data is then read back from the temp files in sorted order.
This should be thread-safe