[英]hadoop hive count concurrency
如何在hadoop中實現它?
在蜂巢中,我有一個包含很多列的表,其中兩個是begin_time,end_time。
我每次都要數一下
一張桌子是這樣的:
begin_time end_time
2011.04.26 10:19:06^A2011.04.26 10:20:22
2011.04.26 10:19:08^A2011.04.26 10:21:49
2011.04.26 10:19:08^A2011.04.26 11:18:46
2011.04.26 10:19:09^A2011.04.26 12:08:36
2011.04.26 10:19:09^A2011.04.26 11:00:16
2011.04.26 10:19:11^A2011.04.26 10:19:17
2011.04.26 10:19:12^A2011.04.26 10:46:21
2011.04.26 10:19:13^A2011.04.26 10:55:43
2011.04.26 10:19:17^A2011.04.26 10:19:41
2011.04.26 10:19:18^A2011.04.26 10:34:41
我想要的結果是在特定時間有多少人。
例如,在2011.04.26 10:19:08上,有3位訪客在賽道上,19:06一位,2位在19:08。
和2011.04.26 10:19:18為9,課程10,但在2011.04.26 10:19:17休假
所需的結果是
2011.04.26 10:19:06 1
2011.04.26 10:19:08 3
2011.04.26 10:19:09 5
2011.04.26 10:19:11 6
2011.04.26 10:19:12 7
2011.04.26 10:19:13 8
2011.04.26 10:19:17 9
2011.04.26 10:19:18 9
任何幫助深表感謝和歡迎。
您可以在配置單元上嘗試此操作(假設表名稱為test_log):
select /*+ MAPJOIN(driven) */ driven.time, count(*)
from
(select time
from
(select begin_time time from test_log union all
select end_time time from test_log) u
group by time) driven
join test_log l on true
where
driven.time between l.begin_time and l.end_time
group by driven.time
可能不是最好的解決方案,但至少可以奏效。 您可以在驅動的子查詢上添加一些過濾器以減少數據集。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.