diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DataChecksum.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DataChecksum.java index 78624047d9f..1681c92eef1 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DataChecksum.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/DataChecksum.java @@ -288,12 +288,20 @@ public class DataChecksum implements Checksum { public void verifyChunkedSums(ByteBuffer data, ByteBuffer checksums, String fileName, long basePos) throws ChecksumException { if (type.size == 0) return; - + if (data.hasArray() && checksums.hasArray()) { final int dataOffset = data.arrayOffset() + data.position(); final int crcsOffset = checksums.arrayOffset() + checksums.position(); - verifyChunked(type, summer, data.array(), dataOffset, data.remaining(), - bytesPerChecksum, checksums.array(), crcsOffset, fileName, basePos); + + if (NativeCrc32.isAvailable()) { + NativeCrc32.verifyChunkedSumsByteArray(bytesPerChecksum, type.id, + checksums.array(), crcsOffset, data.array(), dataOffset, + data.remaining(), fileName, basePos); + } else { + verifyChunked(type, summer, data.array(), dataOffset, data.remaining(), + bytesPerChecksum, checksums.array(), crcsOffset, fileName, + basePos); + } return; } if (NativeCrc32.isAvailable()) {