sumitagrawl commented on code in PR #5970:
URL: https://github.com/apache/ozone/pull/5970#discussion_r1454711047


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ListIterator.java:
##########
@@ -236,14 +241,38 @@ private void 
populateCacheMap(Iterator<Map.Entry<CacheKey<String>,
       }
     }
 
+    public boolean doesKeyExistInCache(String key) {
+      return cacheKeyMap.containsKey(key);
+    }
+
+    private void getNextKey() throws IOException {
+      while (cacheCreatedKeyIter.hasNext() && currentKey == null) {
+        Map.Entry<String, Value> entry = cacheCreatedKeyIter.next();
+        if (null == entry.getValue()) {

Review Comment:
   > @sumitagrawl @devmadhuu I am surely missing something here. Correct me if 
I am wrong, we are doing a continue here as per this statement which will skip 
the null value here. So all I am asking is when we are initializing 
cacheCreatedKeyIter can we skip null values? The key would be still there in 
the cacheKeyMap. It will make this code much simpler.
   
   cacheKeyMap: This is used for 2 porpose, 
   1. check if latest update available in cache compared to DB,
   - Value if not null: latest value from cache
   - Value if null: represent data is deleted and `dbIterator` check for this 
also
   
   Now if we remove null value while initialize, then how DBIterator knows if 
keys are deleted? So this is required if key is deleted to skip from db 
iterator and hence we need this information.
   
   2. retrieve data in getNextKey() to caller.
   Here, null value is not required to be returned while iterator, so we can 
skip as above.
   
   @swamirishi I think this will help to understand why we can not remove null 
value during initialization. else if any key deleted, this can not be know via 
dbIterator (as may not yet flushed to db with delete) and may give deleted key 
details to user.
   
   
   



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