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 aTreeSet
.
-
-
Field Summary
-
Fields inherited from interface org.apache.flink.state.forst.sync.ForStDBCachingPriorityQueueSet.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:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the number of contained elements.- Specified by:
size
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
maxSize
public int maxSize()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the maximum number of elements that can be stored in the cache.- Specified by:
maxSize
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isEmpty
public boolean isEmpty()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returnssize() == 0
.- Specified by:
isEmpty
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
isFull
public boolean isFull()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returnssize() == maxSize()
.- Specified by:
isFull
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
add
public boolean add(@Nonnull byte[] toAdd)
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Adds the given element, if it was not already contained. Returnstrue
iff the cache was modified.- Specified by:
add
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
remove
public boolean remove(@Nonnull byte[] toRemove)
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Removes the given element, if it is contained. Returnstrue
iff the cache was modified.- Specified by:
remove
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekFirst
@Nullable public byte[] peekFirst()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the first element ornull
if empty.- Specified by:
peekFirst
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
peekLast
@Nullable public byte[] peekLast()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns the last element ornull
if empty.- Specified by:
peekLast
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollFirst
@Nullable public byte[] pollFirst()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns and removes the first element or returnsnull
if empty.- Specified by:
pollFirst
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
pollLast
@Nullable public byte[] pollLast()
Description copied from interface:ForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
Returns and removes the last element or returnsnull
if empty.- Specified by:
pollLast
in interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
-
bulkLoadFromOrderedIterator
public void bulkLoadFromOrderedIterator(@Nonnull Iterator<byte[]> orderedIterator)
Description copied from interface:ForStDBCachingPriorityQueueSet.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 interfaceForStDBCachingPriorityQueueSet.OrderedByteArraySetCache
- Parameters:
orderedIterator
- iterator with elements in-order.
-
-