1
我試圖理清一系列整數是按以下順序:在MapReduce的排序產生額外的價值
A 2
B 9
C 4
....
....
Z 42
以下是映射和減速代碼:
public static class MapClass extends MapReduceBase implements Mapper<Text, Text, IntWritable, Text>
{
public void map(Text key, Text value, OutputCollector<IntWritable, Text> output, Reporter reporter) throws IOException
{
output.collect(new IntWritable(Integer.parseInt(value.toString())), key);
}
}
public static class Reduce extends MapReduceBase implements Reducer<IntWritable, Text, IntWritable, Text>
{
public void reduce(IntWritable key, Iterator<Text> values, OutputCollector<IntWritable, Text> output, Reporter reporter) throws IOException
{
output.collect(key, new Text(""));
}
}
但產量正在生產大量額外的整數。任何人都可以告訴我什麼是錯誤的代碼?
另外,如果可能的話,使用MapReduce指向一個很好的整數排序示例。
編輯:
job.setInputFormat(KeyValueTextInputFormat.class);
job.setOutputFormat(TextOutputFormat.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Text.class);
你可以分享你的全部代碼。需要知道你使用的是什麼InputFormat,以及你的邏輯是什麼。你的數據中是否有重複的字段?你使用了多少個reducer? – Rags
還要說明數據有多大? – Rags
這是一個非常小的數據,最多20個整數分佈在4個文件中(每個文件5個整數)。只是想測試該程序。我編輯了源代碼以包含輸入格式。檢查。 – Jyotiska