You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by he...@apache.org on 2020/11/06 06:59:40 UTC
[hadoop] branch branch-3.2.2 updated: HDFS-15643. EC: Fix checksum
computation in case of native encoders. (#2424). Contributed by Ayush
Saxena.
This is an automated email from the ASF dual-hosted git repository.
hexiaoqiao pushed a commit to branch branch-3.2.2
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/branch-3.2.2 by this push:
new 6bee816 HDFS-15643. EC: Fix checksum computation in case of native encoders. (#2424). Contributed by Ayush Saxena.
6bee816 is described below
commit 6bee816740e3060a072772057f7a4715ec770d75
Author: Ayush Saxena <ay...@apache.org>
AuthorDate: Wed Nov 4 09:28:44 2020 +0530
HDFS-15643. EC: Fix checksum computation in case of native encoders. (#2424). Contributed by Ayush Saxena.
---
.../StripedBlockChecksumReconstructor.java | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockChecksumReconstructor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockChecksumReconstructor.java
index b2e6496..d9e2f60 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockChecksumReconstructor.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/erasurecode/StripedBlockChecksumReconstructor.java
@@ -87,7 +87,7 @@ public abstract class StripedBlockChecksumReconstructor
// step3: calculate checksum
checksumDataLen += checksumWithTargetOutput(
- targetBuffer.array(), toReconstructLen);
+ getBufferArray(targetBuffer), toReconstructLen);
updatePositionInBlock(toReconstructLen);
requestedLen -= toReconstructLen;
@@ -140,7 +140,7 @@ public abstract class StripedBlockChecksumReconstructor
// case-2) length of data bytes which is less than bytesPerCRC
if (requestedLen <= toReconstructLen) {
int remainingLen = Math.toIntExact(requestedLen);
- outputData = Arrays.copyOf(targetBuffer.array(), remainingLen);
+ outputData = Arrays.copyOf(outputData, remainingLen);
int partialLength = remainingLen % getChecksum().getBytesPerChecksum();
@@ -207,4 +207,19 @@ public abstract class StripedBlockChecksumReconstructor
public long getChecksumDataLen() {
return checksumDataLen;
}
-}
+
+ /**
+ * Gets an array corresponding the buffer.
+ * @param buffer the input buffer.
+ * @return the array with content of the buffer.
+ */
+ private static byte[] getBufferArray(ByteBuffer buffer) {
+ byte[] buff = new byte[buffer.remaining()];
+ if (buffer.hasArray()) {
+ buff = buffer.array();
+ } else {
+ buffer.slice().get(buff);
+ }
+ return buff;
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org