com.hazelcast.mapreduce
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 that 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
Calls to this method won't change state.
|
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 the 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 the set, one by one. |
Collection<K> |
getAllKeys()
If
isAllKeysSupported() returns true, a call to this method returns
all clusterwide available keys. |
protected Collection<K> |
getAllKeys0()
This method is meant to be overridden to implement collecting of all clusterwide available keys
and return 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 returns 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 resets all internal state to be a new instance.
|
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.
Calls to this method won't change state.KeyPredicate
analysispublic abstract Map.Entry<K,V> element()
public abstract boolean reset()
PartitionIdAware
.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 returns
all clusterwide available keys. If there is no chance to precollect all keys due to
partitioning of the data isAllKeysSupported()
, this method returns 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 returns 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 implementationpublic 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 implementationpublic static <V> KeyValueSource<String,V> fromList(IList<V> list)
IList
.V
- value type of the listlist
- list to build a KeyValueSource implementationpublic static <V> KeyValueSource<String,V> fromSet(ISet<V> set)
ISet
.V
- value type of the setset
- set to build a KeyValueSource implementationCopyright © 2015 Hazelcast, Inc.. All Rights Reserved.