- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我的现有系统从特定文件夹读取所有文件,并在其上运行 MapReduce。代码如下:
Path path = new Path(inputPath)
if (!FileSystem.get(conf).exists(path)) {
System.out.println("Path does not exist (skipping): " + path);
return 1;
}
FileInputFormat.setInputPaths(conf, inputPath);
这运行没有任何问题。现在,最近的文件更改要求我指定将哪些文件用作输入。我将代码更改为:
for(String fileName:filePath.split(",")){
MultipleInputs.addInputPath(conf, new Path(fileName), TextInputFormat.class, RawLogMapper.class);
// MultipleInputs.addInputPath(conf, new Path(fileName), TextInputFormat.class);
}
其中 filePath 是需要处理的绝对文件路径的逗号分隔列表。我使用的是 mapred,而不是 mapreduce。
import org.apache.hadoop.mapred.Reporter;
import org.apache.hadoop.mapred.TextInputFormat;
import org.apache.hadoop.mapred.lib.MultipleInputs;
import org.apache.hadoop.mapred.lib.MultipleTextOutputFormat;
更改代码后,我遇到了以下错误:
14/09/08 13:50:05 INFO mapred.JobClient: Task Id : attempt_201408201501_1196_m_000000_1, Status : FAILED
java.lang.RuntimeException: Error in configuring object
at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109)
at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:75)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:413)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:332)
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:1438)
at org.apache.hadoop.mapred.Child.main(Child.java:262)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.ja
不确定是不是因为我没有指定TextInputFormat,我把那部分加到addInputPath函数中,错误依旧。
发现问题。在映射器的下游进行了调用
String filename = conf.get("map.input.file");
pos = conf.get((new File(filename)).getName().split("-")[0]);
当我指定文件而不是给出文件夹时,文件名返回 null,因此是 NPE。我想知道为什么在我指定输入文件时使用 conf.get("map.input.file")。
https://issues.apache.org/jira/browse/MAPREDUCE-1743
这意味着,我需要在运行配置时知道文件的名称:
((FileSplit) context.getInputSplit()).getPath().toString();
,因为我使用的是 mapred 而不是 mapreduce。public void configure(JobConf conf) {
String filename = conf.get("map.input.file");
merchant = conf.get((new File(filename)).getName().split("-")[0]);
if (merchant == null) {
merchant = "unknown_merchant";
}
}
如果有任何意见可以解决此问题,我们将不胜感激。
谢谢,杰文
最佳答案
用过
FileInputFormat.addInputPath(conf, new Path(fileName));
一切看起来都很好。
关于java - Hadoop MultipleInputs 因 RuntimeException 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25731303/
如何最简单地运行多个不同的映射器类(使用 MultipleInputs),所有映射器类都使用相同的输入格式,但使用不同的输入分隔符? MultipleInput 允许您添加多个映射器,每个映射器都有自
我的 mapreduce 作业之一是使用 MultipleInputs。工作完成后,我想删除输入文件。不幸的是,MultipleInputs 的 API 非常有限,并且不提供 FileInputFor
所以,我想与 MR 执行 reduce side join。 (没有 Hive 或任何东西,我正在尝试 Vanilla Hadoop atm)。 我有 2 个输入文件,首先是这样的: 12 13 12
我在我们的 Yarn 集群上使用新的 MapReduce Api。我需要从两个不同的目录中读取两种不同格式的文件。为此,我决定使用 MultipleInputs 来指定两个映射器类。以下是我的工作驱动
出于学习目的,我正在使用 Java 中的 Hadoop(没有 Pig 或 Hive)编写 TF-IDF。我将把它分成三轮:字数统计、每个文档的字数统计,最后是每个字的 docCount。 我相信主要的
我的hadoop版本是1.0.3,当我使用multipleinputs时,我得到了这个错误。 java.lang.ClassCastException: org.apache.hadoop.mapre
目标:实现Reduce Side Join 我的代码中目前有作业链(两个作业)。现在我想在减少端加入另一份工作。而且我必须接受多个输入: Input #1:前一个 reducer 的输出。 Input
最近版本的 Hadoop 已经使用 FileInputFormat.setInputDirRecursive 轻松支持嵌套输入目录,它依赖于 mapreduce.input.fileinputform
我的现有系统从特定文件夹读取所有文件,并在其上运行 MapReduce。代码如下: Path path = new Path(inputPath) if (!FileSystem.ge
我有一个问题。 我需要两个文件作为 mapreduce 程序的输入。 @Override public int run(String[] args) throws Exception { (a
我正在尝试编写一个程序,其中包含 2 个同时执行的映射器和一个缩减器。每个映射器都有不同的输入文件。基本上,我正在尝试进行减少端连接。但是当我通过以下方式声明我的工作时出现错误: public sta
我正在尝试连接两个数据集,一个存储在 Hive 表中,另一个不存储。根据人们的做法,我看到这不是很正常,因为他们要么将所有内容定义为 Hive 表,要么不定义。 现在有 MultipleInputs
我在使用 hadoop 时使用了 MultipleInputs 。因为我有多个映射器分配给不同的输入。我想知道 EMR 是否也支持它。 在hadoop中我是这样操作的。这些是我的不同文件的映射器。在这
我是一名优秀的程序员,十分优秀!