hadoop - MapReduce output as ArrayList -
how call map reduce method in normal java project , possible return reducer output arraylist / hashmap instead of flat file, , how access mapreduce method jboss appserver.
here sample program uses multipleoutput
public void reduce(text key, iterator<intwritable> values, outputcollector<text, intwritable> output, reporter reporter) throws ioexception { int total = 0; (; values.hasnext();) { total += values.next().get(); mos.getcollector("text", reporter).collect(key, new intwritable(total)); mos.getcollector("seq", reporter).collect(key, new intwritable(total)); } }
you need create multipleoutputs instance in configure method.
private multipleoutputs mos; @override public void configure(jobconf job) { mos = new multipleoutputs(job); }
in driver class need tell inputformats want use. below generate output in text , sequence file formats.
// defines additional single text based output 'text' job multipleoutputs.addnamedoutput(conf, "text", textoutputformat.class, text.class, intwritable.class); // defines additional sequence-file based output 'sequence' job multipleoutputs.addnamedoutput(conf, "seq", sequencefileoutputformat.class, text.class, intwritable.class);
but understood question, want access mapreduce output code. may download output file using hdfs api. better put data in hive table , access using jdbc.
Comments
Post a Comment