Class CheckSum
java.lang.Object
com.linkedin.venice.kafka.validation.checksum.CheckSum
- Direct Known Subclasses:
AdHash
,Adler32CheckSum
,CRC32CheckSum
,MD5CheckSum
Parent class for various running checksum implementations.
CheckSum has 2 modes -- write mode and read mode. Updating check sum
is only available in the write mode. When
getCheckSum()
is
called, the object will flip to the read mode and Checksum value will be
finalized.
reset()
can flip the object back to the write mode and checksum
value will be re-initialized.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
Get the checkSum of the buffer till now.byte[]
protected abstract byte[]
static CheckSum
getInstance
(CheckSumType type) static CheckSum
getInstance
(CheckSumType type, byte[] encodedState) abstract CheckSumType
getType()
void
reset()
Reset the checksum generatorabstract void
toString()
void
update
(byte[] input) Update the checksum buffer to include inputvoid
update
(byte[] input, int startIndex, int length) Update the checksum buffer to include input with startIndex and length.void
update
(int number) Update the underlying buffer using the integervoid
update
(short number) Update the underlying buffer using the shortprotected abstract void
updateChecksum
(byte[] input, int startIndex, int length)
-
Constructor Details
-
CheckSum
public CheckSum()
-
-
Method Details
-
update
public void update(byte[] input, int startIndex, int length) Update the checksum buffer to include input with startIndex and length. Following calls to multiple 'update's you need to call 'getCheckSum' which will reset the buffer as well. -
updateChecksum
protected abstract void updateChecksum(byte[] input, int startIndex, int length) -
getCheckSum
public byte[] getCheckSum()Get the checkSum of the buffer till now. When it called, the object will flip from write mode to read mode -
getFinalCheckSum
protected abstract byte[] getFinalCheckSum() -
reset
public void reset()Reset the checksum generator -
resetInternal
public abstract void resetInternal() -
getType
-
getEncodedState
public byte[] getEncodedState() -
update
public void update(int number) Update the underlying buffer using the integer- Parameters:
number
- number to be stored in checksum buffer
-
update
public void update(short number) Update the underlying buffer using the short- Parameters:
number
- number to be stored in checksum buffer
-
update
public void update(byte[] input) Update the checksum buffer to include input- Parameters:
input
- bytes added to the buffer
-
getInstance
-
getInstance
-
toString
-