大大数据基础课程设计资料报告材料

上传人:pu****.1 文档编号:459254188 上传时间:2023-11-14 格式:DOC 页数:38 大小:1.11MB
返回 下载 相关 举报
大大数据基础课程设计资料报告材料_第1页
第1页 / 共38页
大大数据基础课程设计资料报告材料_第2页
第2页 / 共38页
大大数据基础课程设计资料报告材料_第3页
第3页 / 共38页
大大数据基础课程设计资料报告材料_第4页
第4页 / 共38页
大大数据基础课程设计资料报告材料_第5页
第5页 / 共38页
点击查看更多>>
资源描述

《大大数据基础课程设计资料报告材料》由会员分享,可在线阅读,更多相关《大大数据基础课程设计资料报告材料(38页珍藏版)》请在金锄头文库上搜索。

1、文档大数据根底课程设计报告一、项目简介:使用hadoop中的hive、mapreduce以与HBASE对网上的一个搜狗五百万的数进展了一个比拟实际的数据分析。搜狗五百万数据,是经过处理后的搜狗搜索引擎生产数据,具有真实性,大数据性,能够较好的满足分布式计算应用开发课程设计的数据要求。 搜狗数据的数据格式为:访问时间t 用户 IDt查询词t 该 URL 在返回结果中的排名t 用户点击的顺序号t 用户点击的 URL。其中,用户 ID 是根据用户使用浏览器访问搜索引擎时的 Cookie 信息自动赋值,即同一次使用浏览器输入的不同查询对应同一个用户 ID。二、操作要求1.将原始数据加载到HDFS平台。

2、 2.将原始数据中的时间字段拆分并拼接,添加年、月、日、小时字段。 3.将处理后的数据加载到HDFS平台。 4.以下操作分别通过MR和Hive实现。l 查询总条数l 非空查询条数l 无重复总条数l 独立UID总数l 查询频度排名频度最高的前50词l 查询次数大于2次的用户总数l 查询次数大于2次的用户占比l Rank在10以的点击次数占比l 直接输入URL查询的比例l 查询搜索过仙剑奇侠传“的uid,并且次数大于35.将4每步骤生成的结果保存到HDFS中。 6.将5生成的文件通过Java API方式导入到HBase一表。 7.通过HBase shell命令查询6导出的结果。三、实验流程1. 将

3、原始数据加载到HDFS平台2. 将原始数据中的时间字段拆分并拼接,添加年、月、日、小时字段(1) 编写1个脚本sogou-log-extend.sh,其中sogou-log-extend.sh的容为:#!/bin/bashinfile=$1outfile=$2awk -F t print $0tsubstr($1,0,4)年tsubstr($1,5,2)月tsubstr($1,7,2)日tsubstr($1,8,2)hour $infile $outfile处理脚本文件:结果为:3. 将处理后的数据加载到HDFS平台hadoop fs -put sogou.500w.utf8.ext /4.

4、以下操作分别通过MR和Hive实现.hive实现1.查看数据库:show databases;2.创建数据库: create database sogou;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;6.将本地数据导入到Hive表里:Load data local inpath /r

5、oot/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 !=;(3) 无重复总条数select count(*) from (select * from sogou group by time,num1,num2,uuid,name,url having count(*)=1) a;(4) 独立UID总数select count(d

6、istinct uuid) from sogou;(5) 查询频度排名频度最高的前50词select name,count(*) as pd from sogou group by name order by pd desc limit 50;6查询次数大于2次的用户总数 select count(a.uuid) from (select uuid,count(*) ast from sogou group by uuid havingt 2) a;7查询次数大于2次的用户占比select count(*) from (select uuid,count(*) ast from sogou g

7、roup by uuid havingt 2) a;(8) Rank在10以的点击次数占比select count(*) from sogou where num13;.MapReduce实现(import的各种包省略)(1) 查询总条数public class MRCountAll public static Integer i = 0; public static boolean flag = true; public static class CountAllMap extends Mapper Override protected void map(Object key, Text v

8、alue, Mapper.Context context) throws IOException, InterruptedException i+; public static void runcount(String Inputpath, String Outpath) Configuration conf = new Configuration(); conf.set(fs.defaultFS, hdfs:/10.49.47.20:9000); Job job = null; try job = Job.getInstance(conf, count); catch (IOExceptio

9、n e) / TODO Auto-generated catch block e.printStackTrace(); job.setJarByClass(MRCountAll.class); job.setMapperClass(CountAllMap.class); job.setOutputKeyClass(Text.class); job.setOutputValueClass(Text.class); try FileInputFormat.addInputPath(job, new Path(Inputpath); catch (IllegalArgumentException e

10、) / TODO Auto-generated catch block e.printStackTrace(); catch (IOException e) / TODO Auto-generated catch block e.printStackTrace(); FileOutputFormat.setOutputPath(job, new Path(Outpath); try job.waitForpletion(true); catch (ClassNotFoundException e) / TODO Auto-generated catch block e.printStackTr

11、ace(); catch (IOException e) / TODO Auto-generated catch block e.printStackTrace(); catch (InterruptedException e) / TODO Auto-generated catch block e.printStackTrace(); public static void main(String args) throws Exception runcount(/sogou/data/sogou.500w.utf8, /sogou/data/CountAll); System.out.prin

12、tln(总条数: + i); (2) 非空查询条数public class CountNotNull public static String Str = ; public static int i = 0; public static boolean flag = true; public static class wyMap extends Mapper Override protected void map(Object key, Text value, Mapper.Context context) throws IOException, InterruptedException String values = value.toString().split(t); if (!values2.equals(null) & values2 != ) context.write(new Text(values1), new IntWritable(1); i+

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 建筑/环境 > 施工组织

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号