Class ExternalSortTuples

java.lang.Object
com.semedy.reasoner.edb.persistentstore.ExternalSortTuples

public class ExternalSortTuples extends Object
sorts large files of tuples in binary format (arrays of longs )
  • 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 file
      tuplesize - , the size of a tuple in bytes
      indexedPositions - , the indexed positions of a tuple
      tempdir - , the temporary directory,
      Returns:
      Throws:
      EDBException
      IOException
    • 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 tuples
      tuplesize - , the size of a tuple in bytes
      indexedPositions - , the indexed positions of a tuple
      tempdir - , the temporary directory,
      Returns:
      Throws:
      EDBException
      IOException
    • 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 merged
      tuplelength - , the length of tuples in bytes
      indexedPositions - , the indexed positions of a tuple
      consumer - , the consumer who received the tuples in sorted order
      Throws:
      IOException
      EDBException
    • 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 sequence
      numberOfTuples - , number of tuples in array
      arity - , arity of tuples
      tempdir - , 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 sequence
      numberOfTuples - , number of tuples in array
      arity - , arity of tuples
      file - , 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 file
      tuplesize - , size of a tuple in bytes
      tempdir - , temporary directory
      Returns:
      Throws:
      EDBException
      IOException
    • sortFileZipped

      public static List<File> sortFileZipped(File file, int tuplesize, File tempdir) throws IOException, EDBException
      sort a compressed tuple file
      Parameters:
      file - , the tuple file
      tuplesize - , size of a tuple in bytes
      tempdir - , temporary directory
      Returns:
      Throws:
      EDBException
      IOException
    • sortFile

      public static List<File> sortFile(File file, int tuplesize, File tempdir) throws IOException, EDBException
      sort an (uncompressed) tuple file
      Parameters:
      file - , the tuple file
      tuplesize - , size of a tuple in bytes
      tempdir - , temporary directory
      Returns:
      Throws:
      EDBException
      IOException
    • 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 files
      tuplelength - , length of a tuple in bytes
      consumer - , the consumer who gets the tuples
      Throws:
      IOException
      EDBException
    • 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 files
      tuplelength - , length of a tuple in bytes
      consumer - , the consumer who gets the tuples
      Throws:
      IOException
      EDBException
    • 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 files
      tuplelength - , length of a tuple in bytes
      consumer - , the consumer who gets the tuples
      Throws:
      IOException
      EDBException
    • 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 from
      fileToSubtract - , the sorted file containing the tuples to substract
      tuplelength - , tuple length in bytes
      consumer - , the consumer who gets the resulting tuples
      Throws:
      IOException
      EDBException
    • 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 files
      tuplelength - , length of a tuple in bytes
      consumer - , the consumer who gets the tuples
      Throws:
      IOException
      EDBException