KEYIN
- Input keyVALUEIN
- Input valueKEYOUT
- Output keyVALUEOUT
- Output valuepublic class CollectiveMapper<KEYIN,VALUEIN,KEYOUT,VALUEOUT>
extends <any>
Modifier and Type | Class and Description |
---|---|
protected class |
CollectiveMapper.KeyValReader
A Key-Value reader to read key-value inputs
for this worker.
|
Modifier and Type | Field and Description |
---|---|
protected static Log |
LOG |
Constructor and Description |
---|
CollectiveMapper() |
Modifier and Type | Method and Description |
---|---|
<P extends Simple> |
allgather(java.lang.String contextName,
java.lang.String operationName,
Table<P> table)
Allgather partitions of the tables to all the
local tables.
|
<P extends Simple> |
allreduce(java.lang.String contextName,
java.lang.String operationName,
Table<P> table)
Allreduce partitions of the tables to all the
local tables.
|
boolean |
barrier(java.lang.String contextName,
java.lang.String operationName)
Synchronize workers through a barrier
|
<P extends Simple> |
broadcast(java.lang.String contextName,
java.lang.String operationName,
Table<P> table,
int bcastWorkerID,
boolean useMSTBcast)
Broadcast the partitions of the table on a
worker to other workers.
|
protected void |
cleanup(Context context)
Called once at the end of the task.
|
protected void |
freeConn()
Free the connections cached in the pool.
|
protected void |
freeMemory()
Free the objects cached in the pool.
|
Event |
getEvent()
Get an event from the event queue.
|
int |
getMasterID()
Get the ID of the master worker.
|
int |
getMaxID()
Get the maximum worker ID
|
int |
getMinID()
Get the minimum worker ID.
|
int |
getNumWorkers()
Get the total number of workers.
|
int |
getSelfID()
Get the ID of this worker.
|
boolean |
isMaster()
Check if this worker is the master worker.
|
protected void |
logGCTime()
Log Garbage collection time
|
protected void |
logMemUsage()
Log memory usage
|
protected void |
mapCollective(CollectiveMapper.KeyValReader reader,
Context context)
Most applications should override this.
|
<P extends Simple> |
pull(java.lang.String contextName,
java.lang.String operationName,
Table<P> localTable,
Table<P> globalTable,
boolean useBcast)
Pull partitions in the global table to the
local tables.
|
<P extends Simple,PT extends Partitioner> |
push(java.lang.String contextName,
java.lang.String operationName,
Table<P> localTable,
Table<P> globalTable,
PT partitioner)
Push the partitions of local tables to the
global table.
|
<P extends Simple> |
reduce(java.lang.String contextName,
java.lang.String operationName,
Table<P> table,
int reduceWorkerID)
Reduce the partitions of the tables to one of
them.
|
<P extends Simple,PT extends Partitioner> |
regroup(java.lang.String contextName,
java.lang.String operationName,
Table<P> table,
PT partitioner)
Regroup the partitions of the tables based on
a partitioner.
|
<P extends Simple> |
rotate(java.lang.String contextName,
java.lang.String operationName,
Table<P> globalTable,
Int2IntMap rotateMap)
The rotation communication.
|
void |
run(Context context)
Override this method to support collective
communications among Mappers
|
boolean |
sendEvent(Event event)
Send an event to the local (local event), to
a remote worker (message event), or to the
rest workers (collective event).
|
protected void |
setup(Context context)
Called once at the beginning of the task.
|
Event |
waitEvent()
Wait for an event from the queue
|
public int getSelfID()
public int getMasterID()
public boolean isMaster()
public int getNumWorkers()
public int getMinID()
public int getMaxID()
public boolean barrier(java.lang.String contextName, java.lang.String operationName)
contextName
- operationName
- public <P extends Simple> boolean broadcast(java.lang.String contextName, java.lang.String operationName, Table<P> table, int bcastWorkerID, boolean useMSTBcast)
contextName
- the name of the operation contextoperationName
- the name of the operationtable
- the table used to hold the
partitionsbcastWorkerID
- the worker ID of broadcasting datauseMSTBcast
- if minimum-spanning tree algorithm
is usedpublic <P extends Simple> boolean reduce(java.lang.String contextName, java.lang.String operationName, Table<P> table, int reduceWorkerID)
contextName
- the name of the operation contextoperationName
- the name of the operationtable
- the table to hold the partitionsreduceWorkerID
- the worker ID for reduce operationpublic <P extends Simple> boolean allgather(java.lang.String contextName, java.lang.String operationName, Table<P> table)
contextName
- the name of the operation contextoperationName
- the name of the operationtable
- the table to hold the partitionspublic <P extends Simple> boolean allreduce(java.lang.String contextName, java.lang.String operationName, Table<P> table)
contextName
- the name of the operation contextoperationName
- the name of the operationtable
- the table to hold the partitionspublic <P extends Simple,PT extends Partitioner> boolean regroup(java.lang.String contextName, java.lang.String operationName, Table<P> table, PT partitioner)
contextName
- the name of the operation contextoperationName
- the name of the operationtable
- the table to hold the partitionspartitioner
- a boolean tells if the operations
succeedspublic <P extends Simple> boolean pull(java.lang.String contextName, java.lang.String operationName, Table<P> localTable, Table<P> globalTable, boolean useBcast)
contextName
- the name of the operation contextoperationName
- the name of the operationlocalTable
- the local tablesglobalTable
- the global table, acts like a
distributed datasetuseBcast
- if using broadcast in scattering the
partitionspublic <P extends Simple,PT extends Partitioner> boolean push(java.lang.String contextName, java.lang.String operationName, Table<P> localTable, Table<P> globalTable, PT partitioner)
contextName
- the name of the operation contextoperationName
- the name of operationlocalTable
- the local tablesglobalTable
- the global table which acts like a
distributed dataset, each partition
in this table is uniquepartitioner
- when a partiitoner is used, the
local partitions are sent to the
global table even without partiiton
ID associationpublic <P extends Simple> boolean rotate(java.lang.String contextName, java.lang.String operationName, Table<P> globalTable, Int2IntMap rotateMap)
contextName
- the name of the operation contextoperationName
- the name of operationglobalTable
- the global table which acts like a
distributed dataset, each partition
in this table is uniquerotateMap
- the map from worker to worker,
defines how to rotate the datapublic Event getEvent()
public Event waitEvent()
public boolean sendEvent(Event event)
event
- an eventprotected void freeMemory()
protected void freeConn()
protected void logMemUsage()
protected void logGCTime()
protected void setup(Context context) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
protected void mapCollective(CollectiveMapper.KeyValReader reader, Context context) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
protected void cleanup(Context context) throws java.io.IOException, java.lang.InterruptedException
java.io.IOException
java.lang.InterruptedException
public void run(Context context) throws java.io.IOException, java.lang.InterruptedException
context
- the contextjava.io.IOException
java.lang.InterruptedException