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.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 theorg.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 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 int
getIntValue()
int
getMaskedValue()
long
getValue()
static int
mask(int crc)
Return a masked representation of crc.static int
maskedCrc32c(byte[] data)
static int
maskedCrc32c(byte[] data, int offset, int length)
void
reset()
static int
unmask(int maskedCrc)
Return the crc whose masked representation is masked_crc.void
update(byte[] b)
void
update(byte[] b, int off, int len)
void
update(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:
getValue
in interfacejava.util.zip.Checksum
-
reset
public void reset()
- Specified by:
reset
in interfacejava.util.zip.Checksum
-
update
public void update(byte[] b)
- Specified by:
update
in interfacejava.util.zip.Checksum
-
update
public void update(byte[] b, int off, int len)
- Specified by:
update
in interfacejava.util.zip.Checksum
-
update
public void update(int b)
- Specified by:
update
in interfacejava.util.zip.Checksum
-
-