public class ChangelogKeyGroupedPriorityQueue<T> extends Object implements KeyGroupedInternalPriorityQueue<T>, ChangelogState
KeyGroupedInternalPriorityQueue
that keeps state on the underlying delegated KeyGroupedInternalPriorityQueue
as well as on the state change log.Constructor and Description |
---|
ChangelogKeyGroupedPriorityQueue(KeyGroupedInternalPriorityQueue<T> delegatedPriorityQueue,
StateChangeLogger<T,Void> logger,
TypeSerializer<T> serializer) |
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.
|
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.
|
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.
|
void |
resetWritingMetaFlag()
Enable logging meta data before next writes.
|
<IS> void |
setDelegatedState(IS state) |
int |
size()
Returns the number of elements in this set.
|
public ChangelogKeyGroupedPriorityQueue(KeyGroupedInternalPriorityQueue<T> delegatedPriorityQueue, StateChangeLogger<T,Void> logger, TypeSerializer<T> serializer)
public Set<T> getSubsetForKeyGroup(int keyGroupId)
KeyGroupedInternalPriorityQueue
getSubsetForKeyGroup
in interface KeyGroupedInternalPriorityQueue<T>
@Nullable public T poll()
InternalPriorityQueue
null
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.
poll
in interface InternalPriorityQueue<T>
null
if this set is empty.@Nullable public T peek()
InternalPriorityQueue
null
if this set is empty.peek
in interface InternalPriorityQueue<T>
null
if this set is
empty.public boolean add(T toAdd)
InternalPriorityQueue
add
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(T toRemove)
InternalPriorityQueue
NOTE: Correct key (i.e. the key of the polled element) must be set on KeyContext before calling this method.
remove
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()
InternalPriorityQueue
isEmpty
in interface InternalPriorityQueue<T>
public int size()
InternalPriorityQueue
size
in interface InternalPriorityQueue<T>
public void addAll(@Nullable Collection<? extends T> toAdd)
InternalPriorityQueue
addAll
in interface InternalPriorityQueue<T>
@Nonnull public CloseableIterator<T> iterator()
InternalPriorityQueue
iterator
in interface InternalPriorityQueue<T>
public StateChangeApplier getChangeApplier(ChangelogApplierFactory factory)
getChangeApplier
in interface ChangelogState
public <IS> void setDelegatedState(IS state)
setDelegatedState
in interface ChangelogState
public StateChangeLogger<T,Void> getStateChangeLogger()
public void resetWritingMetaFlag()
ChangelogState
resetWritingMetaFlag
in interface ChangelogState
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.