@LimitedPrivate({"Common","HDFS","MapReduce","Yarn"})
@Unstable
public final class CrcUtil
extends java.lang.Object
| Modifier and Type | Field | Description |
|---|---|---|
static int |
CASTAGNOLI_POLYNOMIAL |
|
static int |
GZIP_POLYNOMIAL |
|
static int |
MULTIPLICATIVE_IDENTITY |
| Modifier and Type | Method | Description |
|---|---|---|
static int |
compose(int crcA,
int crcB,
long lengthB,
int mod) |
compose.
|
static int |
composeWithMonomial(int crcA,
int crcB,
int monomial,
int mod) |
composeWithMonomial.
|
static int |
getMonomial(long lengthBytes,
int mod) |
Compute x^(
lengthBytes * 8) mod mod, where mod is
in "reversed" (little-endian) format such that mod & 1 represents
x^31 and has an implicit term x^32. |
static byte[] |
intToBytes(int value) |
|
static int |
readInt(byte[] buf,
int offset) |
Reads 4-byte big-endian int value from
buf starting at
offset. |
static java.lang.String |
toMultiCrcString(byte[] bytes) |
For use with debug statements; verifies bytes.length on creation,
expecting it to be divisible by CRC byte size, and returns a list of
hex formatted values.
|
static java.lang.String |
toSingleCrcString(byte[] bytes) |
For use with debug statements; verifies bytes.length on creation,
expecting it to represent exactly one CRC, and returns a hex
formatted value.
|
static void |
writeInt(byte[] buf,
int offset,
int value) |
Writes big-endian representation of
value into buf
starting at offset. |
public static final int MULTIPLICATIVE_IDENTITY
public static final int GZIP_POLYNOMIAL
public static final int CASTAGNOLI_POLYNOMIAL
public static int getMonomial(long lengthBytes,
int mod)
lengthBytes * 8) mod mod, where mod is
in "reversed" (little-endian) format such that mod & 1 represents
x^31 and has an implicit term x^32.lengthBytes - lengthBytes.mod - mod.public static int composeWithMonomial(int crcA,
int crcB,
int monomial,
int mod)
crcA - crcA.crcB - crcB.monomial - Precomputed x^(lengthBInBytes * 8) mod modmod - mod.public static int compose(int crcA,
int crcB,
long lengthB,
int mod)
crcA - crcA.crcB - crcB.lengthB - length of content corresponding to crcB, in bytes.mod - mod.public static byte[] intToBytes(int value)
value - value.value.public static void writeInt(byte[] buf,
int offset,
int value)
throws java.io.IOException
value into buf
starting at offset. buf.length must be greater than or
equal to offset + 4.buf - buf size.offset - offset.value - value.java.io.IOException - raised on errors performing I/O.public static int readInt(byte[] buf,
int offset)
throws java.io.IOException
buf starting at
offset. buf.length must be greater than or equal to offset + 4.offset - offset.buf - buf.java.io.IOException - raised on errors performing I/O.public static java.lang.String toSingleCrcString(byte[] bytes)
throws java.io.IOException
bytes - bytes.java.io.IOException - raised on errors performing I/O.public static java.lang.String toMultiCrcString(byte[] bytes)
throws java.io.IOException
bytes - bytes.java.io.IOException - raised on errors performing I/O.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.