当前位置: 首页 > news >正文

湖北黄石域名注册网站建设今日新闻快讯

湖北黄石域名注册网站建设,今日新闻快讯,顺德做网站shundeit,沈阳建设工程信息网 采购甲方都在中项网目录1、聊天软件数据分析案例需求2、基于Hive数仓实现需求开发2.1 建库2.2 建表2.3 加载数据2.4 ETL数据清洗2.5 需求指标统计---都很简单3、FineBI实现可视化报表3.1 FineBI介绍3.2 FineBI配置数据3.3 构建可视化报表1、聊天软件数据分析案例需求 MR速度慢—引入hive 背景&a…

目录

    • 1、聊天软件数据分析案例需求
    • 2、基于Hive数仓实现需求开发
      • 2.1 建库
      • 2.2 建表
      • 2.3 加载数据
      • 2.4 ETL数据清洗
      • 2.5 需求指标统计---都很简单
    • 3、FineBI实现可视化报表
      • 3.1 FineBI介绍
      • 3.2 FineBI配置数据
      • 3.3 构建可视化报表

1、聊天软件数据分析案例需求

MR速度慢—引入hive

背景:大量的用户在线,通过对聊天数据的分析,构建用户画像,为用户提供更好的服务、以及实现高ROI的平台运营推广,给公司的发展决策提供精确的数据支撑。

目标:基于Hadoop和Hive实现聊天数据统计分析,构建聊天数据分析报表
在这里插入图片描述
需求:

  • 统计今日总消息量
  • 统计今日每小时消息量、发送和接收用户数
  • 统计今日各地区发送消息数据量
  • 统计今日发送消息和接收消息的用户数
  • 统计今日发送消息最多的Top10用户
  • 统计今日接收消息最多的Top10用户
  • 统计发送人的手机型号分布情况
  • 统计发送人的设备操作系统分布情况

原始数据:业务系统中导出的某一天24小时的用户聊天数据,TSV文件。列分隔符:制表符 \t
在这里插入图片描述
在这里插入图片描述

2、基于Hive数仓实现需求开发

在Notepad中可以通过显示所有字符来判断间隔符

打开Datagrip,创建一个hive工程,语言选择hive,并与hive服务器创建连接。
Datagrip中:

2.1 建库

--------------1、建库---------------------如果数据库已存在就删除
drop database if exists db_msg cascade;
--创建数据库
create database db_msg;
--切换数据库
use db_msg;

2.2 建表

--------------2、建表-------------------
--如果表已存在就删除
drop table if exists db_msg.tb_msg_source;
--建表
create table db_msg.tb_msg_source(msg_time             string  comment "消息发送时间", sender_name        string  comment "发送人昵称", sender_account     string  comment "发送人账号", sender_sex         string  comment "发送人性别", sender_ip          string  comment "发送人ip地址", sender_os          string  comment "发送人操作系统", sender_phonetype   string  comment "发送人手机型号", sender_network     string  comment "发送人网络类型", sender_gps         string  comment "发送人的GPS定位", receiver_name      string  comment "接收人昵称", receiver_ip        string  comment "接收人IP", receiver_account   string  comment "接收人账号", receiver_os        string  comment "接收人操作系统", receiver_phonetype string  comment "接收人手机型号", receiver_network   string  comment "接收人网络类型", receiver_gps       string  comment "接收人的GPS定位", receiver_sex       string  comment "接收人性别", msg_type           string  comment "消息类型", distance           string  comment "双方距离", message            string  comment "消息内容"
)
--指定分隔符为制表符
row format delimited fields terminated by '\t';

2.3 加载数据

--------------3、加载数据-------------------
--上传数据文件到node1服务器本地文件系统(HS2服务所在机器)
--shell:  mkdir -p /root/hivedata--加载数据到表中
load data local inpath '/root/hivedata/data1.tsv' into table db_msg.tb_msg_source;
load data local inpath '/root/hivedata/data2.tsv' into table db_msg.tb_msg_source;--查询表 验证数据文件是否映射成功
select * from tb_msg_source limit 10;--统计行数
select count(*) as cnt from tb_msg_source;

在这里插入图片描述

2.4 ETL数据清洗

加载完数据后,需要判断加载过来的数据是否有效–ETL
问题与解决:

  • sender_gps字段有些记录为空,如何处理? – where length(sender_gps) =0筛选出非空的
  • 时间字段,只需要提取中间的小时信息? —substr(字段,12,1)提取小时
  • GPS经纬度是一个字段,需要获取经纬度两个? — split(字段,‘,’)根据逗号进行字段切割
  • 将ETL处理后的结果保存到一张新hive表中?—CTAS语法
    create table … as select … 表结构和数据全部都有了
--ETL实现
--如果表已存在就删除
drop table if exists db_msg.tb_msg_etl;
--将Select语句的结果保存到新表中
create table db_msg.tb_msg_etl as
select*,substr(msg_time,0,10) as dayinfo, --获取天substr(msg_time,12,2) as hourinfo, --获取小时split(sender_gps,",")[0] as sender_lng, --提取经度split(sender_gps,",")[1] as sender_lat --提取纬度
from db_msg.tb_msg_source
--过滤字段为空的数据
where length(sender_gps) > 0 ;

数据量太多–记得limit 10

--验证ETL结果
selectmsg_time,dayinfo,hourinfo,sender_gps,sender_lng,sender_lat
from db_msg.tb_msg_etl
limit 10;

2.5 需求指标统计—都很简单

需求1:统计今日总消息量
group by 每日后count计数

create table if not exists tb_rs_total_msg_cnt 
comment "今日消息总量"
as
selectdayinfo,count(*) as total_msg_cnt
from db_msg.tb_msg_etl
group by dayinfo;select * from tb_rs_total_msg_cnt;--结果验证

需求2:统计今日每小时消息量、发送和接收用户数
按每天,每小时分组,计数

create table if not exists tb_rs_hour_msg_cnt
comment "每小时消息量趋势"
as
selectdayinfo,hourinfo,count(*) as total_msg_cnt,count(distinct sender_account) as sender_usr_cnt,count(distinct receiver_account) as receiver_usr_cnt
from db_msg.tb_msg_etl
group by dayinfo,hourinfo;select * from tb_rs_hour_msg_cnt;--结果验证

需求3:统计今日各地区发送消息数据量
按照每日与地区GPS分组,

出现在select后的字段,要么是group by 后的字段,要么是聚合函数字段,所以分组还加了经纬度字段。

case函数:将原本经纬度的string类型转换成double数字类型
cast(sender_lng as double)

create table if not exists tb_rs_loc_cnt
comment "今日各地区发送消息总量"
as
selectdayinfo,sender_gps,cast(sender_lng as double) as longitude,cast(sender_lat as double) as latitude,count(*) as total_msg_cnt
from db_msg.tb_msg_etl
group by dayinfo,sender_gps,sender_lng,sender_lat;select * from tb_rs_loc_cnt; --结果验证

需求4:统计今日发送消息和接收消息的用户数

按照天分组,对用户数进行去重统计

create table if not exists tb_rs_usr_cnt
comment "今日发送消息人数、接受消息人数"
as
selectdayinfo,count(distinct sender_account) as sender_usr_cnt,count(distinct receiver_account) as receiver_usr_cnt
from db_msg.tb_msg_etl
group by dayinfo;select * from tb_rs_usr_cnt; --结果验证

需求5:统计今日发送消息最多的Top10用户
按照天,用户分组,计数后排序,limit 10

create table if not exists tb_rs_susr_top10
comment "发送消息条数最多的Top10用户"
as
selectdayinfo,sender_name as username,count(*) as sender_msg_cnt
from db_msg.tb_msg_etl
group by dayinfo,sender_name
order by sender_msg_cnt desc
limit 10;select * from tb_rs_susr_top10; --结果验证

需求6:统计今日接收消息最多的Top10用户
按照天,用户分组,计数后排序,limit 10

create table if not exists tb_rs_rusr_top10
comment "接受消息条数最多的Top10用户"
as
selectdayinfo,receiver_name as username,count(*) as receiver_msg_cnt
from db_msg.tb_msg_etl
group by dayinfo,receiver_name
order by receiver_msg_cnt desc
limit 10;select * from tb_rs_rusr_top10;  --结果验证

需求7:统计发送人的手机型号分布情况
按照天,用户手机型号分组,对用户去重计数

create table if not exists tb_rs_sender_phone
comment "发送人的手机型号分布"
as
selectdayinfo,sender_phonetype,count(distinct sender_account) as cnt
from tb_msg_etl
group by dayinfo,sender_phonetype;select * from tb_rs_sender_phone; --结果验证

需求8:统计发送人的设备操作系统分布情况

create table if not exists tb_rs_sender_os
comment "发送人的OS分布"
as
selectdayinfo,sender_os,count(distinct sender_account) as cnt
from tb_msg_etl
group by dayinfo,sender_os;select * from tb_rs_sender_os;  --结果验证

3、FineBI实现可视化报表

进入可视化展示阶段

3.1 FineBI介绍

FineBI:https://www.finebi.com/
FineBI特点:可多人协作、拖拽不需要代码、适合各种分析场景、支持各种图表、支持大数据
已下载安装好

3.2 FineBI配置数据

将hive中数据连接到BI上。
FineBI与Hive集成的官方文档:https://help.fanruan.com/finebi/doc-view-301.html

驱动配置、安装插件-----都配置好了,可直接连接hive数据
配置数据操作

3.3 构建可视化报表

FineBI上各种拖拽操作

最后效果:
在这里插入图片描述

总结:很简单的一个案例,但把数据分析的整个流程走完了


文章转载自:
http://deserter.spfh.cn
http://consilience.spfh.cn
http://analytics.spfh.cn
http://amnestic.spfh.cn
http://euphorigenic.spfh.cn
http://negev.spfh.cn
http://machinable.spfh.cn
http://experienced.spfh.cn
http://irascibility.spfh.cn
http://thibet.spfh.cn
http://nasrani.spfh.cn
http://galaxy.spfh.cn
http://handgrip.spfh.cn
http://bindin.spfh.cn
http://unionization.spfh.cn
http://nonpros.spfh.cn
http://gentlefolk.spfh.cn
http://chorioallantois.spfh.cn
http://docent.spfh.cn
http://ampliate.spfh.cn
http://ascribable.spfh.cn
http://gravesian.spfh.cn
http://vibrator.spfh.cn
http://tannin.spfh.cn
http://shadrach.spfh.cn
http://dreamily.spfh.cn
http://besought.spfh.cn
http://paiute.spfh.cn
http://centrifugalization.spfh.cn
http://comedienne.spfh.cn
http://urbanology.spfh.cn
http://panties.spfh.cn
http://culver.spfh.cn
http://zingaro.spfh.cn
http://pratincole.spfh.cn
http://xylophagous.spfh.cn
http://franc.spfh.cn
http://juneau.spfh.cn
http://cuspidated.spfh.cn
http://bandage.spfh.cn
http://haematein.spfh.cn
http://xystarch.spfh.cn
http://ladderway.spfh.cn
http://electroencephalogram.spfh.cn
http://vri.spfh.cn
http://purgatorial.spfh.cn
http://fatted.spfh.cn
http://rotameter.spfh.cn
http://cystostomy.spfh.cn
http://cockcrowing.spfh.cn
http://repentance.spfh.cn
http://collodium.spfh.cn
http://superscribe.spfh.cn
http://biostratigraphic.spfh.cn
http://kilobaud.spfh.cn
http://illude.spfh.cn
http://ayudhya.spfh.cn
http://haet.spfh.cn
http://dishful.spfh.cn
http://appendix.spfh.cn
http://unread.spfh.cn
http://vaporous.spfh.cn
http://reproval.spfh.cn
http://pedicab.spfh.cn
http://horticulture.spfh.cn
http://littery.spfh.cn
http://shoehorn.spfh.cn
http://transuranic.spfh.cn
http://artificiality.spfh.cn
http://defibrinate.spfh.cn
http://attractive.spfh.cn
http://tripey.spfh.cn
http://barcarolle.spfh.cn
http://anhyd.spfh.cn
http://taibei.spfh.cn
http://mmhg.spfh.cn
http://scurvy.spfh.cn
http://sestet.spfh.cn
http://zed.spfh.cn
http://nome.spfh.cn
http://pathogeny.spfh.cn
http://laid.spfh.cn
http://hac.spfh.cn
http://giggit.spfh.cn
http://oopm.spfh.cn
http://phosphonium.spfh.cn
http://filamerican.spfh.cn
http://withdraw.spfh.cn
http://porphyropsin.spfh.cn
http://bleaching.spfh.cn
http://stiffly.spfh.cn
http://cyclophosphamide.spfh.cn
http://biphenyl.spfh.cn
http://nephrogenic.spfh.cn
http://maryology.spfh.cn
http://inarticulately.spfh.cn
http://apogee.spfh.cn
http://metric.spfh.cn
http://taboo.spfh.cn
http://polarize.spfh.cn
http://www.15wanjia.com/news/100396.html

相关文章:

  • 政府网上商城采购流程优化大师电视版
  • 网站开发和设计如何合作百度竞价返点开户
  • 网站建设流程信息超级seo外链工具
  • 管理系统的组成株洲seo优化首选
  • 怎样在在农行网站上做风险评估快速优化排名公司推荐
  • 做直播网站宽带seo是什么意思
  • 网站建设中什么页面结构搭建一个网站的流程
  • 合肥网站建设=388元北京seo推广公司
  • 推荐邵阳网站建设seo优化排名
  • 一个人免费观看高清在线观看网络优化基础知识
  • 聊城手机网站建设软件网站建设策划书案例
  • php程序员网站开发建设全网营销推广公司
  • 乡镇实体化大团委建设网站分销系统
  • 7000元买一个域名做网站网站推广途径和推广要点有哪些?
  • 建设学院实验室网站的作用最新国际要闻
  • 桂林建设网站公司如何交换优质友情链接
  • 做网站单线程CPU和多线程cpu百度推广代理赚钱
  • 教你如何建立网站青岛网站建设制作
  • 这个网站做海外推广广西seo
  • 易语言如何建设网站百度app下载安装普通下载
  • 温州网站建设模板下载免费惠州seo网站排名
  • 网站建设重要性郑州网站seo外包
  • 太平洋手机官网seo咨询解决方案
  • 网站开发微信登录流程网站模板设计
  • 做的页面好看的网站百度移动
  • 8图片这样的网站怎么做的微信营销技巧
  • 炫酷的企业网站模板2022年度关键词
  • 温州云海和联欣哪个做网站比较好免费网络推广工具
  • 广西网站建设哪里好杭州seo网络推广
  • 淘宝客做网站怎样推广关键词搜索引擎工具