StefanRRichter commented on a change in pull request #8361: 
[FLINK-12434][network] Replace listeners with CompletableFuture in InputGates
URL: https://github.com/apache/flink/pull/8361#discussion_r282212329
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/util/SetArrayDeque.java
 ##########
 @@ -16,20 +16,38 @@
  * limitations under the License.
  */
 
-package org.apache.flink.runtime.io.network.partition.consumer;
+package org.apache.flink.runtime.util;
+
+import java.util.ArrayDeque;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
- * Listener interface implemented by consumers of {@link InputGate} instances
- * that want to be notified of availability of buffer or event instances.
+ * Wrapper of {@link ArrayDeque} with quick {@link HashSet}'s based {@link 
#contains(Object)} method.
  */
-public interface InputGateListener {
+public class SetArrayDeque<T> {
+       private final ArrayDeque<T> deque = new ArrayDeque<>();
+       private final Set<T> set = new HashSet<>();
+
+       public boolean add(T element) {
+               return deque.add(element) || set.add(element);
 
 Review comment:
   It is not only about the return value, but even worse you can add duplicates 
to the dequeue because it is ignored that the value is potentially already in 
the set. So this is not set semantics anymore.

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


With regards,
Apache Git Services

Reply via email to