Class AdHash
- java.lang.Object
-
- com.linkedin.venice.kafka.validation.checksum.CheckSum
-
- com.linkedin.venice.kafka.validation.checksum.AdHash
-
public class AdHash extends CheckSum
This class AdHash is used to keep track of the checksum of the data incrementally. It adopts the idea of AdHash that: " A message x' which I want to hash may be a simple modification of a message x which I previously hashed. If I have already computed the hash f(x) of x then, rather than re-computing f(x') from scratch, I would like to just quickly 'update' the old hash value f(x) to the new value f(x'). An incremental hash function is one that permits this. " See the paper for details: A New Paradigm for Collision-free Hashing: Incrementality at Reduced Cost. (https://cseweb.ucsd.edu/~daniele/papers/IncHash.pdf) Its adoption in ZooKeeper: Verify, And Then Trust: Data Inconsistency Detection in ZooKeeper. (https://dl.acm.org/doi/abs/10.1145/3578358.3591328)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getEncodedState()
byte[]
getFinalCheckSum()
CheckSumType
getType()
void
resetInternal()
void
updateChecksum(byte[] input, int startIndex, int length)
Update the checksum with the input data.-
Methods inherited from class com.linkedin.venice.kafka.validation.checksum.CheckSum
getCheckSum, getInstance, getInstance, reset, toString, update, update, update, update
-
-
-
-
Method Detail
-
getFinalCheckSum
public byte[] getFinalCheckSum()
- Specified by:
getFinalCheckSum
in classCheckSum
-
updateChecksum
public void updateChecksum(byte[] input, int startIndex, int length)
Update the checksum with the input data. Notice that the internal CRC32 object is reset everytime before updating the checksum. This is to ensure that the checksum is always calculated from the beginning of the data and checkpoint-able. This is not thread-safe, but the caller should ensure that the object is not shared.- Specified by:
updateChecksum
in classCheckSum
-
resetInternal
public void resetInternal()
- Specified by:
resetInternal
in classCheckSum
-
getType
public CheckSumType getType()
-
getEncodedState
public byte[] getEncodedState()
- Overrides:
getEncodedState
in classCheckSum
-
-