[ 
https://issues.apache.org/jira/browse/HDDS-8059?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17723752#comment-17723752
 ] 

Hemant Kumar commented on HDDS-8059:
------------------------------------

It is a great idea if we can simply wrap *LinkedHashMap* to implement iterator 
since *LinkedHashMap* is used to maintain [snapshotChainGlobal and 
snapshotChainPath|https://github.com/apache/ozone/blob/master/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/SnapshotChainManager.java#L47].
 But I doubt it is that simple and *LinkedHashMap* can be reused for the 
iterator. We have to create a copy/clone of *LinkedHashMap* every time 
*iterator()* is called as per my understanding of *LinkedHashMap*. And 
consistency would be another problem if we go with iterator approach.


In my opinion, if we want to simplify it, we should create *SnapshotChain* 
instead of `SnapshotChainIterator`. *SnapshotChain* could simple wrapped over 
*LinkedHashMap* and can provide helper function like *contains()*, 
*hasPreviousSnapshotAttached()*, *hasNextSnapshotAttached* (something along the 
lines).

Or create custom LinkedHashMap which exposes the iterator we want.

> [Snapshot] Implement SnapshotChainIterator
> ------------------------------------------
>
>                 Key: HDDS-8059
>                 URL: https://issues.apache.org/jira/browse/HDDS-8059
>             Project: Apache Ozone
>          Issue Type: Sub-task
>            Reporter: Siyao Meng
>            Priority: Major
>
> Context: https://github.com/apache/ozone/pull/4244#discussion_r1112993449



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

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

Reply via email to