Class TextHashFunctions


  • class TextHashFunctions
    extends TextBuiltin
    Scan repository to compute maximum number of collisions for hash functions. This is a test suite to help benchmark the collision rate of hash functions when applied to file contents in a Git repository. The test scans all text files in the HEAD revision of the repository it is run within. For each file it finds the unique lines, and then inserts those lines into a hash table to determine collision rates under the selected hash functions. To add another hash function to the test suite, declare a new instance member field of type TextHashFunctions.Hash and implement the hashRegion method. The test suite will automatically pick up the new function through reflection. To add another folding function (method of squashing a 32 bit hash code into the hash tables smaller array index space), declare a new instance field of type TextHashFunctions.Fold and implement the logic. The test suite will automatically pick up the new function through reflection.
    • Field Detail

      • sha1

        final TextHashFunctions.Hash sha1
        Standard SHA-1 on the line, using the first 4 bytes as the hash code.
      • rabin_DeltaIndex

        final TextHashFunctions.Hash rabin_DeltaIndex
        The Rabin polynomial hash that is used by our own DeltaIndex.
      • hashFunctions

        java.util.List<java.lang.String> hashFunctions
      • foldFunctions

        java.util.List<java.lang.String> foldFunctions
      • textLimit

        int textLimit
      • gitDirs

        java.util.List<java.io.File> gitDirs
    • Constructor Detail

      • TextHashFunctions

        TextHashFunctions()
    • Method Detail

      • run

        protected void run()
                    throws java.lang.Exception
        Perform the actions of this command.

        This method should only be invoked by TextBuiltin.execute(String[]).

        Specified by:
        run in class TextBuiltin
        Throws:
        java.lang.Exception - an error occurred while processing the command. The main framework will catch the exception and print a message on standard error.
      • run

        private void run​(Repository repo)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • include

        private static boolean include​(java.lang.String name,
                                       java.util.List<java.lang.String> want)
      • tableBits

        private static int tableBits​(int sz)