کار با hadoop
سلام
از بچه ها کسی با هدوپ کار میکنه؟
این کد که جمع دو ماتریس ۲*۲ هست وقتی اجرا میکنم پیغام خطای زیرو میده:
۱۵/۰۷/۰۱ ۱۳:۰۵:۱۹ INFO mapreduce.Job: Task Id: attempt_1435769899158_0001_m_000000_2, Status: FAILED Error: java.lang.ArrayIndexOutOfBoundsException: 1
code map:
public static class Map extends Mapper<LongWritable, Text, Text, Text> {
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
int r = Integer.parseInt(conf.get("r"));
int c = Integer.parseInt(conf.get("c"));
String line = value.toString();
String[] indicesAndValue = line.split(",");
Text outputKey = new Text();
Text outputValue = new Text();
if (indicesAndValue[0].equals("A")) {
outputKey.set(indicesAndValue[1] + "," + indicesAndValue[2]);
outputValue.set("A," + indicesAndValue[2] + "," + indicesAndValue[3]);
context.write(outputKey, outputValue);
} else {
outputKey.set(indicesAndValue[1] + "," + indicesAndValue[2]);
outputValue.set("B," + indicesAndValue[2] + "," + indicesAndValue[3]);
context.write(outputKey, outputValue);
}
}
}
jop:
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
/* // A is an r-by-c matrix; B is an r-by-c matrix.
conf.set("r", "2");
conf.set("c", "2");
Job job = new Job(conf, "MatrixSum");
job.setJarByClass(MatrixSum.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
job.waitForCompletion(true);
}
|