com.hazelcast.cache.impl
Class AbstractClusterWideIterator<K,V>

java.lang.Object
  extended by com.hazelcast.cache.impl.AbstractClusterWideIterator<K,V>
Type Parameters:
K - the type of key.
V - the type of value.
All Implemented Interfaces:
Iterator<javax.cache.Cache.Entry<K,V>>
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.

Iteration steps:

This implementation iterates over partitions and for each partition it iterates over the internal map using the internal table index of the map CacheConcurrentHashMap.

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.

Notes:

See Also:
AbstractCacheRecordStore.iterator(int tableIndex, int size), ClusterWideIterator, CacheKeyIteratorResult

Field Summary
protected  ICache<K,V> cache
           
protected  int currentIndex
           
protected  int fetchSize
           
protected  int index
           
protected  int lastTableIndex
           
protected  int partitionCount
           
protected  int partitionIndex
           
protected  CacheKeyIteratorResult result
           
 
Constructor Summary
AbstractClusterWideIterator(ICache<K,V> cache, int partitionCount)
           
 
Method Summary
protected  boolean advance()
           
protected  void ensureOpen()
           
protected abstract  CacheKeyIteratorResult fetch()
           
protected  int getPartitionCount()
           
 boolean hasNext()
           
 javax.cache.Cache.Entry<K,V> next()
           
 void remove()
           
protected abstract  Data toData(Object obj)
           
protected abstract
<T> T
toObject(Object data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

protected ICache<K,V> cache

result

protected CacheKeyIteratorResult result

partitionCount

protected final int partitionCount

partitionIndex

protected int partitionIndex

lastTableIndex

protected int lastTableIndex

fetchSize

protected final int fetchSize

index

protected int index

currentIndex

protected int currentIndex
Constructor Detail

AbstractClusterWideIterator

public AbstractClusterWideIterator(ICache<K,V> cache,
                                   int partitionCount)
Method Detail

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<javax.cache.Cache.Entry<K,V>>

next

public javax.cache.Cache.Entry<K,V> next()
Specified by:
next in interface Iterator<javax.cache.Cache.Entry<K,V>>

remove

public void remove()
Specified by:
remove in interface Iterator<javax.cache.Cache.Entry<K,V>>

advance

protected boolean advance()

ensureOpen

protected void ensureOpen()

getPartitionCount

protected int getPartitionCount()

fetch

protected abstract CacheKeyIteratorResult fetch()

toData

protected abstract Data toData(Object obj)

toObject

protected abstract <T> T toObject(Object data)


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.