java.lang.Object
com.linkedin.venice.kafka.validation.checksum.CheckSum
Direct Known Subclasses:
AdHash, Adler32CheckSum, CRC32CheckSum, MD5CheckSum

public abstract class CheckSum extends 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. 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 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

      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 String toString()
      Overrides:
      toString in class Object