Class KeyGroupPartitionedPriorityQueue<T,PQ extends InternalPriorityQueue<T> & HeapPriorityQueueElement>
java.lang.Object
org.apache.flink.runtime.state.heap.KeyGroupPartitionedPriorityQueue<T,PQ>
- Type Parameters:
T- the type of elements in the queue.PQ- the type of sub-queue used for each key-group partition.
- All Implemented Interfaces:
InternalPriorityQueue<T>,KeyGroupedInternalPriorityQueue<T>
public class KeyGroupPartitionedPriorityQueue<T,PQ extends InternalPriorityQueue<T> & HeapPriorityQueueElement>
extends Object
implements InternalPriorityQueue<T>, KeyGroupedInternalPriorityQueue<T>
This implementation of
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceKeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T,PQS extends InternalPriorityQueue<T> & HeapPriorityQueueElement> Factory that produces the sub-queues that represent the partitions of aKeyGroupPartitionedPriorityQueue. -
Constructor Summary
ConstructorsConstructorDescriptionKeyGroupPartitionedPriorityQueue(KeyExtractorFunction<T> keyExtractor, PriorityComparator<T> elementPriorityComparator, KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T, PQ> orderedCacheFactory, KeyGroupRange keyGroupRange, int totalKeyGroups) -
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds the given element to the set, if it is not already contained.voidaddAll(Collection<? extends T> toAdd) Adds all the given elements to the set.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.booleanisEmpty()Check if the set contains any elements.org.apache.flink.util.CloseableIterator<T>iterator()Iterator over all elements, no order guaranteed.peek()Retrieves, but does not remove, the element (w.r.t. order) of this set, or returnsnullif this set is empty.poll()Retrieves and removes the first element (w.r.t. the order) of this set, or returnsnullif this set is empty.booleanRemoves the given element from the set, if is contained in the set.intsize()Returns the number of elements in this set.
-
Constructor Details
-
KeyGroupPartitionedPriorityQueue
public KeyGroupPartitionedPriorityQueue(@Nonnull KeyExtractorFunction<T> keyExtractor, @Nonnull PriorityComparator<T> elementPriorityComparator, @Nonnull KeyGroupPartitionedPriorityQueue.PartitionQueueSetFactory<T, PQ> orderedCacheFactory, @Nonnull KeyGroupRange keyGroupRange, @Nonnegative int totalKeyGroups)
-
-
Method Details
-
poll
Description copied from interface:InternalPriorityQueueRetrieves and removes the first element (w.r.t. the order) of this set, or returnsnullif this set is empty.NOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
- Specified by:
pollin interfaceInternalPriorityQueue<T>- Returns:
- the first element of this ordered set, or
nullif this set is empty.
-
peek
Description copied from interface:InternalPriorityQueueRetrieves, but does not remove, the element (w.r.t. order) of this set, or returnsnullif this set is empty.- Specified by:
peekin interfaceInternalPriorityQueue<T>- Returns:
- the first element (w.r.t. order) of this ordered set, or
nullif this set is empty.
-
add
Description copied from interface:InternalPriorityQueueAdds the given element to the set, if it is not already contained.- Specified by:
addin interfaceInternalPriorityQueue<T>- Parameters:
toAdd- the element to add to the set.- Returns:
trueif the operation changed the head element or if it is unclear if the head element changed. Only returnsfalseif the head element was not changed by this operation.
-
remove
Description copied from interface:InternalPriorityQueueRemoves the given element from the set, if is contained in the set.NOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
- Specified by:
removein interfaceInternalPriorityQueue<T>- Parameters:
toRemove- the element to remove.- Returns:
trueif the operation changed the head element or if it is unclear if the head element changed. Only returnsfalseif the head element was not changed by this operation.
-
isEmpty
public boolean isEmpty()Description copied from interface:InternalPriorityQueueCheck if the set contains any elements.- Specified by:
isEmptyin interfaceInternalPriorityQueue<T>- Returns:
- true if the set is empty, i.e. no element is contained.
-
size
public int size()Description copied from interface:InternalPriorityQueueReturns the number of elements in this set.- Specified by:
sizein interfaceInternalPriorityQueue<T>- Returns:
- the number of elements in this set.
-
addAll
Description copied from interface:InternalPriorityQueueAdds all the given elements to the set.- Specified by:
addAllin interfaceInternalPriorityQueue<T>
-
iterator
Description copied from interface:InternalPriorityQueueIterator over all elements, no order guaranteed. Iterator must be closed after usage.- Specified by:
iteratorin interfaceInternalPriorityQueue<T>
-
getSubsetForKeyGroup
Description copied from interface:KeyGroupedInternalPriorityQueueReturns the subset of elements in the priority queue that belongs to the given key-group, within the operator's key-group range.- Specified by:
getSubsetForKeyGroupin interfaceKeyGroupedInternalPriorityQueue<T>
-