|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.mapreduce.KeyValueSource<K,V>
K
- key typeV
- value type@Beta public abstract class KeyValueSource<K,V>
The abstract KeyValueSource class is used to implement custom data sources for mapreduce algorithms.
Default shipped implementations contains KeyValueSources for Hazelcast data structures like
IMap
and MultiMap
. Custom implementations could
be external files, URLs or any other data source can be visualized as key-value pairs.
Constructor Summary | |
---|---|
KeyValueSource()
|
Method Summary | ||
---|---|---|
abstract Map.Entry<K,V> |
element()
Returns the current index' element Calls to this method won't change state. |
|
static
|
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
|
fromMap(IMap<K,V> map)
A helper method to build a KeyValueSource implementation based on the specified IMap |
|
static
|
fromMultiMap(MultiMap<K,V> multiMap)
A helper method to build a KeyValueSource implementation based on the specified MultiMap |
|
static
|
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.io.Closeable |
---|
close |
Constructor Detail |
---|
public KeyValueSource()
Method Detail |
---|
public abstract boolean open(NodeEngine nodeEngine)
nodeEngine
- nodeEngine of this cluster node
public 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
.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 with
public 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 with
public static <V> KeyValueSource<String,V> fromList(IList<V> list)
IList
.
V
- value type of the listlist
- list to build a KeyValueSource implementation with
public static <V> KeyValueSource<String,V> fromSet(ISet<V> set)
ISet
.
V
- value type of the setset
- set to build a KeyValueSource implementation with
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |