|
||||||||||
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.MapDriverBase<K1,V1,K2,V2>
org.apache.hadoop.mrunit.MapDriver<K1,V1,K2,V2>
public class MapDriver<K1,V1,K2,V2>
Harness that allows you to test a Mapper instance. You provide the input key and value that should be sent to the Mapper, and outputs you expect to be sent by the Mapper to the collector for those inputs. By calling runTest(), the harness will deliver the input to the Mapper and will check its outputs against the expected results. This is designed to handle a single (k, v) -> (k, v)* case from the Mapper, representing a single unit test. Multiple input (k, v) pairs should go in separate unit tests.
Field Summary | |
---|---|
static org.apache.commons.logging.Log |
LOG
|
Fields inherited from class org.apache.hadoop.mrunit.MapDriverBase |
---|
inputKey, inputVal |
Fields inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
configuration, counterWrapper, expectedEnumCounters, expectedOutputs, expectedStringCounters |
Constructor Summary | |
---|---|
MapDriver()
|
|
MapDriver(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> m)
|
Method Summary | ||
---|---|---|
org.apache.hadoop.mapred.Counters |
getCounters()
|
|
org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> |
getMapper()
|
|
static
|
newMapDriver()
Returns a new MapDriver without having to specify the generic types on the right hand side of the object create statement. |
|
static
|
newMapDriver(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> mapper)
Returns a new MapDriver 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.mapred.Counters ctrs)
Sets the counters object to use for this test. |
|
void |
setMapper(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> m)
Set the Mapper instance to use with this test driver |
|
String |
toString()
|
|
MapDriver<K1,V1,K2,V2> |
withConfiguration(org.apache.hadoop.conf.Configuration configuration)
|
|
MapDriver<K1,V1,K2,V2> |
withCounter(Enum e,
long expectedValue)
Register expected enumeration based counter value |
|
MapDriver<K1,V1,K2,V2> |
withCounter(String g,
String n,
long expectedValue)
Register expected name based counter value |
|
MapDriver<K1,V1,K2,V2> |
withCounters(org.apache.hadoop.mapred.Counters ctrs)
Sets the counters to use and returns self for fluent style |
|
MapDriver<K1,V1,K2,V2> |
withInput(K1 key,
V1 val)
Identical to setInput() but returns self for fluent programming style |
|
MapDriver<K1,V1,K2,V2> |
withInput(Pair<K1,V1> inputRecord)
Identical to setInput() but returns self for fluent programming style |
|
MapDriver<K1,V1,K2,V2> |
withInputFromString(String input)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
|
MapDriver<K1,V1,K2,V2> |
withInputKey(K1 key)
Identical to setInputKey() but with fluent programming style |
|
MapDriver<K1,V1,K2,V2> |
withInputValue(V1 val)
Identical to setInputValue() but with fluent programming style |
|
MapDriver<K1,V1,K2,V2> |
withMapper(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> m)
Sets the Mapper instance to use and returns self for fluent style |
|
MapDriver<K1,V1,K2,V2> |
withOutput(K2 key,
V2 val)
Functions like addOutput() but returns self for fluent programming style |
|
MapDriver<K1,V1,K2,V2> |
withOutput(Pair<K2,V2> outputRecord)
Works like addOutput(), but returns self for fluent style |
|
MapDriver<K1,V1,K2,V2> |
withOutputFromString(String output)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
Methods inherited from class org.apache.hadoop.mrunit.MapDriverBase |
---|
addOutput, addOutput, addOutputFromString, getInputKey, getInputValue, runTest, setInput, setInput, setInputFromString, setInputKey, setInputValue |
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 MapDriver(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> m)
public MapDriver()
Method Detail |
---|
public org.apache.hadoop.mapred.Counters getCounters()
public void setCounters(org.apache.hadoop.mapred.Counters ctrs)
ctrs
- The counters object to use.public MapDriver<K1,V1,K2,V2> withCounters(org.apache.hadoop.mapred.Counters ctrs)
public void setMapper(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> m)
m
- the Mapper instance to usepublic MapDriver<K1,V1,K2,V2> withMapper(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> m)
public org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> getMapper()
public MapDriver<K1,V1,K2,V2> withInputKey(K1 key)
public MapDriver<K1,V1,K2,V2> withInputValue(V1 val)
val
-
public MapDriver<K1,V1,K2,V2> withInput(K1 key, V1 val)
public MapDriver<K1,V1,K2,V2> withInput(Pair<K1,V1> inputRecord)
inputRecord
-
public MapDriver<K1,V1,K2,V2> withOutput(Pair<K2,V2> outputRecord)
outputRecord
-
public MapDriver<K1,V1,K2,V2> withOutput(K2 key, V2 val)
@Deprecated public MapDriver<K1,V1,K2,V2> withInputFromString(String input)
input
- A string of the form "key \t val". Trims any whitespace.
@Deprecated public MapDriver<K1,V1,K2,V2> withOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.
public MapDriver<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 MapDriver<K1,V1,K2,V2> withCounter(String g, String n, long expectedValue)
TestDriver
withCounter
in class TestDriver<K1,V1,K2,V2>
g
- Counter groupn
- Counter nameexpectedValue
- Expected value
public List<Pair<K2,V2>> run() throws IOException
TestDriver
run
in class MapDriverBase<K1,V1,K2,V2>
IOException
public String toString()
toString
in class Object
public MapDriver<K1,V1,K2,V2> withConfiguration(org.apache.hadoop.conf.Configuration configuration)
configuration
- The configuration object that will given to the mapper associated
with the driver
public static <K1,V1,K2,V2> MapDriver<K1,V1,K2,V2> newMapDriver()
public static <K1,V1,K2,V2> MapDriver<K1,V1,K2,V2> newMapDriver(org.apache.hadoop.mapred.Mapper<K1,V1,K2,V2> mapper)
mapper
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |