問題は、それがあるということですこれは愚かな質問のように見えるかもしれませんが、私はHadoopの間違ったキークラス:質問で述べたようにテキストがIntWritableない
のための私のMapReduceコードで私のタイプの問題を見ることができませんIntWritableを期待していますが、私はそれを減算器のcollector.collectのTextオブジェクトに渡しています。
マイジョブ構成は、以下のマッパー出力クラスがあります。
conf.setMapOutputKeyClass(IntWritable.class);
conf.setMapOutputValueClass(IntWritable.class);
そして、次の減速機出力クラス:
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
は私のマッピングクラスの定義は、次のとおりです
public static class Reduce extends MapReduceBase implements Reducer<IntWritable, IntWritable, Text, IntWritable>
必要な機能:
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<Text,IntWritable> output, Reporter reporter)
そして、私が呼ぶとき、それは失敗します。
output.collect(new Text(),new IntWritable());
私が軽減マッピングすることはかなり新しいですが、すべての型が一致するように見える、それはコンパイルしたが、その期待IntWritableを言って、その行に失敗します削減クラスの鍵としてそれが重要な場合は、私はここでのHadoop
の0.21バージョンを使用しています私のマップクラスである:
public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, IntWritable, IntWritable> {
private IntWritable node = new IntWritable();
private IntWritable edge = new IntWritable();
public void map(LongWritable key, Text value, OutputCollector<IntWritable, IntWritable> output, Reporter reporter) throws IOException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
node.set(Integer.parseInt(tokenizer.nextToken()));
edge.set(Integer.parseInt(tokenizer.nextToken()));
if(node.get() < edge.get())
output.collect(node, edge);
}
}
}
と私のクラス減らす:
public static class Reduce extends MapReduceBase implements Reducer<IntWritable, IntWritable, Text, IntWritable> {
IntWritable $ = new IntWritable(Integer.MAX_VALUE);
Text keyText = new Text();
public void reduce(IntWritable key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
ArrayList<IntWritable> valueList = new ArrayList<IntWritable>();
//outputs original edge pair as key and $ for value
while (values.hasNext()) {
IntWritable value = values.next();
valueList.add(value);
keyText.set(key.get() + ", " + value.get());
output.collect(keyText, $);
}
//outputs all the 2 length pairs
for(int i = 0; i < valueList.size(); i++)
for(int j = i+1; i < valueList.size(); j++)
output.collect(new Text(valueList.get(i).get() + ", " + valueList.get(j).get()), key);
}
}
と私の仕事の設定:
JobConf conf = new JobConf(Triangles.class);
conf.setJobName("mapred1");
conf.setMapOutputKeyClass(IntWritable.class);
conf.setMapOutputValueClass(IntWritable.class);
conf.setOutputKeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(Map.class);
conf.setCombinerClass(Reduce.class);
conf.setReducerClass(Reduce.class);
conf.setInputFormat(TextInputFormat.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf, new Path(args[0]));
FileOutputFormat.setOutputPath(conf, new Path("mapred1"));
JobClient.runJob(conf);
を
OKである必要があります。あなたはメールを投稿し、クラスをマップし、減らすことができます –
私はhadoopを初めて使い、メールクラスが何であるか分かりませんが、マップで質問を更新してクラスを減らしましたか?私は、このクラスを含むとは思わないWordCountの例を変更しました。 – user1084563