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

网站开发项目方案较便宜的网站建设

网站开发项目方案,较便宜的网站建设,网站风格类型是,设计教育机构一、简介 求和是统计中最常使用到的#xff0c;现在使用Mapreduce在海量数据中统计数据的求和。 二、例子 #xff08;1#xff09;实例描述 给出三个文件#xff0c;每个文件中都存储了若干个数值#xff0c;求所有数值中的求和。 样例输入#xff1a; …一、简介 求和是统计中最常使用到的现在使用Mapreduce在海量数据中统计数据的求和。 二、例子 1实例描述 给出三个文件每个文件中都存储了若干个数值求所有数值中的求和。 样例输入                                             1file1   1 2 3 7 9 -99 2 2file2   11 2 23 17 9 199 22 3file3   21 12 3 17 2 39 12 期望输出 314 2问题分析 实现统计海量数据的求和不能将所有的数据加载到内存计算只能使用类似外部排序的方式加载一部分数据统计求和接着加载另一部分进行统计。 3实现步骤 1Map过程      首先使用默认的TextInputFormat类对输入文件进行处理得到文本中每行的偏移量及其内容。显然Map过程首先必须分析输入的key,value对得到数值然后在mapper中统计单个分块的求和。 2Reduce过程      经过map方法处理后Reduce过程将获取每个mapper的求和进行统计分行统计出总的求和。 3关键代码 package com.mk.mapreduce;import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;import java.io.IOException; import java.net.URI;public class SumValue {public static class SumValueMapper extends MapperLongWritable, Text, IntWritable, NullWritable {private int sumValue 0;Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {if (StringUtils.isBlank(value.toString())) {System.out.println(空白行);return;}int v Integer.parseInt(value.toString().trim());sumValue sumValue v;}Overrideprotected void cleanup(Context context) throws IOException, InterruptedException {context.write( new IntWritable(sumValue), NullWritable.get());}}public static class SumValueReducer extends Reducer IntWritable, NullWritable,IntWritable, NullWritable {private int sumValue 0;Overrideprotected void reduce(IntWritable key, IterableNullWritable values, Context context) throws IOException, InterruptedException {int v key.get();sumValue sumValue v;}Overrideprotected void cleanup(Context context) throws IOException, InterruptedException {context.write( new IntWritable(sumValue), NullWritable.get());}}public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {String uri hdfs://192.168.150.128:9000;String input /sumValue/input;String output /sumValue/output;Configuration conf new Configuration();if (System.getProperty(os.name).toLowerCase().contains(win))conf.set(mapreduce.app-submission.cross-platform, true);FileSystem fileSystem FileSystem.get(URI.create(uri), conf);Path path new Path(output);fileSystem.delete(path, true);Job job new Job(conf, SumValue);job.setJar(./out/artifacts/hadoop_test_jar/hadoop-test.jar);job.setJarByClass(SumValue.class);job.setMapperClass(SumValueMapper.class);job.setReducerClass(SumValueReducer.class);job.setMapOutputKeyClass(IntWritable.class);job.setMapOutputValueClass(NullWritable.class);job.setOutputKeyClass(IntWritable.class);job.setOutputValueClass(NullWritable.class);FileInputFormat.addInputPaths(job, uri input);FileOutputFormat.setOutputPath(job, new Path(uri output));boolean ret job.waitForCompletion(true);System.out.println(job.getJobName() ----- ret);} }
http://www.pierceye.com/news/894731/

相关文章:

  • 网站建设主要职责六安网站建设
  • wordpress电影站主题一般做兼职在哪个网站
  • 可信网站友链怎么做网站建设行业标准
  • 济南营销网站制作公司哪家好口碑好的家装前十强
  • 公司网站开发费账务处理做图表的网站推荐
  • 网站如何做好用户体验wordpress 文章类
  • 做采集网站的方法世界四大广告公司
  • 做断桥铝窗户的网站宿州推广公司
  • 网站优化制作东莞房价一览表
  • 屏显的企业网站应该怎么做沈阳网站推广优化公司哪家好
  • 外包服务有哪些汕头seo网站建设
  • 新公司网站怎么做推广wordpress 中文 seo 插件
  • 网站建设客户分析国家企业信息公示网(广东)
  • php网站开发技术文档天津市装修公司排名榜
  • qq群优惠券里面网站怎么做的长春网站建设找源晟
  • 如何建一个公司的网站百度快速收录入口
  • 网络市场营销湘潭seo优化
  • 网站建设的模块传奇合成版2合1雷霆版手游
  • wordpress快站怎么样js网站开发视频
  • 滕州市 网站建设公司合肥网站建设方案案例
  • 外贸网站推广企业ida设计公司上海
  • 网站怎么做图片转链湄潭建设局官方网站
  • 泰州品牌网站建设二建报名时间2023年报名时间
  • 企业网站优化兴田德润怎么样wordpress标签不输出文章
  • 百度站长平台论坛永嘉网站制作
  • 月嫂公司网站建设构思免费的短视频素材库
  • 2017做哪些网站致富邢台市行政区划图
  • 深圳和海枫建设集团有限公司网站国内外基于vue框架的网站建设现状
  • 珠海免费网站制作购物网站前台模板
  • 小程序软件制作网站捷克注册公司网站