|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.hadoop.mrunit.TestDriver<K1,V1,K2,V2> org.apache.hadoop.mrunit.ReduceDriverBase<K1,V1,K2,V2>
public abstract class ReduceDriverBase<K1,V1,K2,V2>
Harness that allows you to test a Reducer instance. You provide a key and a set of intermediate values for that key that represent inputs that should be sent to the Reducer (as if they came from a Mapper), and outputs you expect to be sent by the Reducer to the collector. By calling runTest(), the harness will deliver the input to the Reducer and will check its outputs against the expected results. This is designed to handle a single (k, v*) -> (k, v)* case from the Reducer, representing a single unit test. Multiple input (k, v*) sets should go in separate unit tests.
Nested Class Summary | |
---|---|
protected static class |
ReduceDriverBase.ValueClassInstanceReuseList<T>
|
Field Summary | |
---|---|
protected K1 |
inputKey
|
Fields inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
configuration, counterWrapper, expectedEnumCounters, expectedOutputs, expectedStringCounters, LOG |
Constructor Summary | |
---|---|
ReduceDriverBase()
|
Method Summary | |
---|---|
void |
addInputValue(V1 val)
adds an input value to send to the reducer |
void |
addInputValues(List<V1> values)
Adds a set of input values to send to the reducer |
void |
addOutput(K2 key,
V2 val)
Adds an output (k, v) pair we expect from the Reducer |
void |
addOutput(Pair<K2,V2> outputRecord)
Adds an output (k, v) pair we expect from the Reducer |
void |
addOutputFromString(String output)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
List<V1> |
getInputValues()
Returns a list which when iterated over, returns the same instance of the value each time with different contents similar to how Hadoop currently works with Writables. |
abstract 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 |
runTest(boolean orderMatters)
Runs the test and validates the results |
void |
setInput(K1 key,
List<V1> values)
Sets the input to send to the reducer |
void |
setInputFromString(String input)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
void |
setInputKey(K1 key)
Sets the input key to send to the Reducer |
void |
setInputValues(List<V1> values)
Sets the input values to send to the reducer; overwrites existing ones |
Methods inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
formatValueList, getConfiguration, getExpectedEnumCounters, getExpectedOutputs, getExpectedStringCounters, parseCommaDelimitedList, parseTabbedPair, resetExpectedCounters, resetOutput, runTest, setConfiguration, validate, validate, withCounter, withCounter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected K1 inputKey
Constructor Detail |
---|
public ReduceDriverBase()
Method Detail |
---|
public List<V1> getInputValues()
public void setInputKey(K1 key)
public void addInputValue(V1 val)
val
- public void setInputValues(List<V1> values)
values
- public void addInputValues(List<V1> values)
values
- public void setInput(K1 key, List<V1> values)
key
- values
- public void addOutput(Pair<K2,V2> outputRecord)
outputRecord
- The (k, v) pair to addpublic void addOutput(K2 key, V2 val)
key
- The key part of a (k, v) pair to addval
- The val part of a (k, v) pair to add@Deprecated public void setInputFromString(String input)
input
- A string of the form "key \t val,val,val". Trims any whitespace.@Deprecated public void addOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.public abstract List<Pair<K2,V2>> run() throws IOException
TestDriver
run
in class TestDriver<K1,V1,K2,V2>
IOException
public void runTest(boolean orderMatters)
TestDriver
runTest
in class TestDriver<K1,V1,K2,V2>
orderMatters
- Whether or not output ordering is important
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |