com.hazelcast.mapreduce.impl
Class MultiMapKeyValueSource<K,V>

java.lang.Object
  extended by com.hazelcast.mapreduce.KeyValueSource<K,V>
      extended by com.hazelcast.mapreduce.impl.MultiMapKeyValueSource<K,V>
Type Parameters:
K - type of the key of the MultiMap
V - type of the value of the MultiMap
All Implemented Interfaces:
PartitionIdAware, DataSerializable, IdentifiedDataSerializable, Closeable

public class MultiMapKeyValueSource<K,V>
extends KeyValueSource<K,V>
implements IdentifiedDataSerializable, PartitionIdAware

This KeyValueSource implementation is used in KeyValueSource.fromMultiMap(com.hazelcast.core.MultiMap) to generate a default implementation based on a Hazelcast MultiMap.


Constructor Summary
MultiMapKeyValueSource(String multiMapName)
           
 
Method Summary
 void close()
           
 Map.Entry<K,V> element()
          Returns the current index' element Calls to this method won't change state.
 int getFactoryId()
          Returns DataSerializableFactory factory id for this class.
 int getId()
          Returns type identifier for this class.
 boolean hasNext()
          Called to request if at least one more key-value pair is available from this data source.
 K key()
          Returns the current index' key for KeyPredicate analysis.
 boolean open(NodeEngine nodeEngine)
          This method is called before accessing the key-value pairs of this KeyValueSource
 void readData(ObjectDataInput in)
          Reads fields from the input stream
 boolean reset()
          This method need to reset all internal state as it would be a new instance at all.
 void setPartitionId(int partitionId)
          Sets the partition id the implementing instance is executed against
 void writeData(ObjectDataOutput out)
          Writes object fields to output stream
 
Methods inherited from class com.hazelcast.mapreduce.KeyValueSource
fromList, fromMap, fromMultiMap, fromSet, getAllKeys, getAllKeys0, isAllKeysSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultiMapKeyValueSource

public MultiMapKeyValueSource(String multiMapName)
Method Detail

open

public boolean open(NodeEngine nodeEngine)
Description copied from class: KeyValueSource
This method is called before accessing the key-value pairs of this KeyValueSource

Specified by:
open in class KeyValueSource<K,V>
Parameters:
nodeEngine - nodeEngine of this cluster node
Returns:
true if operation succeed otherwise false

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException

hasNext

public boolean hasNext()
Description copied from class: KeyValueSource
Called to request if at least one more key-value pair is available from this data source. If so this method returns true otherwise it false. Calls to this method will change the state, more specifically if an element is found, the index will be set to the found element. Subsequent calls to the key() and element() methods will return that element.

Specified by:
hasNext in class KeyValueSource<K,V>
Returns:
true if at least one more key-value pair is available from this data source, false otherwise.

key

public K key()
Description copied from class: KeyValueSource
Returns the current index' key for 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.

Specified by:
key in class KeyValueSource<K,V>
Returns:
the current index key for KeyPredicate analysis

element

public Map.Entry<K,V> element()
Description copied from class: KeyValueSource
Returns the current index' element Calls to this method won't change state.

Specified by:
element in class KeyValueSource<K,V>
Returns:
the current index element

reset

public boolean reset()
Description copied from class: KeyValueSource
This method need to reset all internal state as it would be a new instance at all. The same instance of the KeyValueSource may be used multiple times in a row depending on the internal implementation, especially when the KeyValueSource implements PartitionIdAware.
If the instance is reused a sequence of KeyValueSource.reset(), KeyValueSource.open(com.hazelcast.spi.NodeEngine) and Closeable.close() is called multiple times with the other methods between open(...) and close().

Specified by:
reset in class KeyValueSource<K,V>
Returns:
true if reset was successful otherwise false

setPartitionId

public void setPartitionId(int partitionId)
Description copied from interface: PartitionIdAware
Sets the partition id the implementing instance is executed against

Specified by:
setPartitionId in interface PartitionIdAware
Parameters:
partitionId - current partitionId

writeData

public void writeData(ObjectDataOutput out)
               throws IOException
Description copied from interface: DataSerializable
Writes object fields to output stream

Specified by:
writeData in interface DataSerializable
Parameters:
out - output
Throws:
IOException

readData

public void readData(ObjectDataInput in)
              throws IOException
Description copied from interface: DataSerializable
Reads fields from the input stream

Specified by:
readData in interface DataSerializable
Parameters:
in - input
Throws:
IOException

getFactoryId

public int getFactoryId()
Description copied from interface: IdentifiedDataSerializable
Returns DataSerializableFactory factory id for this class.

Specified by:
getFactoryId in interface IdentifiedDataSerializable
Returns:
factory id

getId

public int getId()
Description copied from interface: IdentifiedDataSerializable
Returns type identifier for this class. Id should be unique per DataSerializableFactory.

Specified by:
getId in interface IdentifiedDataSerializable
Returns:
type id


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