package com.mapreduce.topn;
import org.apache.hadoop.io.Text;
public class Item implements Comparable<Item>{
private Long count;
private String content;
public Item() {
}
public Item(Long count, String content) {
this.count = count;
this.content = content;
}
public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
@Override
public int compareTo(Item o) {
return Long.compare(count, o.getCount());
}
}
TopNMapper.java
package com.mapreduce.topn;
import java.io.IOException;
import java.util.PriorityQueue;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.log4j.Logger;
public class TopNMapper extends Mapper<Object, Text, NullWritable, Text> {
private int N;
private PriorityQueue<Item> priorityQueue = new PriorityQueue();
private static Logger