Java中的MapReduce程序

Java中的MapReduce程序,java,eclipse,hadoop,mapreduce,mapper,Java,Eclipse,Hadoop,Mapreduce,Mapper,我有下面的地图 private Text sentiment = new Text(); public void map(LongWritable key, Text value, OutputCollector<Text, Text> output, Reporter reporter) throws IOException { String allPages = value.toString(); String[] tokens = allPa

我有下面的地图

private Text sentiment = new Text();

public void map(LongWritable key, Text value, OutputCollector<Text, Text> output, Reporter reporter)
        throws IOException {

    String allPages = value.toString();
    String[] tokens = allPages.split(":::");

    for(int i=0;i<(tokens.length-1);i++)
    {
        String articleID="";
        sentiment.set(tokens[i].trim());
        articleID = tokens[0].trim();
        System.out.println("articleID "+articleID);
        Text articleIDValue = new Text(articleID); 
        output.collect(sentiment,articleIDValue);
    }
    String line = "";
    for(int j=1;j<tokens.length;j++){
        line = line + " "+tokens[j];
        System.out.println("line.... "+line);
    }
    Text lineText = new Text(line.trim());
    output.collect(new Text(tokens[0]),lineText);

}
私有文本情感=新文本();
公共void映射(可长写键、文本值、OutputCollector输出、Reporter)
抛出IOException{
String allPages=value.toString();
String[]tokens=allPages.split(“:”);

对于(int i=0;i我怀疑您看到的是第一个collect()调用的结果,在该调用中,键和值都是从标记[0](“abc”)设置的。

是不是一个键有多个值?为什么要输出。collect(情绪,articleIDValue);对于标记[0]你能给我一些2-3行输入输出样本吗?是的,我意识到了我的错误。是的,我刚刚重新检查过。我正在
output.collect(情绪,articleIDValue);
。谢谢