Interface RuleKeyHasher<HASH>

  • All Known Implementing Classes:
    CountingRuleKeyHasher, ForwardingRuleKeyHasher, GuavaRuleKeyHasher, StringRuleKeyHasher, ThriftRuleKeyHasher

    public interface RuleKeyHasher<HASH>
    A hasher used for the rule key construction.

    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).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.:
     public class myRule implements BuildRule {