Class RocksDBCachingPriorityQueueSet<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>

  • Type Parameters:
    E - the type of the contained elements in the queue.
    All Implemented Interfaces:
    org.apache.flink.runtime.state.heap.HeapPriorityQueueElement, org.apache.flink.runtime.state.InternalPriorityQueue<E>

    public class RocksDBCachingPriorityQueueSet<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
    extends org.apache.flink.runtime.state.heap.AbstractHeapPriorityQueueElement
    implements org.apache.flink.runtime.state.InternalPriorityQueue<E>
    A priority queue with set semantics, implemented on top of RocksDB. This uses a 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.
    • Method Detail

      • peek

        @Nullable
        public E peek()
        Specified by:
        peek in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • poll

        @Nullable
        public E poll()
        Specified by:
        poll in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • add

        public boolean add​(@Nonnull
                           E toAdd)
        Specified by:
        add in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • remove

        public boolean remove​(@Nonnull
                              E toRemove)
        Specified by:
        remove in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • addAll

        public void addAll​(@Nullable
                           Collection<? extends E> toAdd)
        Specified by:
        addAll in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • iterator

        @Nonnull
        public org.apache.flink.util.CloseableIterator<E> iterator()
        Specified by:
        iterator in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>
      • size

        public int size()
        This implementation comes at a relatively high cost per invocation. It should not be called repeatedly when it is clear that the value did not change. Currently this is only truly used to realize certain higher-level tests.
        Specified by:
        size in interface org.apache.flink.runtime.state.InternalPriorityQueue<E extends org.apache.flink.runtime.state.heap.HeapPriorityQueueElement>