class TextHashFunctions extends TextBuiltin
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.Modifier and Type | Class and 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.
|
TextBuiltin.TerminatedByHelpException
Modifier and Type | Field and 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 and Description |
---|
TextHashFunctions() |
Modifier and Type | Method and 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) |
containsHelp, die, die, die, die, execute, getErrorWriter, getOutputWriter, getRepository, getResourceBundle, init, initRaw, parseArguments, printUsage, printUsageAndExit, printUsageAndExit
final TextHashFunctions.Hash sha1
final TextHashFunctions.Hash djb
final TextHashFunctions.Hash string_hash31
final TextHashFunctions.Hash rabin_DeltaIndex
final TextHashFunctions.Fold truncate
final TextHashFunctions.Fold golden_ratio
java.util.List<java.lang.String> hashFunctions
java.util.List<java.lang.String> foldFunctions
int textLimit
java.util.List<java.io.File> gitDirs
protected boolean requiresRepository()
requiresRepository
in class TextBuiltin
TextBuiltin.db
/TextBuiltin.getRepository()
is requiredprotected void run() throws java.lang.Exception
This method should only be invoked by TextBuiltin.execute(String[])
.
run
in class TextBuiltin
java.lang.Exception
- an error occurred while processing the command. The main
framework will catch the exception and print a message on
standard error.private void run(Repository repo) throws java.lang.Exception
java.lang.Exception
private static void testOne(TextHashFunctions.Function fun, RawText txt, int[] elements, int cnt)
private java.util.List<TextHashFunctions.Function> init()
private static boolean include(java.lang.String name, java.util.List<java.lang.String> want)
private static int tableBits(int sz)