有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java使用Hadoop连接两个需要两个映射和一个reduce的数据集

Possible Duplicate:
Equivalent of mongo's out:reduce option in hadoop

我有两个数据集,一个是另一个的补充。它看起来像这样(不是实际字段):

Question
========
id(key)
name
description

Answer
========
id(key)
type
question_id

Output
======
question_id (key)
name
description
type_a_count
type_b_count

我想知道每个问题有多少个特定类型的答案。我以前使用mongodb的map reduce引擎来实现这一点,除了type_count字段中的一个字段外,我的问题映射器会发出相同的字段(但已归零),然后在我的reducer中添加所有内容 现在的问题是,当我运行答案映射器时,来自问题映射器的值被来自答案映射器的值覆盖

我正在寻找mongodb的{out:“reduce”}选项的等价物

更多详情:

  • 我的问题映射器只使用映射器
  • 两个作业的outputURI相同,因为我希望它合并
  • 我想使用问题映射器的输出和答案映射器的输出作为我的减速机的输入

共 (1) 个答案

  1. # 1 楼答案

    这个答案可能符合你的喜好,也可能不符合你的喜好。我知道您标记了java,但是有一个名为cascalog(用clojure编写)的库可以用来编写hadoop查询。这很简单:

    $ lein repl
    REPL started; server listening on localhost port 16309
    myapp=> (use 'cascalog.playground)
    nil
    myapp=> (bootstrap)
    nil
    myapp=> (def questions [["1" "what?" "desc what"] ["2" "where?" "Desc where"]])
    #'myapp/questions
    myapp=> (def answers [["1" "a" "1"]["2" "a" "1"]["3" "a" "1"]["4" "b" "2"]])
    #'myapp/answers
    myapp=> (?<- (stdout) [?type ?name ?desc ?count] (questions ?qid ?name ?desc) (answers ?aid ?type ?qid) (c/count ?count))
    
    RESULTS
               -
    a       what?   desc what   3
    b       where?  Desc where  1
    

    下面是学习cascalog的好起点:http://nathanmarz.com/blog/introducing-cascalog-a-clojure-based-query-language-for-hado.html