本文整理汇总了Java中java.util.zip.Checksum.reset方法的典型用法代码示例。如果您正苦于以下问题:Java Checksum.reset方法的具体用法?Java Checksum.reset怎么用?Java Checksum.reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.zip.Checksum
的用法示例。
在下文中一共展示了Checksum.reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createIndexFile
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void createIndexFile(File indexFile, Configuration conf)
throws IOException {
if (indexFile.exists()) {
System.out.println("Deleting existing file");
indexFile.delete();
}
indexFile.createNewFile();
FSDataOutputStream output = FileSystem.getLocal(conf).getRaw().append(
new Path(indexFile.getAbsolutePath()));
Checksum crc = new PureJavaCrc32();
crc.reset();
CheckedOutputStream chk = new CheckedOutputStream(output, crc);
String msg = "Writing new index file. This file will be used only " +
"for the testing.";
chk.write(Arrays.copyOf(msg.getBytes(),
MapTask.MAP_OUTPUT_INDEX_RECORD_LENGTH));
output.writeLong(chk.getChecksum().getValue());
output.close();
}
示例2: SpillRecord
import java.util.zip.Checksum; //导入方法依赖的package包/类
public SpillRecord(Path indexFileName, JobConf job, Checksum crc,
String expectedIndexOwner)
throws IOException {
final FileSystem rfs = FileSystem.getLocal(job).getRaw();
final FSDataInputStream in =
SecureIOUtils.openFSDataInputStream(new File(indexFileName.toUri()
.getRawPath()), expectedIndexOwner, null);
try {
final long length = rfs.getFileStatus(indexFileName).getLen();
final int partitions = (int) length / MAP_OUTPUT_INDEX_RECORD_LENGTH;
final int size = partitions * MAP_OUTPUT_INDEX_RECORD_LENGTH;
buf = ByteBuffer.allocate(size);
if (crc != null) {
crc.reset();
CheckedInputStream chk = new CheckedInputStream(in, crc);
IOUtils.readFully(chk, buf.array(), 0, size);
if (chk.getChecksum().getValue() != in.readLong()) {
throw new ChecksumException("Checksum error reading spill index: " +
indexFileName, -1);
}
} else {
IOUtils.readFully(in, buf.array(), 0, size);
}
entries = buf.asLongBuffer();
} finally {
in.close();
}
}
示例3: outputRecords
import java.util.zip.Checksum; //导入方法依赖的package包/类
public static void outputRecords(OutputStream out,
boolean useAscii,
Unsigned16 firstRecordNumber,
Unsigned16 recordsToGenerate,
Unsigned16 checksum
) throws IOException {
byte[] row = new byte[100];
Unsigned16 recordNumber = new Unsigned16(firstRecordNumber);
Unsigned16 lastRecordNumber = new Unsigned16(firstRecordNumber);
Checksum crc = new PureJavaCrc32();
Unsigned16 tmp = new Unsigned16();
lastRecordNumber.add(recordsToGenerate);
Unsigned16 ONE = new Unsigned16(1);
Unsigned16 rand = Random16.skipAhead(firstRecordNumber);
while (!recordNumber.equals(lastRecordNumber)) {
Random16.nextRand(rand);
if (useAscii) {
generateAsciiRecord(row, rand, recordNumber);
} else {
generateRecord(row, rand, recordNumber);
}
if (checksum != null) {
crc.reset();
crc.update(row, 0, row.length);
tmp.set(crc.getValue());
checksum.add(tmp);
}
recordNumber.add(ONE);
out.write(row);
}
}
示例4: testBytes
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testBytes(Checksum checksum, long expected) {
checksum.reset();
for (byte bits : BYTES_123456789) {
checksum.update(bits);
}
checkChecksum(checksum, expected);
}
示例5: testDirectByteBuffer
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testDirectByteBuffer(Checksum checksum, long expected) {
checksum.reset();
ByteBuffer bb = ByteBuffer.allocateDirect(BYTES_123456789.length);
bb.put(BYTES_123456789);
bb.rewind();
checksum.update(bb);
checkChecksum(checksum, expected);
}
示例6: testByteArrayOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testByteArrayOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
checksum.update(unaligned_bytes_123456789, i, BYTES_123456789.length);
checkChecksumOffset(checksum, expected, i);
}
}
示例7: testDirectByteBufferOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testDirectByteBufferOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
ByteBuffer bb = ByteBuffer.allocateDirect(unaligned_bytes_123456789.length);
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
bb.put(unaligned_bytes_123456789);
bb.position(i);
bb.limit(i + BYTES_123456789.length);
checksum.update(bb);
checkChecksumOffset(checksum, expected, i);
}
}
示例8: testLittleEndianDirectByteBufferOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testLittleEndianDirectByteBufferOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
ByteBuffer bb = ByteBuffer.allocateDirect(unaligned_bytes_123456789.length);
bb.order(ByteOrder.LITTLE_ENDIAN);
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
bb.put(unaligned_bytes_123456789);
bb.position(i);
bb.limit(i + BYTES_123456789.length);
checksum.update(bb);
checkChecksumOffset(checksum, expected, i);
}
}
示例9: testWrappedByteBufferOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testWrappedByteBufferOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789);
bb.position(i);
bb.limit(i + BYTES_123456789.length);
checksum.update(bb);
checkChecksumOffset(checksum, expected, i);
}
}
示例10: testLittleEndianWrappedByteBufferOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testLittleEndianWrappedByteBufferOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789);
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.position(i);
bb.limit(i + BYTES_123456789.length);
checksum.update(bb);
checkChecksumOffset(checksum, expected, i);
}
}
示例11: testReadonlyByteBufferOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testReadonlyByteBufferOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789).asReadOnlyBuffer();
bb.position(i);
bb.limit(i + BYTES_123456789.length);
checksum.update(bb);
checkChecksumOffset(checksum, expected, i);
}
}
示例12: testLittleEndianReadonlyByteBufferOffset
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testLittleEndianReadonlyByteBufferOffset(Checksum checksum, long expected) {
byte[] unaligned_bytes_123456789 = new byte[BYTES_123456789.length + 64];
for (int i = 0; i < unaligned_bytes_123456789.length - BYTES_123456789.length; i++) {
checksum.reset();
System.arraycopy(BYTES_123456789, 0, unaligned_bytes_123456789, i, BYTES_123456789.length);
ByteBuffer bb = ByteBuffer.wrap(unaligned_bytes_123456789).asReadOnlyBuffer();
bb.order(ByteOrder.LITTLE_ENDIAN);
bb.position(i);
bb.limit(i + BYTES_123456789.length);
checksum.update(bb);
checkChecksumOffset(checksum, expected, i);
}
}
示例13: testByteArray
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testByteArray(Checksum checksum, long expected) {
checksum.reset();
checksum.update(BYTES_123456789);
checkChecksum(checksum, expected);
}
示例14: testWrappedByteBuffer
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testWrappedByteBuffer(Checksum checksum, long expected) {
checksum.reset();
ByteBuffer bb = ByteBuffer.wrap(BYTES_123456789);
checksum.update(bb);
checkChecksum(checksum, expected);
}
示例15: testReadonlyByteBuffer
import java.util.zip.Checksum; //导入方法依赖的package包/类
private static void testReadonlyByteBuffer(Checksum checksum, long expected) {
checksum.reset();
ByteBuffer bb = ByteBuffer.wrap(BYTES_123456789).asReadOnlyBuffer();
checksum.update(bb);
checkChecksum(checksum, expected);
}