嗨,如果我想编码“直到输入文件的末尾没有”来找出编写程序的代码 我认为这是由于错误造成的。 非常感谢
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);
}
}
}
}
答案 0 :(得分:0)
**问题解决了: 在IF IF放开之前,直到输入文件的结尾和空行才能读取。它读起来像一个空行显示错误信息。 **
// add this code somewhere to your constructor of your page or content dialog - where the problematic TextBox is located
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Showing += (s, args) =>
{
const double extraHeightBuffer = 20.0;
UIElement focused = FocusManager.GetFocusedElement() as UIElement;
if (null != focused)
{
GeneralTransform gt = focused.TransformToVisual(this);
Point focusedPoint = gt.TransformPoint(new Point(0, focused.RenderSize.Height - 1));
double bottomOfFocused = focusedPoint.Y + extraHeightBuffer;
if (bottomOfFocused > args.OccludedRect.Top)
{
var trans = new TranslateTransform();
trans.Y = -(bottomOfFocused - args.OccludedRect.Top);
this.RenderTransform = trans;
}
args.EnsuredFocusedElementInView = true;
}
};
Windows.UI.ViewManagement.InputPane.GetForCurrentView().Hiding += (s, args) =>
{
var trans = new TranslateTransform();
trans.Y = 0;
this.RenderTransform = trans;
args.EnsuredFocusedElementInView = false;
};