Package org.eclipse.jgit.pgm.debug
Class TextHashFunctions
java.lang.Object
org.eclipse.jgit.pgm.TextBuiltin
org.eclipse.jgit.pgm.debug.TextHashFunctions
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Base class for any hashCode folding function to be tested.private static class
private static class
Base class for any hashCode function to be tested.private static class
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
FieldsModifier and TypeFieldDescription(package private) final TextHashFunctions.Hash
Professor Daniel J.(package private) final TextHashFunctions.Fold
Applies the golden ratio and takes the upper bits.(package private) final TextHashFunctions.Hash
The Rabin polynomial hash that is used by our own DeltaIndex.(package private) final TextHashFunctions.Hash
Standard SHA-1 on the line, using the first 4 bytes as the hash code.(package private) final TextHashFunctions.Hash
Hash function commonly used by java.lang.String.(package private) int
(package private) final TextHashFunctions.Fold
Bitwise-and to extract only the low bits. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
private List<TextHashFunctions.Function>
init()
protected boolean
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 Details
-
sha1
Standard SHA-1 on the line, using the first 4 bytes as the hash code. -
djb
Professor Daniel J. Bernstein's rather popular string hash. -
string_hash31
Hash function commonly used by java.lang.String. -
rabin_DeltaIndex
The Rabin polynomial hash that is used by our own DeltaIndex. -
truncate
Bitwise-and to extract only the low bits. -
golden_ratio
Applies the golden ratio and takes the upper bits. -
hashFunctions
-
foldFunctions
-
textLimit
int textLimit -
gitDirs
-
-
Constructor Details
-
TextHashFunctions
TextHashFunctions()
-
-
Method Details
-
requiresRepository
protected boolean requiresRepository()If this command requires a repository.- Overrides:
requiresRepository
in classTextBuiltin
- Returns:
- true if
TextBuiltin.db
/TextBuiltin.getRepository()
is required
-
run
Perform the actions of this command.This method should only be invoked by
TextBuiltin.execute(String[])
.- Specified by:
run
in classTextBuiltin
- Throws:
Exception
- an error occurred while processing the command. The main framework will catch the exception and print a message on standard error.
-
run
- Throws:
Exception
-
testOne
-
init
-
include
-
tableBits
private static int tableBits(int sz)
-