@Override protected void map(AvroKey<Integer> docid, AvroValue<CharSequence> body, Context context) throws IOException, InterruptedException { for (String token : body.datum().toString().split(" ")) { context.write(new Text(token), new IntWritable(docid.datum())); } }
@Override protected void reduce(Text token, Iterable<IntWritable> docids, Context context) throws IOException, InterruptedException { List<Integer> hitlist = new ArrayList<Integer>(); for (IntWritable docid : docids) { hitlist.add(docid.get()); } context.write(token, new AvroValue<List<Integer>>(hitlist)); }