dawidwys commented on a change in pull request #13550: URL: https://github.com/apache/flink/pull/13550#discussion_r502383634
########## File path: flink-streaming-java/src/main/java/org/apache/flink/streaming/api/operators/sorted/state/SingleKeyKeyGroupedInternalPriorityQueue.java ########## @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.streaming.api.operators.sorted.state; + +import org.apache.flink.runtime.state.KeyGroupedInternalPriorityQueue; +import org.apache.flink.runtime.state.PriorityComparator; +import org.apache.flink.runtime.state.heap.HeapPriorityQueue; +import org.apache.flink.runtime.state.heap.HeapPriorityQueueElement; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +/** + * Very similar implementation to {@link org.apache.flink.runtime.state.heap.HeapPriorityQueueSet}. The only difference + * is it keeps track of elements for a single key at a time. + */ +class SingleKeyKeyGroupedInternalPriorityQueue<T extends HeapPriorityQueueElement> + extends HeapPriorityQueue<T> + implements KeyGroupedInternalPriorityQueue<T> { + + private final Map<T, T> dedupMap = new HashMap<>(); Review comment: Good question. The reason is that we actually always use the `*PriorityQueue` as a `Set`. We use the `PriorityQueue` for storing timers and that's why we need Set semantics. We want to fire only a single timer for a timestamp. BTW, the logic is copied over from the `HeapPriorityQueueSet`. However to better address it I will rename the class to `BatchExecutionInternalPriorityQueueSet`. ---------------------------------------------------------------- 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]
