Package org.eclipse.jgit.pgm.debug
Class TextHashFunctions
- java.lang.Object
-
- org.eclipse.jgit.pgm.TextBuiltin
-
- org.eclipse.jgit.pgm.debug.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 typeTextHashFunctions.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 typeTextHashFunctions.Fold
and implement the logic. The test suite will automatically pick up the new function through reflection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
TextHashFunctions.Fold
Base class for any hashCode folding function to be tested.private static class
TextHashFunctions.Function
private static class
TextHashFunctions.Hash
Base class for any hashCode function to be tested.private static class
TextHashFunctions.Line
Utility to help us identify unique lines in a file.-
Nested classes/interfaces inherited from class org.eclipse.jgit.pgm.TextBuiltin
TextBuiltin.TerminatedByHelpException
-
-
Field Summary
Fields Modifier and Type Field Description (package private) TextHashFunctions.Hash
djb
Professor Daniel J.(package private) java.util.List<java.lang.String>
foldFunctions
(package private) java.util.List<java.io.File>
gitDirs
(package private) TextHashFunctions.Fold
golden_ratio
Applies the golden ratio and takes the upper bits.(package private) java.util.List<java.lang.String>
hashFunctions
(package private) TextHashFunctions.Hash
rabin_DeltaIndex
The Rabin polynomial hash that is used by our own DeltaIndex.(package private) TextHashFunctions.Hash
sha1
Standard SHA-1 on the line, using the first 4 bytes as the hash code.(package private) TextHashFunctions.Hash
string_hash31
Hash function commonly used by java.lang.String.(package private) int
textLimit
(package private) TextHashFunctions.Fold
truncate
Bitwise-and to extract only the low bits.
-
Constructor Summary
Constructors Constructor Description TextHashFunctions()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static boolean
include(java.lang.String name, java.util.List<java.lang.String> want)
private java.util.List<TextHashFunctions.Function>
init()
protected boolean
requiresRepository()
If this command requires a repository.protected void
run()
Perform the actions of this command.private void
run(Repository repo)
private static int
tableBits(int sz)
private static void
testOne(TextHashFunctions.Function fun, RawText txt, int[] elements, int cnt)
-
Methods inherited from class org.eclipse.jgit.pgm.TextBuiltin
containsHelp, die, die, die, die, execute, getErrorWriter, getOutputWriter, getRepository, getResourceBundle, init, initRaw, parseArguments, printUsage, printUsageAndExit, printUsageAndExit
-
-
-
-
Field Detail
-
sha1
final TextHashFunctions.Hash sha1
Standard SHA-1 on the line, using the first 4 bytes as the hash code.
-
djb
final TextHashFunctions.Hash djb
Professor Daniel J. Bernstein's rather popular string hash.
-
string_hash31
final TextHashFunctions.Hash string_hash31
Hash function commonly used by java.lang.String.
-
rabin_DeltaIndex
final TextHashFunctions.Hash rabin_DeltaIndex
The Rabin polynomial hash that is used by our own DeltaIndex.
-
truncate
final TextHashFunctions.Fold truncate
Bitwise-and to extract only the low bits.
-
golden_ratio
final TextHashFunctions.Fold golden_ratio
Applies the golden ratio and takes the upper bits.
-
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
-
-
Method Detail
-
requiresRepository
protected boolean requiresRepository()
If this command requires a repository.- Overrides:
requiresRepository
in classTextBuiltin
- Returns:
- true if
TextBuiltin.db
/TextBuiltin.getRepository()
is required
-
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 classTextBuiltin
- 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
-
testOne
private static void testOne(TextHashFunctions.Function fun, RawText txt, int[] elements, int cnt)
-
init
private java.util.List<TextHashFunctions.Function> init()
-
include
private static boolean include(java.lang.String name, java.util.List<java.lang.String> want)
-
tableBits
private static int tableBits(int sz)
-
-