E
- the type of the contained elements in the queue.public class RocksDBCachingPriorityQueueSet<E extends HeapPriorityQueueElement> extends AbstractHeapPriorityQueueElement implements InternalPriorityQueue<E>
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.
|
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. order) of this set, or returns
null if this set is empty. |
E |
poll()
Retrieves and removes the first element (w.r.t. the order) of this set, or returns
null if this set is empty. |
boolean |
remove(E toRemove)
Removes the given element from the set, if is contained in the set.
|
int |
size()
This implementation comes at a relatively high cost per invocation.
|
getInternalIndex, setInternalIndex
@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>
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.