Package com.linkedin.alpini.base.hash
Class Crc32C
java.lang.Object
com.linkedin.alpini.base.hash.Crc32C
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
int
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)
-
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() -
reset
public void reset() -
update
public void update(byte[] b) -
update
public void update(byte[] b, int off, int len) -
update
public void update(int b)
-