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

【hadoop】基于hive的B站用户行为大数据分析

1.需求分析

b站现在积累有用户数据和视频列表数据,为了配合市场部门做好用户运营工作,需要对b站的用户行为进行分析,其具体需求如下所示:

统计b站视频不同评分等级(行转列)的视频数。

统计上传b站视频最多的用户Top10,以及这些用户上传的视频观看次数在前10的视频。

统计b站每个类别视频观看数topn。

统计b站视频分类热度topn。

统计b站视频观看数topn。

2. 表结构

2.1 user 表结构

2.2 video 表结构

 3.准备工作

create database if not exists bibi_db;

3.1 创建 user 表

create table if not exists user
(uid int,
name string,
regtime string,
visitnum int,
lastvisit string,
gender int,
birthday string,
country string,
province string,
city string,
uploadvideos int)
row format delimited fields terminated by ",";

 3.2 创建 video 表

create table if not exists orc_video
(vid string,
uid int,
vday int,
vtype string,
vlength int,
visit int,
score int,
comments int,
collection int,
fabulous int,
forward int)
row format delimited fields terminated by ",";

4. 加载数据

数据集要先传到虚拟机指定位置(略)

load data local inpath "/home/hadoop/hadoop-2.9.2/study-hive-data/user.txt" into table user;
load data local inpath "/home/hadoop/hadoop-2.9.2/study-hive-data/video.txt" into table video;

5. 统计分析

统计b站视频观看数Topn

hive> select vid,visit from orc_video order by visit desc limit 3;

统计b站视频分类热度Topn

hive> select vtype,count(vid) hot from orc_video group by vtype order by hot desc limit 3;

统计每个类别视频观看数Topn

hive>  select v.vtype,v.vid,v.visit from   (select vtype,vid,visit,rank() over(partition by vtype order by visit desc) rk from orc_video) v where rk<=3; 

http://www.dtcms.com/a/138171.html

相关文章:

  • AMC8 -- 2019年真题解析(中文解析)
  • Vue项目Webpack Loader全解析:从原理到实战配置指南
  • OpenCV颜色变换cvtColor
  • linux安装node版本管理工具(nvm和fnm)
  • 【Axure绘制原型】图片切割、交互动效、热区、动态面板、元件显示隐藏、表单元件、表格、内联框架
  • 【ROS】DWA 规划器
  • 中介者模式(Mediator Pattern)
  • 基于Flask的网络安全渗透知识库系统架构解析
  • 系统架构设计(一):UML与软件架构
  • ICMAN防水触摸芯片 - 复杂环境下精准交互,提升触控体验
  • “盲水印”技术新标杆:blind_watermark加入GitCode
  • 008_ipc概述之socket套接字
  • 泛目录站群技术架构演进观察:2025年PHP+Java混合方案实战笔记​
  • Doris FE 常见问题与处理指南
  • 2025年4月16日华为留学生笔试第二题200分
  • 四大wordpress模板站
  • vscode与vim+cscope+tags热键冲突
  • Apifox下载安装与使用
  • Redis面试——事务
  • SpringBoot整合Rabbitmq(包括docker配置Rabbitmq的详细过程)
  • linux 学习 2.vim学习指南
  • Azure 私有端点和存储帐户用例
  • 2026《数据结构》考研复习笔记二(C++面向对象)
  • MVC/MVVM 高级应用的深度解析
  • 深入理解 Linux 权限管理:从 Shell 到文件权限
  • PyTorch生成式人工智能实战(1)——神经网络与模型训练过程详解
  • pytorch学习02
  • 人工智能 - browser-use:重新定义浏览器自动化的 AI 新范式
  • 【Leetcode 每日一题 - 补卡】2537. 统计好子数组的数目
  • 【Kubernetes基础--Service深入理解】--查阅笔记4