Package org.apache.flink.state.changelog
Class ChangelogKeyGroupedPriorityQueue<T>
- java.lang.Object
-
- org.apache.flink.state.changelog.ChangelogKeyGroupedPriorityQueue<T>
-
- All Implemented Interfaces:
InternalPriorityQueue<T>
,KeyGroupedInternalPriorityQueue<T>
,ChangelogState
public class ChangelogKeyGroupedPriorityQueue<T> extends Object implements KeyGroupedInternalPriorityQueue<T>, ChangelogState
AKeyGroupedInternalPriorityQueue
that keeps state on the underlying delegatedKeyGroupedInternalPriorityQueue
as well as on the state change log.
-
-
Constructor Summary
Constructors Constructor Description ChangelogKeyGroupedPriorityQueue(KeyGroupedInternalPriorityQueue<T> delegatedPriorityQueue, StateChangeLogger<T,Void> logger, TypeSerializer<T> serializer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.StateChangeApplier
getChangeApplier(ChangelogApplierFactory factory)
StateChangeLogger<T,Void>
getStateChangeLogger()
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.CloseableIterator<T>
iterator()
Iterator over all elements, no order guaranteed.T
peek()
Retrieves, but does not remove, the element (w.r.t. order) of this set, or returnsnull
if this set is empty.T
poll()
Retrieves and removes the first element (w.r.t. the order) of this set, or returnsnull
if this set is empty.boolean
remove(T toRemove)
Removes the given element from the set, if is contained in the set.void
resetWritingMetaFlag()
Enable logging meta data before next writes.<IS> void
setDelegatedState(IS state)
int
size()
Returns the number of elements in this set.
-
-
-
Constructor Detail
-
ChangelogKeyGroupedPriorityQueue
public ChangelogKeyGroupedPriorityQueue(KeyGroupedInternalPriorityQueue<T> delegatedPriorityQueue, StateChangeLogger<T,Void> logger, TypeSerializer<T> serializer)
-
-
Method Detail
-
getSubsetForKeyGroup
public Set<T> getSubsetForKeyGroup(int keyGroupId)
Description copied from interface:KeyGroupedInternalPriorityQueue
Returns the subset of elements in the priority queue that belongs to the given key-group, within the operator's key-group range.- Specified by:
getSubsetForKeyGroup
in interfaceKeyGroupedInternalPriorityQueue<T>
-
poll
@Nullable public T poll()
Description copied from interface:InternalPriorityQueue
Retrieves and removes the first element (w.r.t. the order) of this set, or returnsnull
if 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:
poll
in interfaceInternalPriorityQueue<T>
- Returns:
- the first element of this ordered set, or
null
if this set is empty.
-
peek
@Nullable public T peek()
Description copied from interface:InternalPriorityQueue
Retrieves, but does not remove, the element (w.r.t. order) of this set, or returnsnull
if this set is empty.- Specified by:
peek
in interfaceInternalPriorityQueue<T>
- Returns:
- the first element (w.r.t. order) of this ordered set, or
null
if this set is empty.
-
add
public boolean add(T toAdd)
Description copied from interface:InternalPriorityQueue
Adds the given element to the set, if it is not already contained.- Specified by:
add
in interfaceInternalPriorityQueue<T>
- Parameters:
toAdd
- the element to add to the set.- Returns:
true
if the operation changed the head element or if it is unclear if the head element changed. Only returnsfalse
if the head element was not changed by this operation.
-
remove
public boolean remove(T toRemove)
Description copied from interface:InternalPriorityQueue
Removes 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:
remove
in interfaceInternalPriorityQueue<T>
- Parameters:
toRemove
- the element to remove.- Returns:
true
if the operation changed the head element or if it is unclear if the head element changed. Only returnsfalse
if the head element was not changed by this operation.
-
isEmpty
public boolean isEmpty()
Description copied from interface:InternalPriorityQueue
Check if the set contains any elements.- Specified by:
isEmpty
in interfaceInternalPriorityQueue<T>
- Returns:
- true if the set is empty, i.e. no element is contained.
-
size
public int size()
Description copied from interface:InternalPriorityQueue
Returns the number of elements in this set.- Specified by:
size
in interfaceInternalPriorityQueue<T>
- Returns:
- the number of elements in this set.
-
addAll
public void addAll(@Nullable Collection<? extends T> toAdd)
Description copied from interface:InternalPriorityQueue
Adds all the given elements to the set.- Specified by:
addAll
in interfaceInternalPriorityQueue<T>
-
iterator
@Nonnull public CloseableIterator<T> iterator()
Description copied from interface:InternalPriorityQueue
Iterator over all elements, no order guaranteed. Iterator must be closed after usage.- Specified by:
iterator
in interfaceInternalPriorityQueue<T>
-
getChangeApplier
public StateChangeApplier getChangeApplier(ChangelogApplierFactory factory)
- Specified by:
getChangeApplier
in interfaceChangelogState
-
setDelegatedState
public <IS> void setDelegatedState(IS state)
- Specified by:
setDelegatedState
in interfaceChangelogState
-
getStateChangeLogger
public StateChangeLogger<T,Void> getStateChangeLogger()
-
resetWritingMetaFlag
public void resetWritingMetaFlag()
Description copied from interface:ChangelogState
Enable logging meta data before next writes.- Specified by:
resetWritingMetaFlag
in interfaceChangelogState
-
-