T - the type of elements in the queue.PQ - type type of sub-queue used for each key-group partition.public class KeyGroupPartitionedPriorityQueue<T,PQ extends InternalPriorityQueue<T> & HeapPriorityQueueElement> extends Object implements InternalPriorityQueue<T>, KeyGroupedInternalPriorityQueue<T>
InternalPriorityQueue is internally partitioned into sub-queues per key-group and
essentially works as a heap-of-heaps. Instances will have set semantics for elements if the sub-queues have set
semantics.| Modifier and Type | Class and Description |
|---|---|
static interface |
KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T,PQS extends InternalPriorityQueue<T> & HeapPriorityQueueElement>
Factory that produces the sub-queues that represent the partitions of a
KeyGroupPartitionedPriorityQueue. |
| Constructor and Description |
|---|
KeyGroupPartitionedPriorityQueue(KeyExtractorFunction<T> keyExtractor,
PriorityComparator<T> elementPriorityComparator,
KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T,PQ> orderedCacheFactory,
KeyGroupRange keyGroupRange,
int totalKeyGroups) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T toAdd)
Adds the given element to the set, if it is not already contained.
|
void |
addAll(Collection<? extends T> toAdd)
Adds all the given elements to the set.
|
Set<T> |
getSubsetForKeyGroup(int keyGroupId)
Returns the subset of elements in the priority queue that belongs to the given key-group, within the operator's
key-group range.
|
boolean |
isEmpty()
Check if the set contains any elements.
|
org.apache.flink.util.CloseableIterator<T> |
iterator()
Iterator over all elements, no order guaranteed.
|
T |
peek()
Retrieves, but does not remove, the element (w.r.t.
|
T |
poll()
Retrieves and removes the first element (w.r.t.
|
boolean |
remove(T toRemove)
Removes the given element from the set, if is contained in the set.
|
int |
size()
Returns the number of elements in this set.
|
public KeyGroupPartitionedPriorityQueue(@Nonnull KeyExtractorFunction<T> keyExtractor, @Nonnull PriorityComparator<T> elementPriorityComparator, @Nonnull KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T,PQ> orderedCacheFactory, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int totalKeyGroups)
@Nullable public T poll()
InternalPriorityQueuenull if this set is empty.poll in interface InternalPriorityQueue<T>null if this set is empty.@Nullable public T peek()
InternalPriorityQueuenull if this set is empty.peek in interface InternalPriorityQueue<T>null if this set is empty.public boolean add(@Nonnull T toAdd)
InternalPriorityQueueadd in interface InternalPriorityQueue<T>toAdd - the element to add to the set.true if the operation changed the head element or if it is unclear if the head element changed.
Only returns false if the head element was not changed by this operation.public boolean remove(@Nonnull T toRemove)
InternalPriorityQueueremove in interface InternalPriorityQueue<T>toRemove - the element to remove.true if the operation changed the head element or if it is unclear if the head element changed.
Only returns false if the head element was not changed by this operation.public boolean isEmpty()
InternalPriorityQueueisEmpty in interface InternalPriorityQueue<T>public int size()
InternalPriorityQueuesize in interface InternalPriorityQueue<T>public void addAll(@Nullable Collection<? extends T> toAdd)
InternalPriorityQueueaddAll in interface InternalPriorityQueue<T>@Nonnull public org.apache.flink.util.CloseableIterator<T> iterator()
InternalPriorityQueueiterator in interface InternalPriorityQueue<T>@Nonnull public Set<T> getSubsetForKeyGroup(int keyGroupId)
KeyGroupedInternalPriorityQueuegetSubsetForKeyGroup in interface KeyGroupedInternalPriorityQueue<T>Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.