public interface RuleKeyHasher<HASH>
Warning: The result of calling any methods after calling hash()
is undefined.
Chunks of data that are put into the RuleKeyHasher
are delimited. Delimiting details
are implementation dependent, but one common way is to hash the size of the data along with the
data itself, for each operation performed. For example, the following three expressions should
ideally all generate different hash codes:
newHasher().putByte(b1).putByte(b2).putByte(b3).hash()
newHasher().putByte(b1).putBytes(new byte[] { b2, b3 }).hash()
newHasher().putBytes(new byte[] { b1, b2, b3 }).hash()
Note, Buck hashes both field values and field names (keys) when constructing rule keys. E.g.:
{@code public class myRule implements BuildRule {
Modifier and Type | Interface and Description |
---|---|
static class |
RuleKeyHasher.Container |
static class |
RuleKeyHasher.Wrapper |
RuleKeyHasher<HASH> putKey(String key)
RuleKeyHasher<HASH> putKeyPath(Path key)
RuleKeyHasher<HASH> putNull()
RuleKeyHasher<HASH> putCharacter(char val)
RuleKeyHasher<HASH> putBoolean(boolean val)
RuleKeyHasher<HASH> putNumber(Number val)
RuleKeyHasher<HASH> putString(String val)
RuleKeyHasher<HASH> putBytes(byte[] bytes)
RuleKeyHasher<HASH> putPattern(Pattern pattern)
RuleKeyHasher<HASH> putSha1(Sha1HashCode sha1)
RuleKeyHasher<HASH> putPath(Path path, com.google.common.hash.HashCode hash)
RuleKeyHasher<HASH> putArchiveMemberPath(Path relativeArchivePath, Path archiveMemberPath, com.google.common.hash.HashCode hash)
relativeArchivePath
- relative path to archive.archiveMemberPath
- path to archive member.RuleKeyHasher<HASH> putNonHashingPath(Path path)
RuleKeyHasher<HASH> putRuleKey(RuleKey ruleKey)
RuleKeyHasher<HASH> putRuleType(RuleType ruleType)
RuleKeyHasher<HASH> putBuildTarget(BuildTarget buildTarget)
RuleKeyHasher<HASH> putBuildTargetSourcePath(BuildTargetSourcePath buildTargetSourcePath)
RuleKeyHasher<HASH> putContainer(RuleKeyHasher.Container container, int length)
RuleKeyHasher<HASH> putWrapper(RuleKeyHasher.Wrapper wrapper)
HASH hash()