我对极权主义者的概念是完全陌生的,我应用了这个概念,但我没有成功地产生全球排序。这是我的输入记录
676576
7489768576
689576857867857
685768578678578675
765897685789675879679587
1
5
6
7
8
9
0
2
3
5
6
9
这是我的地图
public void map(LongWritable key, Text value,
OutputCollector<NullWritable, Text> outputCollector, Reporter reporter) throws IOException {
// TODO Auto-generated method stub
outputCollector.collect(NullWritable.get(),value);
}
这是我的减速机
public void reduce(NullWritable key, Iterator<Text> values,
OutputCollector<NullWritable, Text> outputCollector, Reporter reporter) throws IOException {
// TODO Auto-generated method stub
while (values.hasNext()) {
Text text = (Text) values.next();
outputCollector.collect(key,text);
}
}
这是我与工作有关的代码
JobConf jobConf = new JobConf();
jobConf.setMapperClass(TotalOrderMapper.class);
jobConf.setReducerClass(TotalOrderReducer.class);
jobConf.setMapOutputKeyClass(NullWritable.class);
jobConf.setMapOutputValueClass(Text.class);
jobConf.setOutputKeyClass(NullWritable.class);
jobConf.setOutputValueClass(Text.class);
jobConf.setPartitionerClass(TotalOrderPartitioner.class);
jobConf.setInputFormat(TextInputFormat.class);
jobConf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.addInputPath(jobConf, new Path("hdfs://localhost:9000/totalorderset.txt"));
FileOutputFormat.setOutputPath(jobConf, new Path("hdfs://localhost:9000//sortedRecords5.txt"));
Path pa = new Path("hdfs://localhost:9000//partitionfile","_partitions.lst");
TotalOrderPartitioner.setPartitionFile(jobConf,
pa);
InputSampler.writePartitionFile(jobConf,
new InputSampler.RandomSampler(1,1));
JobClient.runJob(jobConf);
但是记录没有得到sorted.this是我的输出
676576
7489768576
689576857867857
685768578678578675
765897685789675879679587
1
5
6
7
8
9
0
2
3
5
6
9
我不知道我要去哪里,wrong.could,有人帮我解决问题吗?有人能告诉我输入采样是如何工作的吗? here.thanks。
发布于 2013-10-14 15:09:40
Mapreduce对键进行排序,因为您正在对nullwritable进行排序,所以根本不进行排序:
outputCollector.collect(NullWritable.get(),value);您的地图输出键应该是您的输入值!
outputCollector.collect(value, NullWritable.get());你能试一试吗,让我们知道它是否有效?
第二个注意事项:使用IntWritable代替文本,否则排序将按顺序排列!
https://stackoverflow.com/questions/19354361
复制相似问题