Class Crc32C

java.lang.Object
com.linkedin.alpini.base.hash.Crc32C
All Implemented Interfaces:
Checksum

public final class Crc32C extends Object implements Checksum
A pure-java implementation of the CRC32 checksum that uses the CRC32-C polynomial, the same polynomial used by iSCSI and implemented on many Intel chipsets supporting SSE4.2. This class implementation is copied from the org.iq80.snappy.Crc32C implementation because it was stupidly made package private for no good reason. Note that Java9 will provide its own implementation of CRC32-C which may have scope for native acceleration.
  • Constructor Details

    • Crc32C

      public Crc32C()
      Create a new PureJavaCrc32 object.
  • Method Details

    • maskedCrc32c

      public static int maskedCrc32c(byte[] data)
    • maskedCrc32c

      public static int maskedCrc32c(byte[] data, int offset, int length)
    • mask

      public static int mask(int crc)
      Return a masked representation of crc.

      Motivation: it is problematic to compute the CRC of a string that contains embedded CRCs. Therefore we recommend that CRCs stored somewhere (e.g., in files) should be masked before being stored.

    • unmask

      public static int unmask(int maskedCrc)
      Return the crc whose masked representation is masked_crc.
    • getMaskedValue

      public int getMaskedValue()
    • getIntValue

      public int getIntValue()
    • getValue

      public long getValue()
      Specified by:
      getValue in interface Checksum
    • reset

      public void reset()
      Specified by:
      reset in interface Checksum
    • update

      public void update(byte[] b)
      Specified by:
      update in interface Checksum
    • update

      public void update(byte[] b, int off, int len)
      Specified by:
      update in interface Checksum
    • update

      public void update(int b)
      Specified by:
      update in interface Checksum