dictionary - Pig Convert tuple data to map? -
hello can guide on conversion of tuple data map using pig?
i have data
2013-09-24 19:58:04.440 server120 trsid=20,rid=e7a8-244ce04-03b6k8962890k,extid=e7a8a921-244c-e043-03b6k8962890k
i tried convert data map below. how not able convert data map, resulting in tupletomapfailed
error.
package mymapudf; import java.io.ioexception; import org.apache.pig.evalfunc; import java.util.map; import java.util.map.entry; import org.apache.pig.data.tuple; public class udfmap extends evalfunc<map> { public map exec(tuple input) throws ioexception { try { //tabag values = (databag)input.get(1); //string value = (string)input.get(1); //map<object, object> m = new hashmap<object, object>(); map<string,string> m2 = (map<string, string>) input.get(1); (entry<string, string> entry:m2.entryset()) { m2.put(entry.getkey(),entry.getvalue()); //tuple tuple = tuplefactory.newtuple(2); } return m2; } catch(exception e) { throw new runtimeexception("tupletomapfailed error", e); } } }
please provide suggestions on achieving needed map conversion remaining data leaving timestamp ?
schema:
data_load = load '/user/uk01/test.log' using pigstorage(' ') ( dt:chararray, nodes:tuple(servername:chararray,tris:chararray,extid:chararray)); gen_test = foreach data_load generate mymapudf.udf(nodes);
pig stack trace:
error 2999: unexpected internal error. tupletomapfailed error java.lang.runtimeexception: tupletomapfailed error @ mymapudf.udfmap.exec(udfmap.java:30) @ mymapudf.udfmap.exec(udfmap.java:1) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.expressionoperators.pouserfunc.getnext(pouserfunc.java:337) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.expressionoperators.pouserfunc.getnext(pouserfunc.java:428) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.physicaloperator.getnext(physicaloperator.java:352) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.relationaloperators.poforeach.processplan(poforeach.java:372) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.relationaloperators.poforeach.getnext(poforeach.java:297) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.physicaloperator.processinput(physicaloperator.java:308) @ org.apache.pig.backend.hadoop.executionengine.physicallayer.relationaloperators.pofilter.getnext(pofilter.java:95)
Comments
Post a Comment