Class CheckSum
- java.lang.Object
-
- com.linkedin.venice.kafka.validation.checksum.CheckSum
-
- Direct Known Subclasses:
AdHash
,Adler32CheckSum
,CRC32CheckSum
,MD5CheckSum
public abstract class CheckSum extends java.lang.Object
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. WhengetCheckSum()
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 Constructor Description CheckSum()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description byte[]
getCheckSum()
Get the checkSum of the buffer till now.byte[]
getEncodedState()
protected abstract byte[]
getFinalCheckSum()
static CheckSum
getInstance(CheckSumType type)
static CheckSum
getInstance(CheckSumType type, byte[] encodedState)
abstract CheckSumType
getType()
void
reset()
Reset the checksum generatorabstract void
resetInternal()
java.lang.String
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)
-
-
-
Method Detail
-
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
public abstract CheckSumType 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
public static CheckSum getInstance(CheckSumType type)
-
getInstance
public static CheckSum getInstance(CheckSumType type, byte[] encodedState)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-