StefanRRichter commented on a change in pull request #7188: [FLINK-10473][State 
TTL] TTL state incremental cleanup for heap backend
URL: https://github.com/apache/flink/pull/7188#discussion_r248240356
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/state/heap/CopyOnWriteStateTable.java
 ##########
 @@ -1032,75 +1040,157 @@ public int sizeOfNamespace(Object namespace) {
 
        // StateEntryIterator  
---------------------------------------------------------------------------------------------
 
+       @Override
+       public StateIteratorWithUpdate<K, N, S> 
getStateEntryIteratorWithUpdate() {
+               return new StateEntryIteratorWithModifications();
+       }
+
        /**
-        * Iterator over the entries in a {@link CopyOnWriteStateTable}.
+        * Iterator over state entries in a {@link CopyOnWriteStateTable}.
         */
-       class StateEntryIterator implements Iterator<StateEntry<K, N, S>> {
-               private StateTableEntry<K, N, S>[] activeTable;
-               private int nextTablePosition;
-               private StateTableEntry<K, N, S> nextEntry;
-               private int expectedModCount;
+       class BaseStateEntryIterator implements Iterator<StateEntry<K, N, S>> {
+               StateTableEntry<K, N, S>[] activeTable;
+               int nextTablePosition;
+               StateTableEntry<K, N, S> nextEntry;
+               StateTableEntry<K, N, S> entryToReturn;
 
-               StateEntryIterator() {
+               BaseStateEntryIterator() {
                        this.activeTable = primaryTable;
                        this.nextTablePosition = 0;
-                       this.expectedModCount = modCount;
                        this.nextEntry = getBootstrapEntry();
                        advanceIterator();
                }
 
-               private StateTableEntry<K, N, S> advanceIterator() {
-
-                       StateTableEntry<K, N, S> entryToReturn = nextEntry;
-                       StateTableEntry<K, N, S> next = entryToReturn.next;
-
-                       // consider both sub-tables tables to cover the case of 
rehash
-                       while (next == null) {
-
-                               StateTableEntry<K, N, S>[] tab = activeTable;
+               @Override
+               public boolean hasNext() {
+                       return nextEntry != null;
+               }
 
-                               while (nextTablePosition < tab.length) {
-                                       next = tab[nextTablePosition++];
+               @Override
+               public StateEntry<K, N, S> next() {
+                       if (!hasNext()) {
 
 Review comment:
   In the base class, this looks like it can be dropped, so maybe that should 
just go into the overriden next method of the new iterator before a 
`super.next()`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

Reply via email to