- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
这是我收到的错误:
14/02/28 02:52:43 INFO mapred.JobClient: Task Id : attempt_201402271927_0020_m_000001_2, Status : FAILED
java.lang.NullPointerException
at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.init(MapTask.java:843)
at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:376)
at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:85)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:584)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:656)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:330)
at org.apache.hadoop.mapred.Child$4.run(Child.java:268)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1408)
at org.apache.hadoop.mapred.Child.main(Child.java:262)
我已经将我的代码注释掉以基本上接受典型的 LongWritable 和 Text,然后我只输出一个常量 IntWritable 1 和一个空的天气类(自定义类):
这是我的映射器类:
public class Map extends Mapper<LongWritable, Text, IntWritable, Weather> {
private IntWritable id = new IntWritable(1);
private Weather we = new Weather();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
//String s;
//String line = value.toString();
//int start[] = {0,18,31,42,53,64,74,84,88,103};
//int end[] = {6,22,33,44,55,66,76,86,93,108};
//if(line.length() > 108) {
// create the object to hold our data
// getStuff()
// parse the string
// push the object onto our data structure
context.write(id, we);
//}
}
这是我的 reducer :
public class Reduce extends Reducer<IntWritable, Weather, IntWritable, Text> {
private Text text = new Text("one");
private IntWritable one = new IntWritable(1);
public void reduce(IntWritable key, Iterable<Weather> weather, Context context)
throws IOException, InterruptedException {
//for(Weather w : weather) {
// text.set(w.toString());
context.write(one, text);
}
}
这是我的主要内容:
public class Skyline {
public static void main(String[] args) throws IOException{
//String s = args[0].length() > 0 ? args[0] : "skyline.in";
Path input, output;
Configuration conf = new Configuration();
conf.set("io.serializations", "org.apache.hadoop.io.serializer.JavaSerialization,"
+ "org.apache.hadoop.io.serializer.WritableSerialization");
try {
input = new Path(args[0]);
} catch(ArrayIndexOutOfBoundsException e) {
input = new Path("hdfs://localhost/user/cloudera/in/skyline.in");
}
try {
output = new Path(args[1]);
//FileSystem.getLocal(conf).delete(output, true);
} catch(ArrayIndexOutOfBoundsException e) {
output = new Path("hdfs://localhost/user/cloudera/out/");
//FileSystem.getLocal(conf).delete(output, true);
}
Job job = new Job(conf, "skyline");
job.setJarByClass(Skyline.class);
job.setOutputKeyClass(IntWritable.class);
job.setOutputValueClass(Weather.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
FileInputFormat.addInputPath(job, input);
FileOutputFormat.setOutputPath(job, output);
try {
job.waitForCompletion(true);
} catch(InterruptedException e) {
System.out.println("Interrupted Exception");
} catch(ClassNotFoundException e) {
System.out.println("ClassNotFoundException");
}
}
}
这是我的天气类的示例:
public class Weather {
private in stationId;
public Weather(){}
public int getStation(){return this.stationID;}
public void setStation(int r){this.stationID = r}
//...24 additional things of ints, doubles and strings
}
我已经无计可施了。在这一点上,我有一个程序的外壳,它什么都不做,但仍然收到错误。我已经阅读了 Java 泛型,以确保我正确地使用了它们(我想我是),我对 MapReduce 范例非常陌生,但这个程序只是一个外壳,从 MapReduce 教程( https://hadoop.apache.org/docs/r1.2.1/mapred_tutorial.html#Walk-through ).
最佳答案
问题是您用于 map()
输出/reduce()
输入的类 Weather
没有实现可写
。这将阻止默认的 SerializationFactory
处理您的值。
潜在的概念性问题是 Hadoop 不知道如何将您的数据类型序列化到磁盘并将其读回。这是一个强制性步骤,因为在将数据从 map 任务移动到 reducer 之前必须持久化数据(通常这两者可以在不同的节点上运行)。
所以您要做的是实现 Writable
并在您的自定义数据类型中添加序列化例程。
关于java - 不了解 MapReduce NPE,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22135566/
我开始在 Ethereum blockchain 上了解如何开发智能合约以及如何写 web-script用于与智能合约交互(购买、销售、统计......)我得出了该怎么做的结论。我想知道我是否正确理解
我正在 UIView 中使用 CATransform3DMakeRotation,并且我正在尝试进行 45º,变换就像向后放置一样: 这是我拥有的“代码”,但显然没有这样做。 CATransform3
我目前正在测试 WebRTC 的功能,但我有一些脑逻辑问题。 WebRTC 究竟是什么? 我只读了“STUN”、“P2P”和其他...但是在技术方面什么是正确的 WebRTC(见下一个) 我需要什么
我在看 DelayedInit在 Scala in Depth ... 注释是我对代码的理解。 下面的 trait 接受一个非严格计算的参数(由于 => ),并返回 Unit .它的行为类似于构造函数
谁能给我指出一个用图片和简单的代码片段解释 WCF 的资源。我厌倦了谷歌搜索并在所有搜索结果中找到相同的“ABC”文章。 最佳答案 WCF 是一项非常复杂的技术,在我看来,它的文档记录非常少。启动和运
我期待以下 GetArgs.hs打印出传递给它的参数。 import System.Environment main = do args main 3 4 3 :39:1: Coul
private int vbo; private int ibo; vbo = glGenBuffers(); ibo = glGenBuffers(); glBindBuffer(GL_ARRAY_
我正在尝试一个 for 循环。我添加了一个 if 语句以在循环达到 30 时停止循环。 我见过i <= 10将运行 11 次,因为循环在达到 10 次时仍会运行。 如果有设置 i 的 if 语句,为什
我正在尝试了解 WSGI 的功能并需要一些帮助。 到目前为止,我知道它是一种服务器和应用程序之间的中间件,用于将不同的应用程序框架(位于服务器端)与应用程序连接,前提是相关框架具有 WSGI 适配器。
我是 Javascript 的新手,我正在尝试绕过 while 循环。我了解它们的目的,我想我了解它们的工作原理,但我在使用它们时遇到了麻烦。 我希望 while 值自身重复,直到两个随机数相互匹配。
我刚刚偶然发现Fabric并且文档并没有真正说明它是如何工作的。 我有根据的猜测是您需要在客户端和服务器端都安装它。 Python 代码存储在客户端,并在命令运行时通过 Fabric 的有线协议(pr
我想了解 ConditionalWeakTable .和有什么区别 class ClassA { static readonly ConditionalWeakTable OtherClass
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 5年前关闭。 Improve this questi
我还没有成功找到任何可以引导我理解 UIPickerView 和 UIPickerView 模型的好例子。有什么建议吗? 最佳答案 为什么不使用默认的 Apple 文档示例?这是来自苹果文档的名为 U
我在看foldM为了获得关于如何使用它的直觉。 foldM :: Monad m => (a -> b -> m a) -> a -> [b] -> m a 在这个简单的例子中,我只返回 [Just
答案What are _mm_prefetch() locality hints?详细说明提示的含义。 我的问题是:我想要哪一个? 我正在处理一个被重复调用数十亿次的函数,其中包含一些 int 参数。
我一直在读这个article了解 gcroot 模板。我明白 gcroot provides handles into the garbage collected heap 然后 the handle
提供了一个用例: 流处理架构;事件进入 Kafka,然后由带有 MongoDB 接收器的作业进行处理。 数据库名称:myWebsite集合:用户 并且作业接收 users 集合中的 user 记录。
你好 我想更详细地了解 NFS 文件系统。我偶然发现了《NFS 图解》这本书,不幸的是它只能作为谷歌图书提供,所以有些页面丢失了。有人可能有另一个很好的资源,这将是在较低级别上了解 NFS 的良好开始
我无法理解这个问题,哪个更随机? rand() 或: rand() * rand() 我发现这是一个真正的脑筋急转弯,你能帮我吗? 编辑: 凭直觉,我知道数学答案是它们同样随机,但我忍不住认为,如果您
我是一名优秀的程序员,十分优秀!