/** * Returns the number of bytes needed to store the checksums for * a specified data size * @param datasize number of bytes of data * @param bytesPerChecksum number of bytes in a checksum chunk * @return The number of bytes needed to store the checksum values */ static long numBytes(long datasize, int bytesPerChecksum) { return numChunks(datasize, bytesPerChecksum) * HFileBlock.CHECKSUM_SIZE; }
/** * Write dummy checksums to the end of the specified bytes array * to reserve space for writing checksums later * @param baos OutputStream to write dummy checkum values * @param numBytes Number of bytes of data for which dummy checksums * need to be generated * @param bytesPerChecksum Number of bytes per checksum value */ static void reserveSpaceForChecksums(ByteArrayOutputStream baos, int numBytes, int bytesPerChecksum) throws IOException { long numChunks = numChunks(numBytes, bytesPerChecksum); long bytesLeft = numChunks * HFileBlock.CHECKSUM_SIZE; while (bytesLeft > 0) { long count = Math.min(bytesLeft, DUMMY_VALUE.length); baos.write(DUMMY_VALUE, 0, (int)count); bytesLeft -= count; } }
os.close(); long expectedChunks = ChecksumUtil.numChunks( dataSize + HConstants.HFILEBLOCK_HEADER_SIZE, bytesPerChecksum);
/** * Returns the number of bytes needed to store the checksums for * a specified data size * @param datasize number of bytes of data * @param bytesPerChecksum number of bytes in a checksum chunk * @return The number of bytes needed to store the checksum values */ static long numBytes(long datasize, int bytesPerChecksum) { return numChunks(datasize, bytesPerChecksum) * HFileBlock.CHECKSUM_SIZE; }
/** * Returns the number of bytes needed to store the checksums for * a specified data size * @param datasize number of bytes of data * @param bytesPerChecksum number of bytes in a checksum chunk * @return The number of bytes needed to store the checksum values */ static long numBytes(long datasize, int bytesPerChecksum) { return numChunks(datasize, bytesPerChecksum) * HFileBlock.CHECKSUM_SIZE; }
/** * Write dummy checksums to the end of the specified bytes array * to reserve space for writing checksums later * @param baos OutputStream to write dummy checkum values * @param numBytes Number of bytes of data for which dummy checksums * need to be generated * @param bytesPerChecksum Number of bytes per checksum value */ static void reserveSpaceForChecksums(ByteArrayOutputStream baos, int numBytes, int bytesPerChecksum) throws IOException { long numChunks = numChunks(numBytes, bytesPerChecksum); long bytesLeft = numChunks * HFileBlock.CHECKSUM_SIZE; while (bytesLeft > 0) { long count = Math.min(bytesLeft, DUMMY_VALUE.length); baos.write(DUMMY_VALUE, 0, (int)count); bytesLeft -= count; } }
/** * Write dummy checksums to the end of the specified bytes array * to reserve space for writing checksums later * @param baos OutputStream to write dummy checkum values * @param numBytes Number of bytes of data for which dummy checksums * need to be generated * @param bytesPerChecksum Number of bytes per checksum value */ static void reserveSpaceForChecksums(ByteArrayOutputStream baos, int numBytes, int bytesPerChecksum) throws IOException { long numChunks = numChunks(numBytes, bytesPerChecksum); long bytesLeft = numChunks * HFileBlock.CHECKSUM_SIZE; while (bytesLeft > 0) { long count = Math.min(bytesLeft, DUMMY_VALUE.length); baos.write(DUMMY_VALUE, 0, (int)count); bytesLeft -= count; } }
os.close(); long expectedChunks = ChecksumUtil.numChunks( dataSize + HConstants.HFILEBLOCK_HEADER_SIZE, bytesPerChecksum);