【慕課網實戰】Spark Streaming實時流處理項目實戰筆記二十一之銘文升級版
銘文一級:
DataV功能說明
1)點擊量分省排名/運營商訪問占比
Spark SQL項目實戰課程: 通過IP就能解析到省份、城市、運營商
2)瀏覽器訪問占比/操作系統占比
Hadoop項目:userAgent
DataV訪問的數據庫(MySQL),需要能夠在公網上訪問
DataV測試數據
CREATE TABLE course_click_count
(
ID int(4) PRIMARY KEY,
day VARCHAR(10),
course_id VARCHAR(10),
click_count long
);
INSERT INTO course_click_count values (1,‘20171111‘,‘112‘,8000);
INSERT INTO course_click_count values (2,‘20171111‘,‘128‘,9000);
INSERT INTO course_click_count values (3,‘20171111‘,‘145‘,10000);
INSERT INTO course_click_count values (4,‘20171111‘,‘146‘,4000);
INSERT INTO course_click_count values (5,‘20171111‘,‘131‘,3000);
INSERT INTO course_click_count values (6,‘20171111‘,‘130‘,2000);
CREATE TABLE course_info
(
ID int(4) PRIMARY KEY,
course_id VARCHAR(10),
course_name VARCHAR(100)
);
INSERT INTO course_info values (1,‘112‘,‘Spark SQL‘);
INSERT INTO course_info values (2,‘128‘,‘10小時入門大數據‘);
INSERT INTO course_info values (3,‘145‘,‘深度學習‘);
INSERT INTO course_info values (4,‘146‘,‘Node.js‘);
INSERT INTO course_info values (5,‘131‘,‘Vue+Django實戰‘);
INSERT INTO course_info values (6,‘130‘,‘Web前端性能優化‘);
select b.course_name course_name, a.click_count click_count
from (
(select course_id, click_count from course_click_count where day=‘20171111‘ ) a
join
(select course_id, course_name from course_info) b
on a.course_id = b.course_id
)
省份點擊量排名
[
{
"value": "314529403.31",
"content": "北京市"
},
{
"value": "293711093.03",
"content": "上海市"
},
{
"value": "193691138.91",
"content": "山東省"
},
{
"value": "293711093.03",
"content": "河南省"
},
{
"value": "193120534.18",
"content": "安徽省"
}
]
客戶端統計:
[
{
"x": "Chrome",
"y": 29000,
"s": "1"
},
{
"x": "Firefox",
"y": 4320,
"s": "1"
},
{
"x": "QQ",
"y": 13000,
"s": "1"
},
{
"x": "Safari",
"y": 23000,
"s": "1"
}
]
搜索引擎統計
[
{
"x": "百度",
"y": 14534,
"s": "1"
},
{
"x": "搜狗",
"y": 8345,
"s": "1"
},
{
"x": "雅虎",
"y": 4000,
"s": "1"
},
{
"x": "微軟",
"y": 6666,
"s": "1"
}
]
運營商統計
[
{
"x": "移動",
"y": 5
},
{
"x": "聯通",
"y": 22
},
{
"x": "電信",
"y": 22
},
{
"x": "鵬博士",
"y": 14
},
{
"x": "鐵通",
"y": 15
},
{
"x": "其他",
"y": 15
}
]
操作系統占比
[
{
"x": "iOS",
"y": 65000
},
{
"x": "MacOS",
"y": 80000
},
{
"x": "Win7",
"y": 20000
},
{
"x": "Win10",
"y": 40000
},
{
"x": "Android",
"y": 70000
}
]
有興趣的小夥伴,可以把如上的靜態數據準備成sql語句,插入到MySQL中去,
然後在DataV組件上通過sql的方式展示出來。
銘文二級(自己看官網吧):
DataV的使用、主要是數據庫的連接,操作是寫sql語句,個人版只有mysql數據庫
無法使用HBase,所以需要自己寫到mysql裏面去
第14章 Java拓展
使用java開發Spark應用程序
使用java開發Spark Streaming應用程序
【慕課網實戰】Spark Streaming實時流處理項目實戰筆記二十一之銘文升級版