com.hazelcast.mapreduce.impl.task
Class DefaultContext<KeyIn,ValueIn>

java.lang.Object
  extended by com.hazelcast.mapreduce.impl.task.DefaultContext<KeyIn,ValueIn>
Type Parameters:
KeyIn -
ValueIn -
All Implemented Interfaces:
Context<KeyIn,ValueIn>

public class DefaultContext<KeyIn,ValueIn>
extends Object
implements Context<KeyIn,ValueIn>

This is the internal default implementation of a map reduce context mappers emit values to. It controls the emitted values to be combined using either the set Combiner or by utilizing the internal collecting combiner (which is just a better HashMap ;-)).
In addition to that it is responsible to notify about an the MapCombineTask about an emitted value to eventually send out chunks on reaching the chunk size limit.


Constructor Summary
protected DefaultContext(CombinerFactory<KeyIn,ValueIn,?> combinerFactory, MapCombineTask mapCombineTask)
           
 
Method Summary
 void emit(KeyIn key, ValueIn value)
          Emits a key-value pair to the intermediate working space.
<Chunk> Map<KeyIn,Chunk>
finish()
           
 int getCollected()
           
 Combiner<ValueIn,?> getOrCreateCombiner(KeyIn key)
           
<Chunk> Map<KeyIn,Chunk>
requestChunk()
           
 void setPartitionId(int partitionId)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultContext

protected DefaultContext(CombinerFactory<KeyIn,ValueIn,?> combinerFactory,
                         MapCombineTask mapCombineTask)
Method Detail

setPartitionId

public void setPartitionId(int partitionId)

emit

public void emit(KeyIn key,
                 ValueIn value)
Description copied from interface: Context
Emits a key-value pair to the intermediate working space. The same key can be used multiple times to collect values under the same key.

Specified by:
emit in interface Context<KeyIn,ValueIn>
Parameters:
key - emitted key.
value - emitted value.

requestChunk

public <Chunk> Map<KeyIn,Chunk> requestChunk()

getCollected

public int getCollected()

finish

public <Chunk> Map<KeyIn,Chunk> finish()

getOrCreateCombiner

public Combiner<ValueIn,?> getOrCreateCombiner(KeyIn key)


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