@InterfaceAudience.LimitedPrivate(value={"HDFS","MapReduce"}) @InterfaceStability.Evolving public class DataChecksum extends Object implements Checksum
Modifier and Type | Class and Description |
---|---|
static class |
DataChecksum.Type
The checksum types
|
Modifier and Type | Field and Description |
---|---|
static int |
CHECKSUM_CRC32 |
static int |
CHECKSUM_CRC32C |
static int |
CHECKSUM_DEFAULT |
static int |
CHECKSUM_MIXED |
static int |
CHECKSUM_NULL |
static int |
HEADER_LEN |
static int |
SIZE_OF_INTEGER |
Modifier and Type | Method and Description |
---|---|
void |
calculateChunkedSums(ByteBuffer data,
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(Object other) |
int |
getBytesPerChecksum() |
static int |
getChecksumHeaderSize() |
int |
getChecksumSize() |
DataChecksum.Type |
getChecksumType() |
byte[] |
getHeader() |
int |
getNumBytesInSum() |
long |
getValue() |
int |
hashCode() |
static DataChecksum |
newDataChecksum(byte[] bytes,
int offset)
Creates a DataChecksum from HEADER_LEN bytes from arr[offset].
|
static DataChecksum |
newDataChecksum(DataChecksum.Type type,
int bytesPerChecksum) |
static DataChecksum |
newDataChecksum(DataInputStream in)
This constructucts a DataChecksum by reading HEADER_LEN bytes from
input stream in
|
void |
reset() |
String |
toString() |
void |
update(byte[] b,
int off,
int len) |
void |
update(int b) |
void |
verifyChunkedSums(ByteBuffer data,
ByteBuffer checksums,
String fileName,
long basePos)
Verify that the given checksums match the given data.
|
void |
writeHeader(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(DataOutputStream out,
boolean reset)
Writes the current checksum to the stream.
|
public static final int HEADER_LEN
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 DataChecksum newDataChecksum(DataChecksum.Type type, int bytesPerChecksum)
public static DataChecksum newDataChecksum(byte[] bytes, int offset)
public static DataChecksum newDataChecksum(DataInputStream in) throws IOException
IOException
public void writeHeader(DataOutputStream out) throws IOException
IOException
public byte[] getHeader()
public int writeValue(DataOutputStream out, boolean reset) throws IOException
IOException
public int writeValue(byte[] buf, int offset, boolean reset) throws IOException
IOException
public boolean compare(byte[] buf, int offset)
public DataChecksum.Type getChecksumType()
public int getChecksumSize()
public int getBytesPerChecksum()
public int getNumBytesInSum()
public static int getChecksumHeaderSize()
public void verifyChunkedSums(ByteBuffer data, ByteBuffer checksums, 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(ByteBuffer data, 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.Copyright © 2013 Apache Software Foundation. All rights reserved.