Mapper将值传递给不同的映射器 - 缩减器 [英] Mapper pass values to different mappers-reducers

查看:127
本文介绍了Mapper将值传递给不同的映射器 - 缩减器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个阶段map-reduce hadoop程序。 (mapper1,reducer1,mapper2,reducer2)。我可以直接将一些mapper1键值直接传递给reducer1和其他一些直接映射到mapper2吗?

解决方案

为你想要的reducer1处理的正常设置键值,同时给mapper2的有一些任意的键名(让我们可以在类Text.class中任意说TO_MAPPER_2)。然后你的reducer代码放在一个if语句中,以便它只在key不是TO_MAPPER_2时执行。这将确保您的值不会被reducer处理,并且将通过您使用的任何方法将它们发送到那里,而不会改变mapper2。

I have two phases map-reduce hadoop program. (mapper1, reducer1, mapper2, reducer2). Can i pass some of mapper1 key values directly to reducer1 and some others directly to mapper2?

解决方案

You could just put have the mapper set key value normally for the ones that you want reducer1 to process, while having the ones that go to mapper2 have some arbitrary key name (lets arbitrarily say "TO_MAPPER_2" in class Text.class). Then your reducer code inside of an if statement so that it only executes when key is not "TO_MAPPER_2". This will ensure that your values will not be processed by the reducer, and will reach mapper2 unchanged, through whatever method you are using to send them there.

这篇关于Mapper将值传递给不同的映射器 - 缩减器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆