public abstract class MapReduceAlgorithm
extends java.lang.Thread
Red (cxh) |
Red (cxh) |
Modifier and Type | Field and Description |
---|---|
java.lang.String |
reduceKey
The key for the reduce algorithm, which should be set externally.
|
java.util.List<java.lang.String> |
reduceOutput
The list generated by the reduce algorithm, which should be read
externally.
|
java.util.concurrent.BlockingQueue<java.lang.String> |
reduceValues
The values for the reduce algorithm, which should be set externally.
|
Constructor and Description |
---|
MapReduceAlgorithm() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
isQueueEmpty()
Return true if no more elements will be added to the list.
|
boolean |
isReduceFinished()
Return true if the reduce is finished.
|
abstract java.util.List<KeyValuePair> |
map(java.lang.String key,
java.lang.String value)
Subclasses should implement their map method here.
|
abstract java.util.List<java.lang.String> |
reduce(java.lang.String key,
java.util.concurrent.BlockingQueue<java.lang.String> values)
Subclasses should implement their reduce method here,
calling the take method of the BlockingQueue to get
the next value, and checking the parameter noMoreInputs
to test if no more values can be put on the queue.
|
void |
run()
This is used to call the reduce algorithm.
|
void |
setNoMoreInputs()
Set this true when no more inputs values will be given to the
reduce method queue.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public java.lang.String reduceKey
public java.util.concurrent.BlockingQueue<java.lang.String> reduceValues
public java.util.List<java.lang.String> reduceOutput
public boolean isReduceFinished() throws IllegalActionException
IllegalActionException
- If there was a thread error.public abstract java.util.List<KeyValuePair> map(java.lang.String key, java.lang.String value)
key
- The key passed to the map method.value
- The value passed to the map method.public abstract java.util.List<java.lang.String> reduce(java.lang.String key, java.util.concurrent.BlockingQueue<java.lang.String> values) throws java.lang.InterruptedException
key
- The key to reduce over.values
- The queue of values in reduction.java.lang.InterruptedException
- If thrown while reducing.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void setNoMoreInputs()
protected boolean isQueueEmpty()