Package org.apache.flink.state.rocksdb
Class TreeOrderedSetCache
- java.lang.Object
-
- org.apache.flink.state.rocksdb.TreeOrderedSetCache
-
- All Implemented Interfaces:
RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
public class TreeOrderedSetCache extends Object implements RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Implementation of a lexicographically ordered set of byte-arrays, based on aTreeSet
.
-
-
Field Summary
-
Fields inherited from interface org.apache.flink.state.rocksdb.RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
LEXICOGRAPHIC_BYTE_COMPARATOR
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(byte[] toAdd)
Adds the given element, if it was not already contained.void
bulkLoadFromOrderedIterator(Iterator<byte[]> orderedIterator)
Clears the cache and adds up tomaxSize()
elements from the iterator to the cache.boolean
isEmpty()
Returnssize() == 0
.boolean
isFull()
Returnssize() == maxSize()
.int
maxSize()
Returns the maximum number of elements that can be stored in the cache.byte[]
peekFirst()
Returns the first element ornull
if empty.byte[]
peekLast()
Returns the last element ornull
if empty.byte[]
pollFirst()
Returns and removes the first element or returnsnull
if empty.byte[]
pollLast()
Returns and removes the last element or returnsnull
if empty.boolean
remove(byte[] toRemove)
Removes the given element, if it is contained.int
size()
Returns the number of contained elements.
-
-
-
Method Detail
-
size
public int size()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the number of contained elements.- Specified by:
size
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
maxSize
public int maxSize()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the maximum number of elements that can be stored in the cache.- Specified by:
maxSize
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isEmpty
public boolean isEmpty()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returnssize() == 0
.- Specified by:
isEmpty
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isFull
public boolean isFull()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returnssize() == maxSize()
.- Specified by:
isFull
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
add
public boolean add(@Nonnull byte[] toAdd)
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Adds the given element, if it was not already contained. Returnstrue
iff the cache was modified.- Specified by:
add
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
remove
public boolean remove(@Nonnull byte[] toRemove)
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Removes the given element, if it is contained. Returnstrue
iff the cache was modified.- Specified by:
remove
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekFirst
@Nullable public byte[] peekFirst()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the first element ornull
if empty.- Specified by:
peekFirst
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekLast
@Nullable public byte[] peekLast()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the last element ornull
if empty.- Specified by:
peekLast
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollFirst
@Nullable public byte[] pollFirst()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns and removes the first element or returnsnull
if empty.- Specified by:
pollFirst
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollLast
@Nullable public byte[] pollLast()
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns and removes the last element or returnsnull
if empty.- Specified by:
pollLast
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
bulkLoadFromOrderedIterator
public void bulkLoadFromOrderedIterator(@Nonnull Iterator<byte[]> orderedIterator)
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
Clears the cache and adds up tomaxSize()
elements from the iterator to the cache. Iterator must be ordered in the same order as this cache.- Specified by:
bulkLoadFromOrderedIterator
in interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
- Parameters:
orderedIterator
- iterator with elements in-order.
-
-