Package com.linkedin.alpini.base.hash
Class Crc32C
- java.lang.Object
-
- com.linkedin.alpini.base.hash.Crc32C
-
- All Implemented Interfaces:
java.util.zip.Checksum
public final class Crc32C extends java.lang.Object implements java.util.zip.ChecksumA 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 theorg.iq80.snappy.Crc32Cimplementation 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 Summary
Constructors Constructor Description Crc32C()Create a new PureJavaCrc32 object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetIntValue()intgetMaskedValue()longgetValue()static intmask(int crc)Return a masked representation of crc.static intmaskedCrc32c(byte[] data)static intmaskedCrc32c(byte[] data, int offset, int length)voidreset()static intunmask(int maskedCrc)Return the crc whose masked representation is masked_crc.voidupdate(byte[] b)voidupdate(byte[] b, int off, int len)voidupdate(int b)
-
-
-
Method Detail
-
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:
getValuein interfacejava.util.zip.Checksum
-
reset
public void reset()
- Specified by:
resetin interfacejava.util.zip.Checksum
-
update
public void update(byte[] b)
- Specified by:
updatein interfacejava.util.zip.Checksum
-
update
public void update(byte[] b, int off, int len)- Specified by:
updatein interfacejava.util.zip.Checksum
-
update
public void update(int b)
- Specified by:
updatein interfacejava.util.zip.Checksum
-
-