Friday 15 August 2014

mapreduce - How to test a Mapper which emits key as null i.e. context.write(null, ); -



mapreduce - How to test a Mapper which emits key as null i.e. context.write(null, <somevalue>); -

i have mapreduce programme mapper , no reducer set. want test this. having below test code

@test public void testmapper() throws ioexception { mapdriver.withinput(new longwritable(0l), new text( "af00bac654249b9d27982f19064338f4,54.0258822077885,-1.56832133466378,20121022,105507,026542913532,2093,87")); mapdriver.withoutput(null, [some value]); mapdriver.runtest(); }

with phone call of mapdriver.withoutput(null, [some value]); line throwing below exception

java.lang.nullpointerexception @ org.apache.hadoop.mrunit.internal.io.serialization.copy(serialization.java:58) @ org.apache.hadoop.mrunit.internal.io.serialization.copy(serialization.java:91) @ org.apache.hadoop.mrunit.internal.io.serialization.copywithconf(serialization.java:104)

note: mapper generic signature mapper<longwritable, text, void, genericrecord>

could please allow me know how write test scenarios mapper emit null ?

if nullwritable.get getting exception below java.lang.nullpointerexception @ org.apache.hadoop.mrunit.internal.io.serialization.copy(serialization.java:73) @ org.apache.hadoop.mrunit.internal.io.serialization.copy(serialization.java:91) @ org.apache.hadoop.mrunit.internal.io.serialization.copywithconf(serialization.java:104) @ org.apache.hadoop.mrunit.testdriver.copy(testdriver.java:608) @ org.apache.hadoop.mrunit.testdriver.copypair(testdriver.java:612) @ org.apache.hadoop.mrunit.testdriver.addoutput(testdriver.java:118) @ org.apache.hadoop.mrunit.testdriver.withoutput(testdriver.java:138) @ com.gfk.gxl.etl.common.extractcsvtest.testmapper(extractcsvtest.java:73) @ sun.reflect.nativemethodaccessorimpl.invoke0(native method)

it seems more mrunit avro nullpointerexception in serialization reply not solving problem

few more research have below update class org.apache.avro.generic.genericdata$record not able serializer , deserializer in org.apache.hadoop.mrunit.internal.io.serialization , both coming null causing null pointer exception api code snippet org.apache.hadoop.mrunit.internal.io.serialization starting @ line no 61 70 seek { serializer = (serializer<object>) serializationfactory .getserializer(clazz); deserializer = (deserializer<object>) serializationfactory .getdeserializer(clazz); } grab (nullpointerexception e) { throw new illegalstateexception( "no applicable class implementing serialization in conf @ io.serializations " + orig.getclass(), e); } above method serializer \ deserializer coming null . have way avoid

use nullwritable.get() method insted.hope helps.

mapreduce mrunit

No comments:

Post a Comment