Class TreeOrderedSetCache
java.lang.Object
org.apache.flink.state.forst.sync.TreeOrderedSetCache
- All Implemented Interfaces:
ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
public class TreeOrderedSetCache
extends Object
implements ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Implementation of a lexicographically ordered set of byte-arrays, based on a
TreeSet.-
Field Summary
Fields inherited from interface org.apache.flink.state.forst.sync.ForStDBCachingPriorityQueueSet.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:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the number of contained elements.- Specified by:
sizein interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
maxSize
public int maxSize()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the maximum number of elements that can be stored in the cache.- Specified by:
maxSizein interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isEmpty
public boolean isEmpty()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturnssize() == 0.- Specified by:
isEmptyin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isFull
public boolean isFull()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturnssize() == maxSize().- Specified by:
isFullin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
add
public boolean add(@Nonnull byte[] toAdd) Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheAdds the given element, if it was not already contained. Returnstrueiff the cache was modified.- Specified by:
addin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
remove
public boolean remove(@Nonnull byte[] toRemove) Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheRemoves the given element, if it is contained. Returnstrueiff the cache was modified.- Specified by:
removein interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekFirst
@Nullable public byte[] peekFirst()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the first element ornullif empty.- Specified by:
peekFirstin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekLast
@Nullable public byte[] peekLast()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns the last element ornullif empty.- Specified by:
peekLastin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollFirst
@Nullable public byte[] pollFirst()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns and removes the first element or returnsnullif empty.- Specified by:
pollFirstin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollLast
@Nullable public byte[] pollLast()Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCacheReturns and removes the last element or returnsnullif empty.- Specified by:
pollLastin interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
bulkLoadFromOrderedIterator
Description copied from interface:ForStDBCachingPriorityQueueSet.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 interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache- Parameters:
orderedIterator- iterator with elements in-order.
-