K
- the type of key.V
- the type of value.public abstract class AbstractClusterWideIterator<K,V> extends Object implements Iterator<javax.cache.Cache.Entry<K,V>>
AbstractClusterWideIterator
provides the core iterator functionality shared by its descendants.
Hazelcast cluster is made of partitions which holds a slice of all clusters data. Partition count never increase or decrease in a cluster. In order to implement an iterator over a partitioned data, we use the following parameters.
Iteration steps:
next()
when method is called.next()
, more keys are fetched from the cluster.SampleableConcurrentHashMap
.
hasNext()
may return true for a key already removed.hasNext()
only return false when all known keys are fetched and iterated.next()
may return null although cache never has null value. This may happen when, for example,
someone removes the entry after the current thread has checked with hasNext()
.next()
called.Modifier and Type | Field and Description |
---|---|
protected ICacheInternal<K,V> |
cache |
protected int |
currentIndex |
protected static int |
DEFAULT_FETCH_SIZE |
protected int |
fetchSize |
protected int |
index |
protected int |
lastTableIndex
The table is segment table of hash map, which is an array that stores the actual records.
|
protected int |
partitionCount |
protected int |
partitionIndex |
protected boolean |
prefetchValues |
protected List |
result |
Constructor and Description |
---|
AbstractClusterWideIterator(ICacheInternal<K,V> cache,
int partitionCount,
int fetchSize,
boolean prefetchValues) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
advance() |
protected void |
ensureOpen() |
protected abstract List |
fetch() |
protected int |
getPartitionCount() |
boolean |
hasNext() |
javax.cache.Cache.Entry<K,V> |
next() |
void |
remove() |
protected void |
setLastTableIndex(List response,
int lastTableIndex) |
protected abstract Data |
toData(Object obj) |
protected abstract <T> T |
toObject(Object data) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected static final int DEFAULT_FETCH_SIZE
protected ICacheInternal<K,V> cache
protected List result
protected final int partitionCount
protected int partitionIndex
protected int lastTableIndex
The iteration will start from highest index available to the table. It will be converted to array size on the server side.
protected final int fetchSize
protected boolean prefetchValues
protected int index
protected int currentIndex
public AbstractClusterWideIterator(ICacheInternal<K,V> cache, int partitionCount, int fetchSize, boolean prefetchValues)
public boolean hasNext()
public void remove()
protected boolean advance()
protected void ensureOpen()
protected void setLastTableIndex(List response, int lastTableIndex)
protected int getPartitionCount()
protected abstract List fetch()
protected abstract <T> T toObject(Object data)
Copyright © 2018 Hazelcast, Inc.. All Rights Reserved.