Hadoop:间隔和 JOIN
我对Hadoop非常陌生,目前正在尝试连接两个数据源,其中关键是间隔(例如[日期开始/日期结束] )。例如:
input1:
20091001-20091002 A
20091011-20091104 B
20080111-20091103 C
(...)
input2:
20090902-20091003 D
20081015-20091204 E
20040011-20050101 F
(...)
我想查找 key1 与 key2 重叠的所有记录。可以用hadoop吗?在哪里可以找到实施示例?
谢谢。
I'm very new to Hadoop and I'm currently trying to join two sources of data where the key is an interval (say [date-begin/date-end]). For example:
input1:
20091001-20091002 A
20091011-20091104 B
20080111-20091103 C
(...)
input2:
20090902-20091003 D
20081015-20091204 E
20040011-20050101 F
(...)
I'd like to find all the records where the key1 overlaps the key2. Is it possible with hadoop ? Where can I find an example of implementation ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Biostar上给出了解决方案:http://biostar.stackexchange.com/questions/8821
A solution was given on Biostar: http://biostar.stackexchange.com/questions/8821
我认为所需要的只是一个关键类,其中 hashCode() 和 equals() 执行您希望它们执行的操作。我怀疑你可能会遇到一个问题,A与B重叠(即A.equals(B) == true),B与C重叠,但C不与A重叠。如果你实现这样的equals()方法,你会可能会出现奇怪的行为。
基本上,您想要执行诸如在 Segment Tree 上进行查询之类的操作(即对于所有重叠间隔E 为一个间隔(p1.start,p1.end),对 p1.start 和 p1.end 执行刺探查询。
但基本上,不,我不知道你的问题的正确答案。但也许查询 "Segment tree" hadoop 会让你开始吧。
I think all that's needed is a key class where hashCode() and equals() do what you want them to do. I suspect that you might encounter a problem where A overlaps B (i.e. A.equals(B) == true), B overlaps C, but C doesn't overlap A. If you implement such an equals() method, you'll probably get strange behaviour.
Basically, you want to do something like stabbing queries on a Segment Tree (i.e. for all overlapping intervals E for an interval (p1.start, p1.end), perform stabbing queries for p1.start and p1.end).
But basically, no, I don't know a correct answer to your question. But maybe a query for "Segment tree" hadoop will get you started.