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 a
TreeSet.-
Field Summary
Fields inherited from interface org.apache.flink.state.rocksdb.RocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
LEXICOGRAPHIC_BYTE_COMPARATOR -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(byte[] toAdd) Adds the given element, if it was not already contained.voidbulkLoadFromOrderedIterator(Iterator<byte[]> orderedIterator) Clears the cache and adds up tomaxSize()elements from the iterator to the cache.booleanisEmpty()Returnssize() == 0.booleanisFull()Returnssize() == maxSize().intmaxSize()Returns the maximum number of elements that can be stored in the cache.byte[]Returns the first element ornullif empty.byte[]peekLast()Returns the last element ornullif empty.byte[]Returns and removes the first element or returnsnullif empty.byte[]pollLast()Returns and removes the last element or returnsnullif empty.booleanremove(byte[] toRemove) Removes the given element, if it is contained.intsize()Returns the number of contained elements.
-
Method Details
-
size
public int size()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the number of contained elements.- Specified by:
sizein interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
maxSize
public int maxSize()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the maximum number of elements that can be stored in the cache.- Specified by:
maxSizein interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isEmpty
public boolean isEmpty()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturnssize() == 0.- Specified by:
isEmptyin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isFull
public boolean isFull()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturnssize() == maxSize().- Specified by:
isFullin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
add
public boolean add(@Nonnull byte[] toAdd) Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheAdds the given element, if it was not already contained. Returnstrueiff the cache was modified.- Specified by:
addin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
remove
public boolean remove(@Nonnull byte[] toRemove) Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheRemoves the given element, if it is contained. Returnstrueiff the cache was modified.- Specified by:
removein interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekFirst
@Nullable public byte[] peekFirst()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the first element ornullif empty.- Specified by:
peekFirstin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekLast
@Nullable public byte[] peekLast()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the last element ornullif empty.- Specified by:
peekLastin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollFirst
@Nullable public byte[] pollFirst()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns and removes the first element or returnsnullif empty.- Specified by:
pollFirstin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollLast
@Nullable public byte[] pollLast()Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns and removes the last element or returnsnullif empty.- Specified by:
pollLastin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
bulkLoadFromOrderedIterator
Description copied from interface:RocksDBCachingPriorityQueueSet.OrderedByteArraySetCacheClears 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:
bulkLoadFromOrderedIteratorin interfaceRocksDBCachingPriorityQueueSet.OrderedByteArraySetCache- Parameters:
orderedIterator- iterator with elements in-order.
-