rkhachatryan commented on a change in pull request #15200:
URL: https://github.com/apache/flink/pull/15200#discussion_r640979359



##########
File path: 
flink-state-backends/flink-statebackend-changelog/src/main/java/org/apache/flink/state/changelog/ChangelogMapState.java
##########
@@ -71,22 +94,67 @@ public boolean contains(UK key) throws Exception {
 
     @Override
     public Iterable<Map.Entry<UK, UV>> entries() throws Exception {
-        return delegatedState.entries();
+        Iterator<Map.Entry<UK, UV>> iterator = 
delegatedState.entries().iterator();
+        final N currentNamespace = getCurrentNamespace();
+        return () ->
+                loggingIterator(
+                        new Iterator<Map.Entry<UK, UV>>() {
+                            @Override
+                            public Map.Entry<UK, UV> next() {
+                                return loggingMapEntry(
+                                        iterator.next(),
+                                        changeLogger,
+                                        changeWriter,
+                                        currentNamespace);
+                            }
+
+                            @Override
+                            public boolean hasNext() {
+                                return iterator.hasNext();
+                            }
+
+                            @Override
+                            public void remove() {
+                                iterator.remove();
+                            }
+                        },
+                        changeLogger,
+                        changeWriter,
+                        currentNamespace);
     }
 
     @Override
     public Iterable<UK> keys() throws Exception {
-        return delegatedState.keys();
+        return loggingIterable(
+                delegatedState.keys(), changeLogger, this::serializeKey, 
getCurrentNamespace());

Review comment:
       No, it's impossible. I'm not sure I understand your concern though.
   
   What can happen is:
   1. user calls `map.put(1, 1)`
   2. `delegatedMap` creates a new `HashMap` for the current stream key, stores 
it, and calls `put(1, 1)` on it
   3. user calls `changeLogMap.keys()`
   4. `delegatedMap` returns `hashMap.keySet`, wrapped for logging 
`ChangelogMapState`
   5. user calls `keys.iterator.next().remove(x)` - this is supported by jdk 
`HashMap` and should be logged. Both key and value are removed.
   




-- 
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:
[email protected]


Reply via email to