|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.mrunit.TestDriver<K1,V1,K2,V2>
org.apache.hadoop.mrunit.ReduceDriverBase<K1,V1,K2,V2>
org.apache.hadoop.mrunit.mapreduce.ReduceDriver<K1,V1,K2,V2>
public class ReduceDriver<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 |
---|
Nested classes/interfaces inherited from class org.apache.hadoop.mrunit.ReduceDriverBase |
---|
ReduceDriverBase.ValueClassInstanceReuseList<T> |
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
LOG
|
Fields inherited from class org.apache.hadoop.mrunit.ReduceDriverBase |
---|
inputKey |
Fields inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
configuration, counterWrapper, expectedEnumCounters, expectedOutputs, expectedStringCounters |
Constructor Summary | |
---|---|
ReduceDriver()
|
|
ReduceDriver(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
|
Method Summary | ||
---|---|---|
org.apache.hadoop.mapreduce.Counters |
getCounters()
|
|
org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> |
getReducer()
|
|
static
|
newReduceDriver()
Returns a new ReduceDriver without having to specify the generic types on the right hand side of the object create statement. |
|
static
|
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. |
|
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> |
withConfiguration(org.apache.hadoop.conf.Configuration configuration)
|
|
ReduceDriver<K1,V1,K2,V2> |
withCounter(Enum e,
long expectedValue)
Register expected enumeration based counter value |
|
ReduceDriver<K1,V1,K2,V2> |
withCounter(String g,
String n,
long e)
Register expected name based counter value |
|
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(K1 key,
List<V1> values)
Identical to setInput() but returns self for fluent programming style |
|
ReduceDriver<K1,V1,K2,V2> |
withInputFromString(String input)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
|
ReduceDriver<K1,V1,K2,V2> |
withInputKey(K1 key)
Identical to setInputKey() but with fluent programming style |
|
ReduceDriver<K1,V1,K2,V2> |
withInputValue(V1 val)
Identical to addInputValue() but with fluent programming style |
|
ReduceDriver<K1,V1,K2,V2> |
withInputValues(List<V1> values)
Identical to addInputValues() but with fluent programming style |
|
ReduceDriver<K1,V1,K2,V2> |
withOutput(K2 key,
V2 val)
Works like addOutput(), but returns self for fluent style |
|
ReduceDriver<K1,V1,K2,V2> |
withOutput(Pair<K2,V2> outputRecord)
Works like addOutput(), but returns self for fluent style |
|
ReduceDriver<K1,V1,K2,V2> |
withOutputFromString(String output)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
|
ReduceDriver<K1,V1,K2,V2> |
withReducer(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
Identical to setReducer(), but with fluent programming style |
Methods inherited from class org.apache.hadoop.mrunit.ReduceDriverBase |
---|
addInputValue, addInputValues, addOutput, addOutput, addOutputFromString, getInputValues, runTest, setInput, setInputFromString, setInputKey, setInputValues |
Methods inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
formatValueList, getConfiguration, getExpectedEnumCounters, getExpectedOutputs, getExpectedStringCounters, parseCommaDelimitedList, parseTabbedPair, resetExpectedCounters, resetOutput, runTest, setConfiguration, validate, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
Constructor Detail |
---|
public ReduceDriver(org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> r)
public ReduceDriver()
Method Detail |
---|
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 use
public org.apache.hadoop.mapreduce.Reducer<K1,V1,K2,V2> getReducer()
public org.apache.hadoop.mapreduce.Counters getCounters()
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> withInputKey(K1 key)
public ReduceDriver<K1,V1,K2,V2> withInputValue(V1 val)
val
-
public ReduceDriver<K1,V1,K2,V2> withInputValues(List<V1> values)
values
-
public ReduceDriver<K1,V1,K2,V2> withInput(K1 key, List<V1> values)
key
- values
-
public ReduceDriver<K1,V1,K2,V2> withOutput(Pair<K2,V2> outputRecord)
outputRecord
-
public ReduceDriver<K1,V1,K2,V2> withOutput(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 ReduceDriver<K1,V1,K2,V2> withInputFromString(String input)
input
- A string of the form "key \t val". Trims any whitespace.
@Deprecated public ReduceDriver<K1,V1,K2,V2> withOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.
public List<Pair<K2,V2>> run() throws IOException
TestDriver
run
in class ReduceDriverBase<K1,V1,K2,V2>
IOException
public String toString()
toString
in class Object
public ReduceDriver<K1,V1,K2,V2> withConfiguration(org.apache.hadoop.conf.Configuration configuration)
configuration
- The configuration object that will given to the reducer associated
with the driver
public ReduceDriver<K1,V1,K2,V2> withCounter(Enum e, long expectedValue)
TestDriver
withCounter
in class TestDriver<K1,V1,K2,V2>
e
- Enumeration based counterexpectedValue
- Expected value
public ReduceDriver<K1,V1,K2,V2> withCounter(String g, String n, long e)
TestDriver
withCounter
in class TestDriver<K1,V1,K2,V2>
g
- Counter groupn
- Counter namee
- Expected value
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 constructor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |