Myasuka commented on a change in pull request #12033:
URL: https://github.com/apache/flink/pull/12033#discussion_r422154704



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/HeapMapState.java
##########
@@ -158,7 +159,7 @@ public boolean contains(UK userKey) {
        @Override
        public Iterator<Map.Entry<UK, UV>> iterator() {
                Map<UK, UV> userMap = stateTable.get(currentNamespace);
-               return userMap == null ? null : userMap.entrySet().iterator();
+               return userMap == null ? Collections.<UK, 
UV>emptyMap().entrySet().iterator() : userMap.entrySet().iterator();

Review comment:
       Please take a look at 
[RocksDBMapState#entries](https://github.com/apache/flink/blob/4959ebfc349bb80f88582f9ef2d60d09f1140737/flink-state-backends/flink-statebackend-rocksdb/src/main/java/org/apache/flink/contrib/streaming/state/RocksDBMapState.java#L169-L174),
 it will return `null` if the iterator is empty. 
   Moreover, except `HeapMapState#iterator`, other interfaces like 
`HeapMapState#keys` and `HeapMapState#values` will also return null if empty.
   I prefer you could handle the `null` problem in `NullAwareMapIterator` or 
`StateMapView`. Otherwise, we could launch a discussion thread to align the 
behavior of `HeapMapState` and `RocksDBMapState`.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to