当前位置:文档之家› 大数据基础课程设计报告

大数据基础课程设计报告

(3)
select count(*) from (select * from sogou group by time,num1,num2,uuid,name,url having count(*)=1) a;
(4)
select count(distinct uuid) from sogou;
(5)
select name,count(*) as pd from sogou group by name order by pd desc limit 50;

select count(a.uuid) from (select uuid,count(*) as cnt from sogou group by uuid having cnt > 2) a;

select count(*) from (select uuid,count(*) as cnt from sogou group by uuid having cnt > 2) a;
大数据基础课程设计报告
一、项目简介:
使用hadoop中的hive、mapreduce以及HBASE对网上的一个搜狗五百万的数进行了一个比较实际的数据分析。搜狗五百万数据,是经过处理后的搜狗搜索引擎生产数据,具有真实性,大数据性,能够较好的满足分布式计算应用开发课程设计的数据要求。
搜狗数据的数据格式为:访问时间\t 用户 ID\t[查询词]\t 该 URL 在返回结果中的排名\t 用户点击的顺序号\t 用户点击的 URL。其中,用户 ID 是根据用户使用浏览器访问搜索引擎时的 Cookie 信息自动赋值,即同一次使用浏览器输入的不同查询对应同一个用户 ID。
@Override
protected void map(Object key, Text value, Mapper<Object, Text, Text, Text>.Context context)
throws IOException, InterruptedException {
i++;
}
}
public static void runcount(String Inputpath, String Outpath) {
6.将本地数据导入到Hive表里:Load data local inpath '/root/sogou.500w.utf8' into table sogou;
7.查看表信息:desc sogou;
(1)
select count(*) from sogou;
(2)
select count(*) from sogou where name is not null and name !='';
二、操作要求
1.将原始数据加载到HDFS平台。
2.将原始数据中的时间字段拆分并拼接,添加年、月、日、小时字段。
3.将处理后的数据加载到HDFS平台。
4.以下操作分别通过MR和Hive实现。
查询总条数
非空查询条数
无重复总条数
独立UID总数
查询频度排名(频度最高的前50词)
查询次数大于2次的用户总数
查询次数大于2次的用户占比

(1)
public class MRCountAll {
public static Integer i = 0;
public static boolean flag = true;
public static class CountAllMap extends Mapper<Object, Text, Text, Text> {
3.使用数据库: use sogou;
4.查看所有表:show tables;
5.创建sougou表:Create table sogou(time string,uuid string,name string,num1 int,num2 int,url string) Row format delimited fields terminated by '\t';
Rank在10以内的点击次数占比
直接输入URL查询的比例
查询搜索过”仙剑奇侠传“的uid,并且次数大于3
5.将4每步骤生成的结果保存到HDFS中。
6.将5生成的文件通过Java API方式导入到HBase(一张表)。
7.通过HBase shell命令查询6导出的结果。
ห้องสมุดไป่ตู้三、实验流程
1.
2.
(1)编写1个脚本sogou-log-extend.sh,其中sogou-log-extend.sh的内容为:
Configuration conf = new Configuration();
conf.set("fs.defaultFS", "hdfs://10.49.47.20:9000");
Job job = null;
try {
job = Job.getInstance(conf, "count");
#!/bin/bash
#in
infile=$1
#out
outfile=$2
awk -F '\t' '{print $0"\t"substr($1,0,4)"年\t"substr($1,5,2)"月\t"substr($1,7,2)"日\t"substr($1,8,2)"hour"}' $infile > $outfile
} catch (IOException e) {
处理脚本文件:
bash sogou-log-extend.sh sogou.500w.utf8 sogou.500w.utf8.ext
结果为:
3.
hadoop fs -put sogou.500w.utf8.ext /
4.

1.查看数据库:show databases;
2.创建数据库: create database sogou;
(8)
select count(*) from sogou where num1<11;
(9)
select count(*) from sogou where url like '%www%';
(10)
select uuid ,count(*) as uu from sogou where name='仙剑奇侠传' group by uuid having uu>3;
相关主题