public void Reset() { bytesRead = 0; if (_checkedStream != null) { _checkedStream.GetChecksum().Reset(); } }
/// <exception cref="System.IO.IOException"/> public SpillRecord(Path indexFileName, JobConf job, Checksum crc, string expectedIndexOwner ) { FileSystem rfs = FileSystem.GetLocal(job).GetRaw(); FSDataInputStream @in = SecureIOUtils.OpenFSDataInputStream(new FilePath(indexFileName .ToUri().GetRawPath()), expectedIndexOwner, null); try { long length = rfs.GetFileStatus(indexFileName).GetLen(); int partitions = (int)length / MapTask.MapOutputIndexRecordLength; int size = partitions * MapTask.MapOutputIndexRecordLength; buf = ByteBuffer.Allocate(size); if (crc != null) { crc.Reset(); CheckedInputStream chk = new CheckedInputStream(@in, crc); IOUtils.ReadFully(chk, ((byte[])buf.Array()), 0, size); if (chk.GetChecksum().GetValue() != @in.ReadLong()) { throw new ChecksumException("Checksum error reading spill index: " + indexFileName , -1); } } else { IOUtils.ReadFully(@in, ((byte[])buf.Array()), 0, size); } entries = buf.AsLongBuffer(); } finally { @in.Close(); } }