我有一个 hadoop 程序,我想在其中链接两个作业,例如输入 -> mapper1 -> reducer1 -> mapper2 -> reducer2 -> 输出。前半部分工作正常,我得到了正确的中间输出。问题在于第二份工作。特别是,我相信在第二份工作中,映射器由于某种原因没有调用正确的 reducer ,因为我得到了类型不匹配。 这是我设置作业的主要代码:
//JOB 1
Path input1 = new Path(otherArgs.get(0));
Path output1 =new Path("/tempBinaryPath");
Job job1 = Job.getInstance(conf);
job1.setJarByClass(BinaryPathRefined.class);
job1.setJobName("BinaryPathR1");
FileInputFormat.addInputPath(job1, input1);
FileOutputFormat.setOutputPath(job1, output1);
job1.setMapperClass(MyMapper.class);
//job.setCombinerClass(MyReducer.class);
job1.setReducerClass(MyReducer.class);
job1.setInputFormatClass(TextInputFormat.class);
job1.setOutputKeyClass(Text.class);
job1.setOutputValueClass(Text.class);
job1.waitForCompletion(true);
// JOB 2
Path input2 = new Path("/tempBinaryPath/part-r-00000");
Path output2 =new Path(otherArgs.get(1));
Job job2 = Job.getInstance(conf2);
job2.setJarByClass(BinaryPathRefined.class);
job2.setJobName("BinaryPathR2");
FileInputFormat.addInputPath(job2, input2);
FileOutputFormat.setOutputPath(job2, output2);
job2.setMapperClass(MyMapper2.class);
//job.setCombinerClass(MyReducer.class);
job2.setReducerClass(MyReducer2.class);
job2.setInputFormatClass(TextInputFormat.class);
job2.setOutputKeyClass(Text.class);
job2.setOutputValueClass(Text.class);
job2.waitForCompletion(true);
映射器和缩减器的形式是:
public static class MyMapper extends Mapper<LongWritable, Text, Text, Text>{
...
}
public static class MyReducer extends Reducer<Text, Text, Text, Text>{
...
}
public static class MyMapper2 extends Mapper<LongWritable, Text, Text, IntWritable>{
...
}
public static class MyReducer2 extends Reducer<Text, IntWritable, Text, Text>{
...
}
第一个作业运行良好,而第二个作业出现错误:
Type mismatch in value from map: expected org.apache.hadoop.io.Text, received org.apache.hadoop.io.IntWritable
有什么想法吗?
最佳答案
当您仅调用 setOutputKeyClass 和 setOutputValueClass 时,Hadoop 将假定 Mapper 和 Reducer 具有相同的输出类型。在您的情况下,您应该明确设置 Mapper 产生的输出类型:
job2.setOutputKeyClass(Text.class);
job2.setMapOutputValueClass(IntWritable.class);
关于java - 链接两个作业时未调用 Hadoop 第二个 reducer ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36977386/
exe应该在我打开页面时运行。异步进程需要运行。有什么方法可以在ruby中使用两个参数异步运行exe吗?我已经尝试过ruby命令-system()、exec()但它正在等待过程完成。我需要用参数启动exe,无需等待进程完成是否有任何rubygems会支持我的问题? 最佳答案 您可以使用Process.spawn和Process.wait2:pid=Process.spawn'your.exe','--option'#Later...pid,status=Process.wait2pid您的程序将作为解释器的子进程执行。除
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我正在使用Rails构建一个简单的聊天应用程序。当用户输入url时,我希望将其输出为html链接(即“url”)。我想知道在Ruby中是否有任何库或众所周知的方法可以做到这一点。如果没有,我有一些不错的正则表达式示例代码可以使用... 最佳答案 查看auto_linkRails提供的辅助方法。这会将所有URL和电子邮件地址变成可点击的链接(htmlanchor标记)。这是文档中的代码示例。auto_link("Gotohttp://www.rubyonrails.organdsayhellotodavid@loudthinking.
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL
我正在阅读一本关于Ruby的书,作者在编写类初始化定义时使用的形式与他在本书前几节中使用的形式略有不同。它看起来像这样:classTicketattr_accessor:venue,:datedefinitialize(venue,date)self.venue=venueself.date=dateendend在本书的前几节中,它的定义如下:classTicketattr_accessor:venue,:datedefinitialize(venue,date)@venue=venue@date=dateendend在第一个示例中使用setter方法与在第二个示例中使用实例变量之间是
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我需要一些关于TDD概念的帮助。假设我有以下代码defexecute(command)casecommandwhen"c"create_new_characterwhen"i"display_inventoryendenddefcreate_new_character#dostufftocreatenewcharacterenddefdisplay_inventory#dostufftodisplayinventoryend现在我不确定要为什么编写单元测试。如果我为execute方法编写单元测试,那不是几乎涵盖了我对create_new_character和display_invent
我只想对我一直在思考的这个问题有其他意见,例如我有classuser_controller和classuserclassUserattr_accessor:name,:usernameendclassUserController//dosomethingaboutanythingaboutusersend问题是我的User类中是否应该有逻辑user=User.newuser.do_something(user1)oritshouldbeuser_controller=UserController.newuser_controller.do_something(user1,user2)我
我正在尝试用Prawn生成PDF。在我的PDF模板中,我有带单元格的表格。在其中一个单元格中,我有一个电子邮件地址:cell_email=pdf.make_cell(:content=>booking.user_email,:border_width=>0)我想让电子邮件链接到“mailto”链接。我知道我可以这样链接:pdf.formatted_text([{:text=>booking.user_email,:link=>"mailto:#{booking.user_email}"}])但是将这两行组合起来(将格式化文本作为内容)不起作用:cell_email=pdf.make_c