3.2.1 将表中category字段数组行转列 select views,hot from gulivideo_orc lateral view explode (category) category_t as hot;t1
3.2.2 统计每个类别的观看总数 select hot,count(*) from t1 group by hot;t2
3.2.3 获取观看前10的类别 select hot,total_view from ()t2 order by total_view desc limit 10;
SELECT hot,
total_view
FROM (
SELECT hot,
Count(*) total_view
FROM (
SELECT views,
hot
FROM gulivideo_orc lateral view explode (category) category_t as hot)t1
GROUP BY hot)t2
ORDER BY total_view DESC limit 10;
3.3.1 观看数top20视频 select views,category from gulivideo_orc order by views desc limit 20;t1 3.3.2 所属类别 select views,category from t1 lateral view explode(category)ct as category_name;
SELECT views,
category_name
FROM (
SELECT views,
category
FROM gulivideo_orc
ORDER BY views DESC limit 20)t1 lateral VIEW explode(category)ct AS category_name ;
+-----------+----------------+--+
| views | category_name |
+-----------+----------------+--+
| 42513417 | Comedy |
| 20282464 | Comedy |
| 16087899 | Entertainment |
| 15712924 | Entertainment |
| 15256922 | Music |
| 13199833 | People |
| 13199833 | Blogs |
| 11970018 | Comedy |
| 11823701 | Music |
| 11672017 | Music |
| 11184051 | People |
| 11184051 | Blogs |
| 10786529 | Entertainment |
| 10334975 | Entertainment |
| 10107491 | Comedy |
| 9579911 | Music |
| 9566609 | Comedy |
| 8825788 | UNA |
| 7533070 | Music |
| 7456875 | Entertainment |
| 7066676 | Comedy |
| 6952767 | Entertainment |
+-----------+----------------+--+
3.4 统计视频观看数 Top50 所关联视频的所属类别 Rank
3.4.1 观看数top10,关联视频 select videoid,views,category,relatedid from gulivideo_orc order by views desc limit 50;t1
3.4.2 关联视频行转列 select distinct(r_id) from t1 lateral view explode(relatedid) relatedtable as r_id;t2
3.4.3 视频所属类别 select r_id,g.category from t2.join gulivideo_orc g on r_id = g.videoid;t3
select r_id,g.category from t2 join gulivideo_orc g on r_id = g.videoid;t3
3.4.4 类别展开 select category_name from ()t3 lateral view explode(category)t as category_name;t4
3.4.5 统计类别个数 select category_name,count(*) hot from t4 group by category_name,t_sum;t5
3.4.6 所属类别排名 select * from t5 order by hot desc;t6
SELECT *
FROM (
SELECT category_name,
Count(*) hot
FROM (
SELECT category_name
FROM (
SELECT r_id,
g.category
FROM (
SELECT DISTINCT(r_id)
FROM (
SELECT videoid,
views,
category,
relatedid
FROM gulivideo_orc
ORDER BY views DESC limit 50)t1 lateral VIEW explode(relatedid) relatedtable as r_id)t2
JOIN gulivideo_orc g
ON r_id = g.videoid)t3 lateral VIEW explode(category)t as category_name )t4
GROUP BY category_name)t5
ORDER BY hot DESC;
SELECT category_name,
views,
videoid
FROM (
SELECT category_name,
videoid,
views,
Rank() OVER(partition BY category_name order by views) rank_no
FROM (
SELECT category_name,
videoid,
views
FROM gulivideo_orc lateral view explode(category) t as category_name
GROUP BY category_name,
videoid,
views
ORDER BY category_name,
views DESC)t1
ORDER BY category_name)t2
WHERE rank_no<=10;
3.6 统计每个类别中视频流量 Top10
3.7 统计上传视频最多的用户 Top10 以及他们上传的视频
1.找出上传前10的用户 select uploader, videos from guli_user_orc order by videos desc limit 10;t1
2.找到上传的所有视频 select t1.uploader, videoid, views from ()t1 join gulivideo_orc g on t.uploader=g.uploader order by uploader,views desc; t2
SELECT t1.uploader,
videoid,
views
FROM (SELECT uploader,
videos
FROM guli_user_orc
ORDER BY videos DESC
LIMIT 10)t1
JOIN gulivideo_orc g
ON t1.uploader = g.uploader
order by uploader,views desc;
3.8 统计每个类别视频观看数 Top10
1.统计所有类别对应的视频 select category_name,videoid,views from gulivideo_orc lateral view explode(category) t as category_name;t1
2.对每个类观看数排名 select *,rank() over(partition by category_name order by views desc) rank_no from ()t1;t2
3.取前十 select * from ()t2 where rank_no<=10;
SELECT *
FROM (
SELECT *,
Rank() OVER(partition BY category_name ORDER BY views DESC) rank_no
FROM (
SELECT category_name,
videoid,
views
FROM gulivideo_orc lateral view explode(category) t as category_name)t1 )t2
WHERE rank_no<=10;
首先看看 WeakReference
wiki 上 Weak reference 的一个例子:
public class ReferenceTest {
public static void main(String[] args) throws InterruptedException {
WeakReference r = new Wea
有一个线上环境使用的是c3p0数据库,为外部提供接口服务。最近访问压力增大后台tomcat的日志里面频繁出现
com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResou
https://weblogs.java.net/blog/mriem/archive/2013/11/22/jsf-tip-45-create-composite-component-custom-namespace
When you developed a composite component the namespace you would be seeing would
一、复本集为什么要加入Arbiter这个角色 回答这个问题,要从复本集的存活条件和Aribter服务器的特性两方面来说。 什么是Artiber? An arbiter does
not have a copy of data set and
cannot become a primary. Replica sets may have arbiters to add a
# include <stdio.h>
int main(void)
{
int a[5] = {1, 2, 3, 4, 5};
//a 是数组的名字 5是表示数组元素的个数,并且这五个元素分别用a[0], a[1]...a[4]
int i;
for (i=0; i<5; ++i)
printf("%d\n",