chungen0126 commented on code in PR #7074:
URL: https://github.com/apache/ozone/pull/7074#discussion_r1718837280


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/impl/BlockManagerImpl.java:
##########
@@ -343,7 +343,7 @@ public List<BlockData> listBlock(Container container, long 
startLocalID, int
                 .getSequentialRangeKVs(startKey, count,
                     cData.containerPrefix(), cData.getUnprefixedKeyFilter());
         for (Table.KeyValue<String, BlockData> entry : range) {
-          result.add(entry.getValue());
+          result.add(db.getStore().getBlockByID(null, entry.getKey()));

Review Comment:
   Can we put the merge of last chunk into another function? For example:
   ```
     @Override
     public BlockData getBlockByID(BlockID blockID,
         String blockKey) throws IOException {
       // check block data table
       BlockData blockData = getBlockDataTable().get(blockKey);
       return getCompleteBlockData(blockData, blockID, blockKey);
     }
   
     @Override
     public BlockData getCompleteBlockData(
         BlockData blockData, BlockID blockID, String blockKey) throws 
IOException {
       BlockData lastChunk = null;
       if (blockData == null || isPartialChunkList(blockData)) {
         // check last chunk table
         lastChunk = getLastChunkInfoTable().get(blockKey);
       }
   
       if (blockData == null || blockData.getChunks().isEmpty()) {
         if (lastChunk == null) {
           throw new StorageContainerException(
               NO_SUCH_BLOCK_ERR_MSG + " BlockID : " + blockID, NO_SUCH_BLOCK);
         } else {
           if (LOG.isDebugEnabled()) {
             LOG.debug("blockData=(null), lastChunk={}", lastChunk.getChunks());
           }
           return lastChunk;
         }
       } else {
         if (lastChunk != null) {
           reconcilePartialChunks(lastChunk, blockData);
         } else {
           if (LOG.isDebugEnabled()) {
             LOG.debug("blockData={}, lastChunk=(null)", blockData.getChunks());
           }
         }
       }
   
       return blockData;
     }
   ```
   Then, we can use it here:
   ```
   for (Table.KeyValue<String, BlockData> entry : range) {
             result.add(db.getStore().getCompleteBlockData(entry.getValue(), 
null, entry.getKey()));
           }
           return result;
   ```
   
   I think it is a simple change to avoid getting blockData from table twice. 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to