E
- the type of the contained elements in the queue.public class RocksDBCachingPriorityQueueSet<E extends HeapPriorityQueueElement> extends Object implements InternalPriorityQueue<E>, HeapPriorityQueueElement
TreeSet
to cache the bytes of up to the first n elements from RocksDB in memory to reduce interaction
with RocksDB, in particular seek operations. Cache uses a simple write-through policy.Modifier and Type | Class and Description |
---|---|
static interface |
RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Cache that is organized as an ordered set for byte-arrays.
|
NOT_CONTAINED
Modifier and Type | Method and Description |
---|---|
boolean |
add(E toAdd)
Adds the given element to the set, if it is not already contained.
|
void |
addAll(Collection<? extends E> toAdd)
Adds all the given elements to the set.
|
int |
getInternalIndex()
Returns the current index of this object in the internal array of
HeapPriorityQueue . |
boolean |
isEmpty()
Check if the set contains any elements.
|
CloseableIterator<E> |
iterator()
Iterator over all elements, no order guaranteed.
|
E |
peek()
Retrieves, but does not remove, the element (w.r.t.
|
E |
poll()
Retrieves and removes the first element (w.r.t.
|
boolean |
remove(E toRemove)
Removes the given element from the set, if is contained in the set.
|
void |
setInternalIndex(int newIndex)
Sets the current index of this object in the
HeapPriorityQueue and should only be
called by the owning HeapPriorityQueue . |
int |
size()
This implementation comes at a relatively high cost per invocation.
|
@Nullable public E peek()
InternalPriorityQueue
null
if this set is empty.peek
in interface InternalPriorityQueue<E extends HeapPriorityQueueElement>
null
if this set is
empty.@Nullable public E 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<E extends HeapPriorityQueueElement>
null
if this set is empty.public boolean add(@Nonnull E toAdd)
InternalPriorityQueue
add
in interface InternalPriorityQueue<E extends HeapPriorityQueueElement>
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 E 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<E extends HeapPriorityQueueElement>
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 void addAll(@Nullable Collection<? extends E> toAdd)
InternalPriorityQueue
addAll
in interface InternalPriorityQueue<E extends HeapPriorityQueueElement>
public boolean isEmpty()
InternalPriorityQueue
isEmpty
in interface InternalPriorityQueue<E extends HeapPriorityQueueElement>
@Nonnull public CloseableIterator<E> iterator()
InternalPriorityQueue
iterator
in interface InternalPriorityQueue<E extends HeapPriorityQueueElement>
public int size()
size
in interface InternalPriorityQueue<E extends HeapPriorityQueueElement>
public int getInternalIndex()
HeapPriorityQueueElement
HeapPriorityQueue
.getInternalIndex
in interface HeapPriorityQueueElement
public void setInternalIndex(int newIndex)
HeapPriorityQueueElement
HeapPriorityQueue
and should only be
called by the owning HeapPriorityQueue
.setInternalIndex
in interface HeapPriorityQueueElement
newIndex
- the new index in the timer heap.Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.