Class ExternalSortTuples
java.lang.Object
com.semedy.reasoner.edb.persistentstore.ExternalSortTuples
sorts large files of tuples in binary format (arrays of longs )
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic longstatic voidmergeFiles(List<File> files, int tuplelength, ExternalSortTuplesConsumer consumer) merge a list of sorted tuple files (uncompressed) to one sorted filestatic voidmergeFilesZipped(List<File> files, int tuplelength, ExternalSortTuplesConsumer consumer) merge a list of sorted tuple files compressed to one sorted filestatic voidmergeIndexed(List<TupleFile> files, int tuplelength, int[] indexedPositions, ExternalSortTuplesConsumer consumer) merge several sorted files along indexed positionsstatic voidmergeNSubtract(List<TupleFile> files, int tuplelength, TupleFile fileToSubtract, ExternalSortTuplesConsumer consumer) merge a list of sorted files to one sorted file and subtract the tuples in toSubtractstatic voidmergeTupleFiles(List<TupleFile> files, int tuplelength, ExternalSortTuplesConsumer consumer) merge a list of sorted tuple files (compressed) to one sorted filesort an (uncompressed) tuple filesortFileZipped(File file, int tuplesize, File tempdir) sort a compressed tuple filesortIndexed(TupleEnumerator enm, int tuplesize, int[] indexedPositions, File tempdir) sort tuples along indexed positionssortIndexed(TupleFile file, int tuplesize, int[] indexedPositions, File tempdir) sort a tuple file along indexed positionsstatic voidsortNWriteToTupleFile(long[] list, int numberOfTuples, int arity, TupleFile file) Sort a list of tuples and write it to a (temporary) tuple file in tempdir.static TupleFilesortNWriteToTupleFile(long[] list, int numberOfTuples, int arity, File tempdir) Sort a list of tuples and write it to a (temporary) tuple file in tempdir.sortTupleFile(TupleFile file, int tuplesize, File tempdir) sort a (compressed) tuple filestatic voidsubtract(TupleFile fileToSubtractFrom, TupleFile fileToSubtract, int tuplelength, ExternalSortTuplesConsumer consumer) subtract a sorted file from another sorted file
-
Constructor Details
-
ExternalSortTuples
public ExternalSortTuples()
-
-
Method Details
-
guessSize
public static long guessSize() -
sortIndexed
public static List<TupleFile> sortIndexed(TupleFile file, int tuplesize, int[] indexedPositions, File tempdir) throws IOException, EDBException sort a tuple file along indexed positions- Parameters:
file- , the tuple filetuplesize- , the size of a tuple in bytesindexedPositions- , the indexed positions of a tupletempdir- , the temporary directory,- Returns:
- Throws:
EDBExceptionIOException
-
sortIndexed
public static List<TupleFile> sortIndexed(TupleEnumerator enm, int tuplesize, int[] indexedPositions, File tempdir) throws IOException, EDBException sort tuples along indexed positions- Parameters:
enm- , enumerator for tuplestuplesize- , the size of a tuple in bytesindexedPositions- , the indexed positions of a tupletempdir- , the temporary directory,- Returns:
- Throws:
EDBExceptionIOException
-
mergeIndexed
public static void mergeIndexed(List<TupleFile> files, int tuplelength, int[] indexedPositions, ExternalSortTuplesConsumer consumer) throws IOException, EDBException merge several sorted files along indexed positions- Parameters:
files- , the files to be mergedtuplelength- , the length of tuples in bytesindexedPositions- , the indexed positions of a tupleconsumer- , the consumer who received the tuples in sorted order- Throws:
IOExceptionEDBException
-
sortNWriteToTupleFile
public static TupleFile sortNWriteToTupleFile(long[] list, int numberOfTuples, int arity, File tempdir) throws IOException Sort a list of tuples and write it to a (temporary) tuple file in tempdir.- Parameters:
list- , all arguments (longs) of all tuples in a sequencenumberOfTuples- , number of tuples in arrayarity- , arity of tuplestempdir- , temp directory- Returns:
- sorted tuple file
- Throws:
IOException
-
sortNWriteToTupleFile
public static void sortNWriteToTupleFile(long[] list, int numberOfTuples, int arity, TupleFile file) throws IOException Sort a list of tuples and write it to a (temporary) tuple file in tempdir.- Parameters:
list- , all arguments (longs) of all tuples in a sequencenumberOfTuples- , number of tuples in arrayarity- , arity of tuplesfile- , tuple file to write to- Throws:
IOException
-
sortTupleFile
public static List<TupleFile> sortTupleFile(TupleFile file, int tuplesize, File tempdir) throws IOException, EDBException sort a (compressed) tuple file- Parameters:
file- , the tuple filetuplesize- , size of a tuple in bytestempdir- , temporary directory- Returns:
- Throws:
EDBExceptionIOException
-
sortFileZipped
public static List<File> sortFileZipped(File file, int tuplesize, File tempdir) throws IOException, EDBException sort a compressed tuple file- Parameters:
file- , the tuple filetuplesize- , size of a tuple in bytestempdir- , temporary directory- Returns:
- Throws:
EDBExceptionIOException
-
sortFile
public static List<File> sortFile(File file, int tuplesize, File tempdir) throws IOException, EDBException sort an (uncompressed) tuple file- Parameters:
file- , the tuple filetuplesize- , size of a tuple in bytestempdir- , temporary directory- Returns:
- Throws:
EDBExceptionIOException
-
mergeTupleFiles
public static void mergeTupleFiles(List<TupleFile> files, int tuplelength, ExternalSortTuplesConsumer consumer) throws IOException, EDBException merge a list of sorted tuple files (compressed) to one sorted file- Parameters:
files- , the list of sorted filestuplelength- , length of a tuple in bytesconsumer- , the consumer who gets the tuples- Throws:
IOExceptionEDBException
-
mergeFiles
public static void mergeFiles(List<File> files, int tuplelength, ExternalSortTuplesConsumer consumer) throws IOException, EDBException merge a list of sorted tuple files (uncompressed) to one sorted file- Parameters:
files- , the list of sorted filestuplelength- , length of a tuple in bytesconsumer- , the consumer who gets the tuples- Throws:
IOExceptionEDBException
-
mergeFilesZipped
public static void mergeFilesZipped(List<File> files, int tuplelength, ExternalSortTuplesConsumer consumer) throws IOException, EDBException merge a list of sorted tuple files compressed to one sorted file- Parameters:
files- , the list of sorted filestuplelength- , length of a tuple in bytesconsumer- , the consumer who gets the tuples- Throws:
IOExceptionEDBException
-
subtract
public static void subtract(TupleFile fileToSubtractFrom, TupleFile fileToSubtract, int tuplelength, ExternalSortTuplesConsumer consumer) throws IOException, EDBException subtract a sorted file from another sorted file- Parameters:
fileToSubtractFrom- , the sorted file to be subtracted fromfileToSubtract- , the sorted file containing the tuples to substracttuplelength- , tuple length in bytesconsumer- , the consumer who gets the resulting tuples- Throws:
IOExceptionEDBException
-
mergeNSubtract
public static void mergeNSubtract(List<TupleFile> files, int tuplelength, TupleFile fileToSubtract, ExternalSortTuplesConsumer consumer) throws IOException, EDBException merge a list of sorted files to one sorted file and subtract the tuples in toSubtract- Parameters:
files- , the list of sorted filestuplelength- , length of a tuple in bytesconsumer- , the consumer who gets the tuples- Throws:
IOExceptionEDBException
-