diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PositionStripeReader.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PositionStripeReader.java index 1e9d638295f..b01b74cfa77 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PositionStripeReader.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/PositionStripeReader.java @@ -57,6 +57,10 @@ class PositionStripeReader extends StripeReader { Preconditions.checkState(index >= dataBlkNum && alignedStripe.chunks[index] == null); + int bufLen = (int) alignedStripe.getSpanInBlock(); + decodeInputs[index] = new ECChunk(codingBuffer.duplicate(), index * bufLen, + bufLen); + alignedStripe.chunks[index] = new StripingChunk(decodeInputs[index].getBuffer()); @@ -75,7 +79,7 @@ class PositionStripeReader extends StripeReader { codingBuffer = dfsStripedInputStream.getBufferPool(). getBuffer(useDirectBuffer(), bufLen * bufCount); ByteBuffer buffer; - for (int i = 0; i < decodeInputs.length; i++) { + for (int i = 0; i < dataBlkNum; i++) { buffer = codingBuffer.duplicate(); decodeInputs[i] = new ECChunk(buffer, i * bufLen, bufLen); }