Sort rows by inserting them into a {@link TreeMap} and then reading them out in order.
Behavior
The rows of the input stream are written into a map that orders rows according to the ordering specification. Once the input stream has been consumed, the map is iterated from beginning to end to provide rows of the output stream.
Performance
MemorySorter generates no IO.
Memory Requirements
Memory requirements are dependent on the size of the input stream. One Key is generated for each Row and each Row is copied to be held in memory. All rows from the input stream are held until close.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.