0

私は次のようなMapReduceプログラムを持っています

public static class MapClass extends MapReduceBase implements Mapper<Text, Text, IntWritable, IntWritable> {

        private final static IntWritable uno = new IntWritable(1);
        private IntWritable citationCount = new IntWritable();

        public void map(Text key, Text value, OutputCollector<IntWritable, IntWritable> output, Reporter reporter) throws IOException {
            citationCount.set(Integer.parseInt(value.toString()));
            output.collect(citationCount, uno);
        }
    }

    public static class Reduce extends MapReduceBase implements Reducer<IntWritable, IntWritable, IntWritable, IntWritable> {

        public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<IntWritable, IntWritable> output, Reporter reporter) throws IOException {
            int count = 0;
            while (values.hasNext()) {
                count += values.next().get();
            }

            output.collect(key, new IntWritable(count));
        }
    }

タスクのみ を実行したいのですが、出力はフォームである必要があります。 コマンドラインからこれを実行すると、次のようになります。 map<number, 1>

$ hadoop jar Hadoop-programs.jar com/hadoop/patent/CitationHistogram input output -Dmapred.reduce.tasks=0

しかし、これは私がコマンドライン出力で見るものです

12/07/30 06:13:14 INFO mapred.JobClient:  map 50% reduce 0%
12/07/30 06:13:23 INFO mapred.JobClient:  map 58% reduce 0%
12/07/30 06:13:26 INFO mapred.JobClient:  map 60% reduce 8%
12/07/30 06:13:29 INFO mapred.JobClient:  map 68% reduce 8%
12/07/30 06:13:32 INFO mapred.JobClient:  map 76% reduce 8%
12/07/30 06:13:35 INFO mapred.JobClient:  map 85% reduce 16%
12/07/30 06:13:38 INFO mapred.JobClient:  map 93% reduce 16%
12/07/30 06:13:41 INFO mapred.JobClient:  map 98% reduce 16%
12/07/30 06:13:44 INFO mapred.JobClient:  map 100% reduce 16%
12/07/30 06:13:55 INFO mapred.JobClient:  map 100% reduce 69%
12/07/30 06:13:58 INFO mapred.JobClient:  map 100% reduce 78%
12/07/30 06:14:01 INFO mapred.JobClient:  map 100% reduce 94%
12/07/30 06:14:08 INFO mapred.JobClient:  map 100% reduce 100%

ジョブの出力を見ると、次のようなエントリが表示されます。

1       2
13      2
24      1
29      1
31      2
42      3
6796    7
6799    1
6806    1
6815    1
6824    2

これは、データが集約されていることを意味します

レデューサーをまったく実行できないのはどうしてですか?

4

2 に答える 2

2

これは、ToolRunner.runメソッドを実装し、メインメソッドで引数を渡す場合にのみ機能します。

ToolRunner.run(new Configuration(), new YourClasImplmentingToolRunner(), args);

やりたくない場合は設定してみてください

job.setNumReduceTasks(0);

または、他のオプションは、confに値を設定し、その構成をジョブで使用することです。

Configuration conf = new Configuration();
conf.set("mapred.reduce.tasks", "0");
Job job = new Job(conf, "My job Name");
于 2012-07-30T19:15:36.660 に答える
0

-Dオプションの後にスペースを追加すると、機能するはずです;)

hadoop jar Hadoop-programs.jar com/hadoop/patent/CitationHistogram input output -D mapred.reduce.tasks=0

于 2012-07-30T15:30:34.280 に答える