K
- key typeV
- value type@Beta public abstract class KeyValueSource<K,V> extends Object implements Closeable
IMap
and MultiMap
. Custom implementations could
be external files, URLs or any other data source can be visualized as key-value pairs.Constructor and Description |
---|
KeyValueSource() |
Modifier and Type | Method and Description |
---|---|
abstract Map.Entry<K,V> |
element()
Returns the current index' element
|
static <V> KeyValueSource<String,V> |
fromList(IList<V> list)
A helper method to build a KeyValueSource implementation based on the specified
IList .The key returned by this KeyValueSource implementation is ALWAYS the name of the list itself, whereas the value are the entries of list one by one. |
static <K,V> KeyValueSource<K,V> |
fromMap(IMap<K,V> map)
A helper method to build a KeyValueSource implementation based on the specified
IMap |
static <K,V> KeyValueSource<K,V> |
fromMultiMap(MultiMap<K,V> multiMap)
A helper method to build a KeyValueSource implementation based on the specified
MultiMap |
static <V> KeyValueSource<String,V> |
fromSet(ISet<V> set)
A helper method to build a KeyValueSource implementation based on the specified
ISet .The key returned by this KeyValueSource implementation is ALWAYS the name of the set itself, whereas the value are the entries of set one by one. |
Collection<K> |
getAllKeys()
If
isAllKeysSupported() returns true a call to this method has to return
all clusterwide available keys. |
protected Collection<K> |
getAllKeys0()
This method is meant for overriding to implement collecting of all clusterwide available keys
and returning them from
getAllKeys() . |
abstract boolean |
hasNext()
Called to request if at least one more key-value pair is available from this
data source.
|
boolean |
isAllKeysSupported()
If it is possible to collect all clusterwide available keys for this KeyValueSource
implementation then this method should return true.
If true is returned a call to getAllKeys() must return all available keys
to execute a preselection of interesting partitions / nodes based on returns keys. |
abstract K |
key()
Returns the current index' key for
KeyPredicate analysis. |
abstract boolean |
open(NodeEngine nodeEngine)
This method is called before accessing the key-value pairs of this KeyValueSource
|
abstract boolean |
reset()
This method need to reset all internal state as it would be a new instance at all.
|
public abstract boolean open(NodeEngine nodeEngine)
nodeEngine
- nodeEngine of this cluster nodepublic abstract boolean hasNext()
public abstract K key()
KeyPredicate
analysis. This is called
to prevent a possible deserialization of unneeded values because the key is not
interesting for the running mapreduce algorithm.public abstract Map.Entry<K,V> element()
public abstract boolean reset()
PartitionIdAware
.reset()
, open(com.hazelcast.spi.NodeEngine)
and Closeable.close()
is called multiple times with the other methods between open(...) and close().public final Collection<K> getAllKeys()
If isAllKeysSupported()
returns true a call to this method has to return
all clusterwide available keys. If there is no chance to precollect all keys do to
partitioning of the data isAllKeysSupported()
must return false.
If this functionality is not available and Job.onKeys(Object[])
,
Job.onKeys(Iterable)
or Job.keyPredicate(KeyPredicate)
is used a
preselection of the interesting partitions / nodes is not available and the
overall processing speed my be degraded.
If isAllKeysSupported()
returns false this method throws an
UnsupportedOperationException
.
public boolean isAllKeysSupported()
If it is possible to collect all clusterwide available keys for this KeyValueSource
implementation then this method should return true.
If true is returned a call to getAllKeys()
must return all available keys
to execute a preselection of interesting partitions / nodes based on returns keys.
If this functionality is not available and Job.onKeys(Object[])
,
Job.onKeys(Iterable)
or Job.keyPredicate(KeyPredicate)
is used a
preselection of the interesting partitions / nodes is not available and the
overall processing speed my be degraded.
protected Collection<K> getAllKeys0()
getAllKeys()
.public static <K,V> KeyValueSource<K,V> fromMap(IMap<K,V> map)
IMap
K
- key type of the mapV
- value type of the mapmap
- map to build a KeyValueSource implementation withpublic static <K,V> KeyValueSource<K,V> fromMultiMap(MultiMap<K,V> multiMap)
MultiMap
K
- key type of the multiMapV
- value type of the multiMapmultiMap
- multiMap to build a KeyValueSource implementation withpublic static <V> KeyValueSource<String,V> fromList(IList<V> list)
IList
.V
- value type of the listlist
- list to build a KeyValueSource implementation withpublic static <V> KeyValueSource<String,V> fromSet(ISet<V> set)
ISet
.V
- value type of the setset
- set to build a KeyValueSource implementation withCopyright © 2014 Hazelcast, Inc.. All Rights Reserved.