edu.internet2.middleware.ldappc.util
Class ExternalSort

java.lang.Object
  extended by edu.internet2.middleware.ldappc.util.ExternalSort

public final class ExternalSort
extends Object

This package implement an external merge sort based on Collections sorting. An input file is divided into batches, which are sorted separately using the Collections.sort method. These batches are then merged into a single sorted file. The resulting file overwrites the initial file. The intermediate batch files are deleted.


Method Summary
static void main(String[] args)
          Main method to use for external testing of this routine.
static void sort(String filename)
          Sort a file using the default batch size.
static void sort(String filename, int batchSize)
          Sort a file using the batch size provided.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

main

public static void main(String[] args)
Main method to use for external testing of this routine. For some systems, the batch size may need to be adjusted.

Parameters:
args - Command line args: filename - the file to be sorted; batchsize - the number of lines to be sorted in memory.

sort

public static void sort(String filename)
                 throws IOException
Sort a file using the default batch size.

Parameters:
filename - The file to be sorted.
Throws:
IOException - Thrown if a file cannot be read or written.

sort

public static void sort(String filename,
                        int batchSize)
                 throws IOException
Sort a file using the batch size provided.

Parameters:
filename - the file to be sorted.
batchSize - the batch size, that is, the number of lines to batch and sort in memory.
Throws:
IOException - Thrown if a file cannot be read or written.


Copyright © 2011 Internet2. All Rights Reserved.