ハイブ戦闘オーディオおよびビデオシステム
-
私はプライベート送信するために必要なデータがある場合(Https://download.csdn.net/download/kevin__durant/11798895)も、このような点
-
↓テーブル名に対応するデータ形式の前に9行、最後の対応関連動画
-
LKh7zAJ4nwo TheReceptionist 653 Entertainment 424 13021 4.34 1305 744 DjdA-5oKYFQ NxTDlnOuybo c-8VuICzXtU DH56yrIO5nI W1Uo5DQTtzc E-3zXq_r4w0 1TCeoRPg5dE yAr26YhuYNY 2ZgXx72XmoE -7ClGo-YgZ0 vmdPOOd6cxI KRHfMQqSHpk pIMpORZthYw 1tUDzOp10pk heqocRij5P0 _XIuvoH6rUg LGVU5DsezE0 uO2kj6_D8B4 xiDqywcDQRM uX81lMev6_o
要件の説明
従来の統計的な指標シリコンバレーのビデオサイトのビデオ、さまざまな上位Nの指標:
- ビデオの視聴統計の数トップ10
- 統計トップ10の熱ビデオカテゴリー
- ビデオ鑑賞統計Top20はカテゴリの数
- 動画に関連したビデオを見るカテゴリーランク統計TOP50番号
- ビデオトップ10の熱のカテゴリごとの統計情報
- 各カテゴリのトップ10のためのビデオトラフィック統計
- ほとんどのユーザーのアップロード動画の統計トップ10とそのアップロードした動画
- 動画の数は、各カテゴリのトップ10の統計情報を表示します
プロジェクト
データの構造
1。ビデオを見ます
表6-13ビデオ・テーブル
フィールド | リマーク | 詳細な説明 |
---|---|---|
動画ID | ビデオの一意のID | 11の文字列 |
アップローダー | 動画アップローダー | ユーザー名の文字列は、動画をアップロード |
年齢 | ビデオ年齢 | 整数の日のプラットフォーム上のビデオ |
カテゴリー | 動画カテゴリ | アップロード動画は、動画の分類を指定しました |
長さ | ビデオの長さ | デジタルIDを形作るビデオの長さ |
景色 | ビュー | 動画が閲覧された回数 |
割合 | ビデオの評価 | 5のうち、 |
評価 | フロー | ビデオトラフィック、整数 |
conments | レビュー | コメントの整数の動画 |
関連IDS | 関連動画ID | 20までのidビデオ |
2。ユーザーテーブル
表6-14ユーザ・テーブル
フィールド | リマーク | フィールドタイプ | |
---|---|---|---|
アップローダー | ユーザー名でアップロード | ストリング | |
ビデオ | 動画の数は、アップロードされました | int型 | |
友人 | 友人の数 | int型 |
2 ETL生データ
ビデオは、複数の素子、及び関連ビデオの複数を有することも可能である見つけることができる生データの形態を観察することにより、各カテゴリアンパサンド分割され、分割された空白文字の両側でビデオカテゴリの複数あってもよいです使用「\トン」セグメンテーション。データ分析を操作データサブ要素が複数存在することを容易にするために、我々最初のデータ組換え洗浄操作。すなわち:「&」スプリットを持つすべてのカテゴリ、明確なスペース、関連動画IDを使用「&」セグメンテーションの複数を除去しながら。
- ディレクトリ内の生データは、データは、MapReduceのを清掃ここで使用しました
データクリーニング
クリーニングツール
public String dataRinse(String str){
String[] split = str.split("\t");
//过滤没有视频的用户
if (split.length<9){
return "";
}
//将用户中的空格替换掉
split[3] = split[3].replaceAll(" ","");
//将后面的视频的数据合并为&分割的数据
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < split.length; i++) {
if (i<9){
if (i==split.length-1){
stringBuilder.append(split[i]);
}else {
stringBuilder.append(split[i]).append("\t");
}
}else {
if (i==split.length-1){
stringBuilder.append(split[i]);
}else {
stringBuilder.append(split[i]).append("&");
}
}
}
return stringBuilder.toString();
}
public static void main(String[] args) {
String s = new ETLUtil().dataRinse("uFoWXi25RBk");
System.out.println(s);
}
清掃終了マッパー
public class ETLMapper extends Mapper<LongWritable , Text , Text , NullWritable> {
Text k = new Text();
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
//获得数据
String line = value.toString();
//清洗
String s = new ETLUtil().dataRinse(line);
k.set(s);
//输出
context.write(k , NullWritable.get());
}
}
ドライブドライバをきれいに
public class ETLDriver implements Tool {
private Configuration configuration;
public int run(String[] args) throws Exception {
Job job = Job.getInstance(getConf());
job.setJarByClass(ETLDriver.class);
job.setMapperClass(ETLMapper.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(NullWritable.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(NullWritable.class);
job.setNumReduceTasks(0);
FileInputFormat.setInputPaths(job,new Path(args[0]));
FileOutputFormat.setOutputPath(job,new Path(args[1]));
boolean b = job.waitForCompletion(true);
return b ? 0 : 1;
}
public void setConf(Configuration conf) {
this.configuration = conf;
}
public Configuration getConf() {
return configuration;
}
public static void main(String[] args) throws Exception {
int run = ToolRunner.run(new ETLDriver(), args);
System.out.println(run);
}
}
- クリーンVedioのの実装
ハイブデータ分析
テーブルを作成するには
- 创建表:gulivideo_ori gulivideo_user_ori
create table gulivideo_ori(
videoId string,
uploader string,
age int,
category array<string>,
length int,
views int,
rate float,
ratings int,
comments int,
relatedId array<string>)
row format delimited
fields terminated by "\t"
collection items terminated by "&"
stored as textfile;
create table gulivideo_user_ori(
uploader string,
videos int,
friends int)
row format delimited
fields terminated by "\t"
stored as textfile;
データのインポート
- ユーザが直接インポートテーブルのデータをロードすることができた後の映像データは、前にテーブルをインポート
ビジネス分析
ビデオの視聴の統計トップ10番号
- 単一のテーブルのページングの直接配列決定
select uploader,views
from gulivideo_ori
order by views desc
limit 10;
統計ビデオカテゴリトップ10の熱
select 3.取出前十
t3.cate,t3.cou_cate
from
(
select 2.统计没类的热度
t2.cate cate , count(*) cou_cate
from
(
select t1.ca cate 1.将类别炸开
from gulivideo_ori lateral view explode(category) t1 as ca
)t2
group by t2.cate
)t3
order by t3.cou_cate
limit 10
ビデオ視聴統計Top20はカテゴリの数
select 3.对相同类别去重
distinct(cate)
from
(
select 2.取出前二十观看数,类别,和视频id
cate,views,videoid
from
(
select t1.ca cate,videoid,views 1.将类别炸开
from gulivideo_ori lateral view explode(category) t1 as ca
)t2
order by views desc
limit 20
)t3
ビデオ鑑賞ビデオカテゴリーランクに関連付けられた統計TOP50番号
select 5.排序rank
*
from
(
select 4.将合并的表的类别字段炸开,对组进行分组,统计count
t4.category , count(*) hot
from
(
select 3.然后与原表再连接join
*
from
(
select 2.因为关联视频字段是数组,将其炸开并对相关视频字段去重
distinct(relatedids_name)
from
(
select * 1.取出观看次数top50
from gulivideo_ori
order by views desc
limit 50
)t1
lateral view explode(t1.relatedid) relatedids_t as relatedids_name
)t2
join gulivideo_ori t3
where t2.relatedids_name=t3.videoid
)t4
lateral view explode(t4.category) category_t as category_name
group by t4.category
)t5
order by t5.hot desc
-
ここではいくつかのビジネスクラスは、インポート一時テーブルに爆発し、それを爆破ファーストクラスのテーブルの形で満たされる必要があります
-
create table gulivideo_category( videoId string, uploader string, age int, categoryId string, length int, views int, rate float, ratings int, comments int, relatedId array<string>) row format delimited fields terminated by "\t" collection items terminated
-
insert into table gulivideo_category select videoId, uploader, age, categoryId, length, views, rate, ratings, comments, relatedId from gulivideo_orc lateral view explode(category) catetory as categoryId;
動画トップ10の熱のカテゴリごとの統計
select 2.取出top10
t1.categoryId,
t1.views,
from
(
select 1.按类别分组,观看次数排序
categoryId,
views,
row_number() over(partition by categoryId order by views desc) rank
from gulivideo_category
)t1
where rank <= 10
各カテゴリのトップ10のためのビデオトラフィックの統計情報
select
t1.categoryId,
t1.ratings
from
(
select
categoryId,
ratings,
row_number() over(partition by categoryId order by ratings desc) rank
from gulivideo_category
)t1
where rank <= 10
ほとんどのユーザーは動画の統計トップ10をアップロードして、自分のビデオは、以前の20をアップロード景色
select
t2.uploader,
t2.views
from
(
select
*
from gulivideo_user_ori
order by videos desc
limit 20
)t1
join
(
select
*
from gulivideo_ori
)t2
where t1.uploader=t2.uploader
order by views desc
limit 20
各カテゴリのビデオビューの統計トップ10番号
select
t1.categoryId,
t1.views,
from
(
select
categoryId,
views,
row_number() over(partition by categoryId order by views desc) rank
from gulivideo_category
)t1
where rank <= 10