You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/06/17 03:40:26 UTC

[GitHub] [hadoop-ozone] ChenSammi commented on a change in pull request #1079: HDDS-3802. Incorrect data returned by reading a FILE_PER_CHUNK block.

ChenSammi commented on a change in pull request #1079:
URL: https://github.com/apache/hadoop-ozone/pull/1079#discussion_r441262440



##########
File path: hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/FilePerChunkStrategy.java
##########
@@ -218,17 +244,36 @@ public ChunkBuffer readChunk(Container container, BlockID blockID,
     long len = info.getLen();
     ByteBuffer data = ByteBuffer.allocate((int) len);
 
+    int index = extractChunkIndex(info.getChunkName());
+    if (index == -1) {
+      throw new StorageContainerException(
+          "Chunk file name can't be parsed " + possibleFiles.toString(),
+          UNABLE_TO_FIND_CHUNK);
+    }
+    // Chunk index start from 1
+    Preconditions.checkState(index > 0);
+
+    long chunkFileOffset;
+    try {
+      BlockData blockData = blockManager.getBlock(kvContainer, blockID);
+      List<ContainerProtos.ChunkInfo> chunks = blockData.getChunks();
+      Preconditions.checkState(index <= chunks.size());
+      chunkFileOffset = chunks.get(index - 1).getOffset();

Review comment:
       A good point. I think the performance overhead can be ignored. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org