com.hazelcast.mapreduce.impl
Class SetKeyValueSource<V>

java.lang.Object
  extended by com.hazelcast.mapreduce.KeyValueSource<String,V>
      extended by com.hazelcast.mapreduce.impl.SetKeyValueSource<V>
Type Parameters:
V - type of the values inside the ISet
All Implemented Interfaces:
DataSerializable, IdentifiedDataSerializable, Closeable

public class SetKeyValueSource<V>
extends KeyValueSource<String,V>
implements IdentifiedDataSerializable

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


Constructor Summary
SetKeyValueSource()
           
SetKeyValueSource(String setName)
           
 
Method Summary
 void close()
           
 Map.Entry<String,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.
 String 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 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

SetKeyValueSource

public SetKeyValueSource()

SetKeyValueSource

public SetKeyValueSource(String setName)
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<String,V>
Parameters:
nodeEngine - nodeEngine of this cluster node
Returns:
true if operation succeed otherwise false

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<String,V>
Returns:
true if at least one more key-value pair is available from this data source, false otherwise.

key

public String 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<String,V>
Returns:
the current index key for KeyPredicate analysis

element

public Map.Entry<String,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<String,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<String,V>
Returns:
true if reset was successful otherwise false

close

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

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.