java.util.zip.Checksum@LimitedPrivate({"HDFS","MapReduce"})
@Evolving
public class DataChecksum
extends java.lang.Object
implements java.util.zip.Checksum
| Modifier and Type | Class | Description |
|---|---|---|
static class |
DataChecksum.Type |
The checksum types
|
| Modifier and Type | Field | Description |
|---|---|---|
static int |
CHECKSUM_CRC32 |
|
static int |
CHECKSUM_CRC32C |
|
static int |
CHECKSUM_DEFAULT |
|
static int |
CHECKSUM_MIXED |
|
static int |
CHECKSUM_NULL |
|
static int |
SIZE_OF_INTEGER |
| Modifier and Type | Method | Description |
|---|---|---|
void |
calculateChunkedSums(byte[] data,
int dataOffset,
int dataLength,
byte[] sums,
int sumsOffset) |
Implementation of chunked calculation specifically on byte arrays.
|
void |
calculateChunkedSums(java.nio.ByteBuffer data,
java.nio.ByteBuffer checksums) |
Calculate checksums for the given data.
|
boolean |
compare(byte[] buf,
int offset) |
Compares the checksum located at buf[offset] with the current checksum.
|
boolean |
equals(java.lang.Object other) |
|
int |
getBytesPerChecksum() |
|
static int |
getChecksumHeaderSize() |
|
int |
getChecksumSize() |
the size for a checksum.
|
int |
getChecksumSize(int dataSize) |
the required checksum size given the data length.
|
DataChecksum.Type |
getChecksumType() |
|
static int |
getCrcPolynomialForType(DataChecksum.Type type) |
getCrcPolynomialForType.
|
byte[] |
getHeader() |
|
int |
getNumBytesInSum() |
|
long |
getValue() |
|
int |
hashCode() |
|
static java.util.zip.Checksum |
newCrc32() |
Create a Crc32 Checksum object.
|
static DataChecksum |
newDataChecksum(byte[] bytes,
int offset) |
Creates a DataChecksum from HEADER_LEN bytes from arr[offset].
|
static DataChecksum |
newDataChecksum(java.io.DataInputStream in) |
This constructs a DataChecksum by reading HEADER_LEN bytes from input
stream in.
|
static DataChecksum |
newDataChecksum(DataChecksum.Type type,
int bytesPerChecksum) |
|
void |
reset() |
|
java.lang.String |
toString() |
|
void |
update(byte[] b,
int off,
int len) |
|
void |
update(int b) |
|
void |
verifyChunkedSums(java.nio.ByteBuffer data,
java.nio.ByteBuffer checksums,
java.lang.String fileName,
long basePos) |
Verify that the given checksums match the given data.
|
void |
writeHeader(java.io.DataOutputStream out) |
Writes the checksum header to the output stream out.
|
int |
writeValue(byte[] buf,
int offset,
boolean reset) |
Writes the current checksum to a buffer.
|
int |
writeValue(java.io.DataOutputStream out,
boolean reset) |
Writes the current checksum to the stream.
|
public static final int CHECKSUM_NULL
public static final int CHECKSUM_CRC32
public static final int CHECKSUM_CRC32C
public static final int CHECKSUM_DEFAULT
public static final int CHECKSUM_MIXED
public static final int SIZE_OF_INTEGER
public static java.util.zip.Checksum newCrc32()
public static int getCrcPolynomialForType(DataChecksum.Type type) throws java.io.IOException
type - type.type, suitable for use with further CRC arithmetic.java.io.IOException - if there is no CRC polynomial applicable
to the given type.public static DataChecksum newDataChecksum(DataChecksum.Type type, int bytesPerChecksum)
public static DataChecksum newDataChecksum(byte[] bytes, int offset) throws java.io.IOException
bytes - bytes.offset - offset.java.io.IOException - raised on errors performing I/O.public static DataChecksum newDataChecksum(java.io.DataInputStream in) throws java.io.IOException
in - data input stream.java.io.IOException - raised on errors performing I/O.public void writeHeader(java.io.DataOutputStream out)
throws java.io.IOException
out - output stream.java.io.IOException - raised on errors performing I/O.public byte[] getHeader()
public int writeValue(java.io.DataOutputStream out,
boolean reset)
throws java.io.IOException
out - out.reset - reset.java.io.IOException - raised on errors performing I/O.public int writeValue(byte[] buf,
int offset,
boolean reset)
throws java.io.IOException
buf - buf.offset - offset.reset - reset.java.io.IOException - raised on errors performing I/O.public boolean compare(byte[] buf,
int offset)
buf - buf.offset - offset.public DataChecksum.Type getChecksumType()
public int getChecksumSize()
public int getChecksumSize(int dataSize)
dataSize - data size.public int getBytesPerChecksum()
public int getNumBytesInSum()
public static int getChecksumHeaderSize()
public long getValue()
getValue in interface java.util.zip.Checksumpublic void reset()
reset in interface java.util.zip.Checksumpublic void update(byte[] b,
int off,
int len)
update in interface java.util.zip.Checksumpublic void update(int b)
update in interface java.util.zip.Checksumpublic void verifyChunkedSums(java.nio.ByteBuffer data,
java.nio.ByteBuffer checksums,
java.lang.String fileName,
long basePos)
throws ChecksumException
data - the DirectByteBuffer pointing to the data to verify.checksums - the DirectByteBuffer pointing to a series of stored
checksumsfileName - the name of the file being read, for error-reportingbasePos - the file position to which the start of 'data' correspondsChecksumException - if the checksums do not matchpublic void calculateChunkedSums(java.nio.ByteBuffer data,
java.nio.ByteBuffer checksums)
data - the DirectByteBuffer pointing to the data to checksum.checksums - the DirectByteBuffer into which checksums will be
stored. Enough space must be available in this
buffer to put the checksums.public void calculateChunkedSums(byte[] data,
int dataOffset,
int dataLength,
byte[] sums,
int sumsOffset)
data - data.dataOffset - dataOffset.dataLength - dataLength.sums - sums.sumsOffset - sumsOffset.public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2008–2025 Apache Software Foundation. All rights reserved.