@PrepareForTest(value=org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.class) public class ReduceDriver<K1,V1,K2,V2> extends ReduceDriverBase<K1,V1,K2,V2,ReduceDriver<K1,V1,K2,V2>> implements org.apache.hadoop.mrunit.internal.mapreduce.ContextDriver
ReduceDriverBase.ValueClassInstanceReuseList<T>
Modifier and Type | Field and Description |
---|---|
protected List<KeyValueReuseList<K1,V1>> |
groupedInputs |
static org.apache.commons.logging.Log |
LOG |
protected org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> |
myReducer |
inputKey, inputs, mockOutputCreator
counterWrapper, expectedEnumCounters, expectedMultipleOutputs, expectedOutputs, expectedPathOutputs, expectedStringCounters, mos
Constructor and Description |
---|
ReduceDriver() |
ReduceDriver(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r) |
Modifier and Type | Method and Description |
---|---|
void |
addAllElements(List<KeyValueReuseList<K1,V1>> inputs)
Adds input to send to the Reducer
|
void |
addInput(KeyValueReuseList<K1,V1> input)
Add input (K*, V*) to send to the Reducer
|
void |
clearInput()
Clears the input to be sent to the Reducer
|
org.apache.hadoop.mapreduce.Reducer.Context |
getContext()
Obtain Context object for furthering mocking with Mockito.
|
org.apache.hadoop.mapreduce.Counters |
getCounters() |
List<Pair<K1,V1>> |
getInputs(K1 firstKey) |
org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> |
getReducer() |
static <K1,V1,K2,V2> |
newReduceDriver()
Returns a new ReduceDriver without having to specify the generic types on
the right hand side of the object create statement.
|
static <K1,V1,K2,V2> |
newReduceDriver(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> reducer)
Returns a new ReduceDriver without having to specify the generic types on
the right hand side of the object create statement.
|
protected void |
preRunChecks(Object reducer)
Handle inputKey and inputValues and inputs for backwards compatibility.
|
protected void |
printPreTestDebugLog()
Overridable hook for printing pre-test debug information
|
List<Pair<K2,V2>> |
run()
Runs the test but returns the result set instead of validating it (ignores
any addOutput(), etc calls made before this)
|
void |
setCounters(org.apache.hadoop.mapreduce.Counters ctrs)
Sets the counters object to use for this test.
|
void |
setReducer(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
Sets the reducer object to use for this test
|
String |
toString() |
ReduceDriver<K1,V1,K2,V2> |
withAllElements(List<KeyValueReuseList<K1,V1>> inputs)
Identical to addAllElements() but returns self for fluent programming style
|
ReduceDriver<K1,V1,K2,V2> |
withCounters(org.apache.hadoop.mapreduce.Counters ctrs)
Sets the counters to use and returns self for fluent style
|
ReduceDriver<K1,V1,K2,V2> |
withInput(KeyValueReuseList<K1,V1> input)
Identical to addInput() but returns self for fluent programming style
|
ReduceDriver<K1,V1,K2,V2> |
withOutputFormat(Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass,
Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass)
Configure
Reducer to output with a real OutputFormat . |
ReduceDriver<K1,V1,K2,V2> |
withReducer(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
Identical to setReducer(), but with fluent programming style
|
addAll, addInput, addInput, addInputValue, addInputValues, getInputValues, getInputValues, setInput, setInputFromString, setInputKey, setInputValues, withAll, withInput, withInput, withInputFromString, withInputKey, withInputValue, withInputValues
addAllOutput, addCacheArchive, addCacheArchive, addCacheFile, addCacheFile, addMultiOutput, addMultiOutput, addOutput, addOutput, addOutputFromString, cleanupDistributedCache, copy, copyPair, driverReused, formatPairList, formatValueList, getConfiguration, getExpectedEnumCounters, getExpectedOutputs, getExpectedStringCounters, getKeyComparator, getOutputSerializationConfiguration, getValueComparator, initDistributedCache, parseCommaDelimitedList, parseTabbedPair, resetExpectedCounters, resetOutput, run, runTest, runTest, setCacheArchives, setCacheFiles, setConfiguration, setKeyComparator, setOutputSerializationConfiguration, setUsedOnceStatus, setValueComparator, thisAsTestDriver, validate, validate, validate, validateOutputList, withAllOutput, withCacheArchive, withCacheArchive, withCacheFile, withCacheFile, withConfiguration, withCounter, withCounter, withMultiOutput, withMultiOutput, withOutput, withOutput, withOutputFromString, withOutputSerializationConfiguration, withPathOutput, withPathOutput, withStrictCounterChecking
protected List<KeyValueReuseList<K1,V1>> groupedInputs
public static final org.apache.commons.logging.Log LOG
public void clearInput()
clearInput
in class ReduceDriverBase<K1,V1,K2,V2,ReduceDriver<K1,V1,K2,V2>>
public void addInput(KeyValueReuseList<K1,V1> input)
input
- public ReduceDriver<K1,V1,K2,V2> withInput(KeyValueReuseList<K1,V1> input)
input
- public ReduceDriver<K1,V1,K2,V2> withAllElements(List<KeyValueReuseList<K1,V1>> inputs)
inputs
- public void addAllElements(List<KeyValueReuseList<K1,V1>> inputs)
inputs
- list of (K*, V*) pairsprotected void printPreTestDebugLog()
TestDriver
printPreTestDebugLog
in class ReduceDriverBase<K1,V1,K2,V2,ReduceDriver<K1,V1,K2,V2>>
public void setReducer(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
r
- The reducer object to usepublic ReduceDriver<K1,V1,K2,V2> withReducer(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
r
- The Reducer to usepublic org.apache.hadoop.mapreduce.Counters getCounters()
getCounters
in interface org.apache.hadoop.mrunit.internal.mapreduce.ContextDriver
public void setCounters(org.apache.hadoop.mapreduce.Counters ctrs)
ctrs
- The counters object to use.public ReduceDriver<K1,V1,K2,V2> withCounters(org.apache.hadoop.mapreduce.Counters ctrs)
public ReduceDriver<K1,V1,K2,V2> withOutputFormat(Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass, Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass)
Reducer
to output with a real OutputFormat
. Set
InputFormat
to read output back in for use with run* methodsoutputFormatClass
- inputFormatClass
- protected void preRunChecks(Object reducer)
preRunChecks
in class ReduceDriverBase<K1,V1,K2,V2,ReduceDriver<K1,V1,K2,V2>>
public List<Pair<K2,V2>> run() throws IOException
TestDriver
run
in class ReduceDriverBase<K1,V1,K2,V2,ReduceDriver<K1,V1,K2,V2>>
IOException
public org.apache.hadoop.mapreduce.Reducer.Context getContext()
Obtain Context object for furthering mocking with Mockito. For example, causing write() to throw an exception:
import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; doThrow(new IOException()).when(context).write(any(), any());
Or implement other logic:
import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; doAnswer(new Answer
public static <K1,V1,K2,V2> ReduceDriver<K1,V1,K2,V2> newReduceDriver()
public static <K1,V1,K2,V2> ReduceDriver<K1,V1,K2,V2> newReduceDriver(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> reducer)
reducer
- passed to ReduceDriver constructorCopyright © 2014 The Apache Software Foundation. All Rights Reserved.