errose28 commented on code in PR #7065:
URL: https://github.com/apache/ozone/pull/7065#discussion_r1717279316


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/KeyValueHandler.java:
##########
@@ -527,6 +529,25 @@ ContainerCommandResponseProto handleCloseContainer(
     return getSuccessResponse(request);
   }
 
+  private void createContainerMerkleTree(KeyValueContainer kvContainer) throws 
IOException {
+    KeyValueContainerData containerData = kvContainer.getContainerData();
+    ContainerMerkleTree merkleTree = new ContainerMerkleTree();
+    try (DBHandle dbHandle = BlockUtils.getDB(containerData, conf);
+         BlockIterator<BlockData> blockIterator = dbHandle.getStore().
+             getBlockIterator(containerData.getContainerID())) {
+      while (blockIterator.hasNext()) {
+        BlockData blockData = blockIterator.nextBlock();
+        List<ContainerProtos.ChunkInfo> chunks = blockData.getChunks();
+        List<ChunkInfo> chunkInfos = new ArrayList<>();
+        for (ContainerProtos.ChunkInfo chunk: chunks) {
+          chunkInfos.add(ChunkInfo.getFromProtoBuf(chunk));
+        }
+        merkleTree.addChunks(blockData.getLocalID(), chunkInfos);

Review Comment:
   We should probably make `ContainerMerkleTree` use 
`ContainerProtos.ChunkInfo` instead of just `ChunkInfo`. Otherwise there is 
unnecessary conversion when generating the tree. The original idea was that you 
could just append chunks as you read them without conversion but I think we 
need to make this change in `ContainerMerkleTree` for it to work in practice.



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