java - Join Operation using Map reduce : Not getting anything in output -


just learning purpose trying perform join operation on 2 files common value id. wrote map reduce code doing same getting empty output files. can 1 take @ code , me in solving issues or post new code same can learn.

here map reduce code: (using java programming language , eclipse ide)

public class empmapreduce { public static class tokenizermapper extends mapper<longwritable, text, text, text>              {         public void map(longwritable key, text value, context context)             throws ioexception, interruptedexception                 {         string tokens [] = value.tostring().split(",");         string empid = tokens[0];         string val = "";         if(tokens.length != 0)          {             (int cnt = 1; cnt < tokens.length; cnt++)                {                    val = val + tokens[cnt] + "\t";             }         }          context.write(new text(empid), new text(val));      }    }    public static class myreducer extends reducer<text, text, text, text>          {     public void reduce(text key, iterable<text> values,             context context) throws ioexception, interruptedexception                {             string str = "";         (text val : values)                       {             str = str + val.tostring() + "\t";          }           context.write(key, new text (str));       }   }    public static void main(string[] args) throws exception          {     configuration conf = new configuration();     string[] otherargs = new genericoptionsparser(conf, args)             .getremainingargs();     if (otherargs.length != 3) {         system.err.println("usage: empmapreduce <in1> <in2> <out>");         system.exit(2);     }     job job = new job(conf, "empmapreduce");        job.setjarbyclass(empmapreduce.class);      job.setmapperclass(tokenizermapper.class);     job.setreducerclass(myreducer.class);      job.setmapoutputkeyclass(text.class);     job.setmapoutputvalueclass(text.class);      job.setinputformatclass(textinputformat.class);      job.setoutputkeyclass(text.class);     job.setoutputvalueclass(text.class);      fileinputformat.addinputpath(job, new path(otherargs[0]));     fileinputformat.addinputpath(job, new path(otherargs[1]));     fileoutputformat.setoutputpath(job, new path(otherargs[2]));      system.exit(job.waitforcompletion(true) ? 0 : 1);     }    } 

here 2 input file content used:

100,name100,10 101,name101,11 102,name102,12 103,name103,13 104,name104,14 105,name105,15 106,name106,16 107,name107,17 

second input file:

100,100000 101,200000 102,300000 103,400000 104,500000 105,600000 106,700000 107,800000 

if 1 can tell me getting things wrong or 1 can post there solution great help. in advance


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -