From 7a96033b15580a01a2867fa3cab9c1e409dbaafd Mon Sep 17 00:00:00 2001 From: Kai Zheng Date: Fri, 1 Sep 2017 17:48:26 +0800 Subject: [PATCH] HDFS-11964. Decoding inputs should be correctly prepared in pread. Contributed by Takanobu Asanuma --- .../java/org/apache/hadoop/hdfs/PositionStripeReader.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); }