7.2、将csv格式数据导入ElasticSearch 3
1、将mediamatch_usermsg.csv导入到ElasticSearch 4
2、将mediamatch_userevent.csv导入到 ElasticSearch 5
3、将mmconsume_billevents.csv 导入到ElasticSearch 6
4、将order_index.csv 导入到ElasticSearch 7
5、将media_index.csv 导入到 ElasticSearch 8
7.3转移ElasticSearch数据到Hive 9
1、在Hive中创建表mediamatch_usermsg 9
2、在Hive中创建表mediamatch_userevent 10
3、在Hive中创建表mmconsume_billevents 11
4、在Hive中创建表order_index 12
5、在Hive中创建表media_index 13
7.4统计各表宣传数据和政企用户记录数 14
1、统计各表宣传数据记录数 14
2、统计各表政企用户记录数 17
7.5统计无效收视数据 19
1、统计用户收视时长分布 19
2、统计机顶盒待机记录数 19
7.6处理各表无效数据 20
1、处理无效用户信息 20
2、处理无效收视数据 20
3、处理无效账单数据 21
4、处理无效订单数据 21
7.7计算用户电视消费水平和宽带消费水平 22
1、电视消费水平 22
2、宽带消费水平 23
3、将数据保存到MySQL 23
4、将数据保存到Hbase 23
7.2、将csv格式数据导入ElasticSearch
导数据前要:创建一个maven项目配置pom.xml文件导入对应的jar包。
分五个步骤导入(以下相关的java代码文件都存放在code文件夹下)
1、将mediamatch_usermsg.csv导入到ElasticSearch
创建UserMsgPut.java文件编写对应的上传步骤
上传后到http://192.168.2.100:9100/链接访问ElasticSearch-Head Web端查看elasticsearchsh数据,发现上传成功。
mediamatch_usermsg/data/_count
2、将mediamatch_userevent.csv导入到 ElasticSearch
创建UserEventPut.java编写对应的上传步骤
上传后到http://192.168.2.100:9100/链接访问ElasticSearch-Head Web端查看elasticsearchsh数据,发现上传成功。
mediamatch_userevent/data/_count
3、将mmconsume_billevents.csv 导入到ElasticSearch
创建BillEventsPut.java编写对应的上传步骤
上传后到http://192.168.2.100:9100/链接访问ElasticSearch-Head Web端查看elasticsearchsh数据,发现上传成功。
mmconsume_billevents/data/_count
4、将order_index.csv 导入到ElasticSearch
创建OrderIndexPut.java编写对应的上传步骤
上传后到http://192.168.2.100:9100/链接访问ElasticSearch-Head Web端查看elasticsearchsh数据,发现上传成功。
order_index/data/_count
5、将media_index.csv 导入到 ElasticSearch
创建MediaIndexPut.java编写对应的上传步骤
上传后到http://192.168.2.100:9100/链接访问ElasticSearch-Head Web端查看elasticsearchsh数据,发现上传成功。
media_index/data/_count
7.3转移ElasticSearch数据到Hive
1、在Hive中创建表mediamatch_usermsg
创建Hive和ElasticSearch的映射表,将mediamatch_usermsg的数据导入Hive表中。
SELECT count(*) FROM mediamatch_usermsg;
2、在Hive中创建表mediamatch_userevent
创建Hive和ElasticSearch的映射表,将mediamatch_userevent的数据导入Hive表中。
SELECT count(*) FROM mediamatch_userevent;
3、在Hive中创建表mmconsume_billevents
创建Hive和ElasticSearch的映射表,将mmconsume_billevents的数据导入Hive表中。
SELECT count(*) FROM mmconsume_billevents;
4、在Hive中创建表order_index
创建Hive和ElasticSearch的映射表,将order_index的数据导入Hive表中。
SELECT count(*) FROM order_index;
5、在Hive中创建表media_index
创建Hive和ElasticSearch的映射表,将media_index的数据导入Hive表中。
SELECT count(*) FROM media_index;
7.4统计各表宣传数据和政企用户记录数
1、统计各表宣传数据记录数
注释:在各个表中owner_code为02,09,10的数据为宣传数据。
(1)、统计media_index表中宣传数据的记录数
select count(*) from media_index where owner_code in ("02","09","10");
(2)、统计mediamatch_usermsg表中宣传数据的记录数
select count(*) from mediamatch_usermsg where owner_code in ("02","09","10");
(3)、统计mediamatch_userevent表中宣传数据的记录数
select count(*) from mediamatch_userevent where owner_code in ("02","09","10");
(4)、统计mmconsume_billevents表中宣传数据的记录数
select count(*) from mmconsume_billevents where owner_code in ("02","09","10");
(5)、统计order_index表中宣传数据的记录数
select count(*) from order_index where owner_code in ("02","09","10");
2、统计各表政企用户记录数
注释:在各个表中owner_name为"EA级","EB级","EC级","ED级","EE级"的数据记录为政企用户数据。
(1)、统计media_index表中的政企用户记录数
select count(terminal_no) from media_index where owner_name in ("EA级","EB级","EC级","ED级","EE级");
(2)、统计mediamatch_usermsg表中的政企用户记录数
select count(terminal_no) from mediamatch_usermsg where owner_name in ("EA级","EB级","EC级","ED级","EE级");
(3)、统计mmconsume_billevents表中的政企用户记录数
select count(terminal_no) from mmconsume_billevents where owner_name in ("EA级","EB级","EC级","ED级","EE级");
7.5统计无效收视数据
1、统计用户收视时长分布
2、统计机顶盒待机记录数
注释:同一节目的观看时长超过5小时,则认为机顶盒处于待机状态。
7.6处理各表无效数据
1、处理无效用户信息
注释:无效用户包括用户状态为被动销户、创建、冲正、销号的用户,以及宣传用户和政企用户,对这些字段进行清洗
2、处理无效收视数据
注释:无效收视数据为观看时长小于20秒或者观看时长大于5小时的数据,清洗无效收视数据。
3、处理无效账单数据
注释:无效账单数据是指mmconsume_billevents中的should_pay字段值小于0的记录。
4、处理无效订单数据
注释:无效订单数是指order_index中的cost字段为空的记录。