下载此文档

Hadoop使用.ppt


文档分类:IT计算机 | 页数:约19页 举报非法文档有奖
1/19
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/19 下载此文档
文档列表 文档介绍
Hadoop 使用聂志 niezhixuesen@ outline 2. Hadoop 使用 3. Mapreduce 详解 1云计算概念?概念?狭义云计算是指 IT基础设施的交付和使用模式,通过网络以按需、易扩展的方式获得所需的资源(硬件、平台、软件)。?广义云计算是指服务的交付和使用模式,通过网络以按需、易扩展的方式获得所需的服务。这种服务可以是 IT和软件、互联网相关的,也可以是任意其他的服务。?三层模型? Saas : more ? Paas : hadoop ? Iaas : openstack 2017-3-8 google vs hadoop Google calls it: Hadoop equivalent: MapReduce Hadoop GFS HDFS Bigtable HBase Chubby Zookeeper 2 Hadoop 使用?编写 map 和 reduce 函数?运行测试–命令行运行– eclipse 运行?查看结果 2017-3-8 map public static class TokenizerMapper extends Mapper<Object, Text , Text, IntWritable >{ private final static IntWritable one = new IntWritable(1); private Text word = new Text(); public void map(Object key, Text value, Context context ) throws IOException, InterruptedException { StringTokenizer itr = new StringTokenizer(()); while (()) { (()); (word, one); //设置 key value } } }说明: map 的输出 key 、 value 和 reduce 的输入 key 、 value 要一致,见上面红色部分 reduce public static class IntSumReducer extends Reducer< Text,IntWritable ,Text,IntWritable> { private IntWritable result = new IntWritable(); public void reduce(Text key, Iterable<IntWritable> values, Context context ) throws IOException, InterruptedException { int sum = 0; for (IntWritable val : values) { sum += (); // 聚集操作 } (sum); (key, result); } }说明: map 的输出 key 、 value 和 reduce 的输入 key 、 value 要一致,见上面红色部分 2017-3-8 Job 配置 public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs(); if ( != 2) { ("Usage: wordcount <in> <out>"); (2); } Job job = new Job(conf

Hadoop使用 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数19
  • 收藏数0 收藏
  • 顶次数0
  • 上传人wz_198622
  • 文件大小881 KB
  • 时间2017-03-08
最近更新