- Type Parameters:
K - the type of key.
V - the type of value.
- All Implemented Interfaces:
- Direct Known Subclasses:
- ClientClusterWideIterator, ClusterWideIterator
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.
- To iterate over partitioned data, we use partitionId as the first parameter of this iterator.
- Each partition may have a lot of entries, so we use a second parameter to track the iteration of the
This implementation iterates over partitions and for each partition it iterates over the internal map using the
internal table index of the map
- fetching fixed sized of keys from the current partition defined by partitionId.
- iteration on fetched keys.
- get value of each key with
next() when method is called.
- when fetched keys are all used by calling
next(), more keys are fetched from the cluster.
Fetching data from cluster:
Fetching is getting a fixed size of keys from the internal table of records of a partition defined by
partitionId. Table index is also provided as a table index locator. Fetch response is the keys and
last table index. The last table index is included in the result to be used in the next fetch.
- Iterator fetches keys in batch with a fixed size that is configurable.
- Fetched keys are cached in the iterator to be used in each iteration step.
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
- This implementation does not affected by value updates as each value is got from the cluster
- See Also:
AbstractCacheRecordStore.iterator(int tableIndex, int size),
|Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
protected ICache<K,V> cache
protected CacheKeyIteratorResult result
protected final int partitionCount
protected int partitionIndex
protected int lastTableIndex
protected final int fetchSize
protected int index
protected int currentIndex
public AbstractClusterWideIterator(ICache<K,V> cache,
public boolean hasNext()
- Specified by:
hasNext in interface
public javax.cache.Cache.Entry<K,V> next()
- Specified by:
next in interface
public void remove()
- Specified by:
remove in interface
protected boolean advance()
protected void ensureOpen()
protected int getPartitionCount()
protected abstract CacheKeyIteratorResult fetch()
protected abstract Data toData(Object obj)
protected abstract <T> T toObject(Object data)
Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.