您好,如果我想编码“直到输入文件的末尾不是”,以找出编写程序的代码
我认为这是由于错误。
非常感谢

            15/07/01 13:05:11 INFO mapreduce.Job: Task Id : attempt_1435769899158_0001_m_000000_1, Status : FAILED
Error: java.lang.ArrayIndexOutOfBoundsException: 1
            15/07/01 13:05:28 INFO mapreduce.Job: Job job_1435769899158_0001 failed with state FAILED due to: Task failed task_1435769899158_0001_m_000000
Job failed as tasks failed. failedMaps:1 failedReduces:0


code:

    import java.io.IOException;
    import java.util.*;

    import org.apache.hadoop.fs.Path;
    import org.apache.hadoop.conf.*;
    import org.apache.hadoop.io.*;
    import org.apache.hadoop.mapreduce.*;
    import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
    import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
    import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
    import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

    public class MatrixSum {

    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();
            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);
                }
            }
        }
    }

最佳答案

**问题已解决:
在IF之前,IF放开直到输入文件的末尾并读取空白行。读起来像是空白行显示错误消息。
**

if (lin.isEmpty==false){}

08-25 03:39