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

做网站的顶部图片wordpress 分类采集

做网站的顶部图片,wordpress 分类采集,保定哪家公司做网站,wordpress响应式图片功能数据倾斜#xff1a;主要就是在处理MR任务的时候#xff0c;某个reduce的数据处理量比另外一些的reduce的数据量要大得多#xff0c;其他reduce几乎不处理#xff0c;这样的现象就是数据倾斜。 官方解释#xff1a;数据倾斜指的是在数据处理过程中#xff0c;由于某些键…数据倾斜主要就是在处理MR任务的时候某个reduce的数据处理量比另外一些的reduce的数据量要大得多其他reduce几乎不处理这样的现象就是数据倾斜。 官方解释数据倾斜指的是在数据处理过程中由于某些键的分布极度不均匀导致某些节点处理的数据量显著多于其他节点。‌这种情况会引发性能瓶颈阻碍任务的并行执行增加作业的整体执行时间。在Hadoop的MapReduce作业中数据倾斜尤为明显因为它会导致某些Reduce任务处理的数据量远大于其他任务从而造成集群整体处理效率低下的问题。 这里比如有一个文本数据里面内容全是hadoop, hadoop, hadoop,hadoop ....,假设有800万条数据这样更容易显示数据倾斜的效果里面都是同样的单词默认的hash取余分区的方法明显不太适合所以我们要自定义分区重写分区方法。以及设置多个reduce这里我设置为3主要就是对数据倾斜的key进行一个增加后缀的方法以及在Map阶段就增加后缀实现过程是将每个hadoop都进行增加后缀刚开始会全部默认存放到第一个分区里0分区然后写到分区后自定义分区方法SkewPartitioner就会对里面的数据进行分析如果后缀是1就分到1区里面一共就0、1、2三个分区以此来解决数据倾斜的问题。 注意在Job端进行自定义分区器的设置job,setPartitionerClass(SkewPartitioner.class) 具体代码如下 package com.shujia.mr;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.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Partitioner; 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;public class Demo05SkewDataMR {public static class MyMapper extends MapperLongWritable, Text, Text, IntWritable {Overrideprotected void map(LongWritable key, Text value, MapperLongWritable, Text, Text, IntWritable.Context context) throws IOException, InterruptedException {String line value.toString();// 将每一行数据按照逗号/空格进行切分for (String word : line.split([,\\s])) {// 使用context.write将数据发送到下游// 将每个单词变成 单词,1 形式// 对数据倾斜的Key加上随机后缀if (hadoop.equals(word)) {// 随机生成 0 1 2int prefix (int) (Math.random() * 3);context.write(new Text(word _ prefix), new IntWritable(1));} else {context.write(new Text(word), new IntWritable(1));}}}}public static class MyReducer extends ReducerText, IntWritable, Text, IntWritable {Overrideprotected void reduce(Text key, IterableIntWritable values, ReducerText, IntWritable, Text, IntWritable.Context context) throws IOException, InterruptedException {// 统计每个单词的数量int cnt 0;for (IntWritable value : values) {cnt cnt value.get();}context.write(key, new IntWritable(cnt));}}// Driver端组装调度及配置任务// 可以通过args接收参数// 本任务接收两个参数输入路径、输出路径public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {Configuration conf new Configuration();// 创建JobJob job Job.getInstance(conf);// 配置任务job.setJobName(Demo05SkewDataMR);job.setJarByClass(Demo05SkewDataMR.class);// 设置自定义分区器job.setPartitionerClass(SkewPartitioner.class);// 手动设置Reduce的数量// 最终输出到HDFS的文件数量等于Reduce的数量job.setNumReduceTasks(3);// 配置Map端job.setMapperClass(MyMapper.class);job.setMapOutputKeyClass(Text.class);job.setMapOutputValueClass(IntWritable.class);// 配置Reduce端job.setReducerClass(MyReducer.class);job.setOutputKeyClass(Text.class);job.setOutputValueClass(IntWritable.class);// 验证args的长度if (args.length ! 2) {System.out.println(请传入输入输出目录);return;}String input args[0];String output args[1];// 配置输入输出的路径FileInputFormat.addInputPath(job, new Path(input));Path ouputPath new Path(output);// 通过FileSystem来实现覆盖写入FileSystem fs FileSystem.get(conf);if (fs.exists(ouputPath)) {fs.delete(ouputPath, true);}// 该目录不能存在会自动创建如果已存在则会直接报错FileOutputFormat.setOutputPath(job, ouputPath);// 启动任务// 等待任务的完成job.waitForCompletion(true);} }// 自定义分区在Map阶段给key加上随机后缀基于后缀返回不同的分区编号 class SkewPartitioner extends PartitionerText, IntWritable {Overridepublic int getPartition(Text text, IntWritable intWritable, int numPartitions) {String key text.toString();int partitions 0;// 只对数据倾斜的key做特殊处理if (hadoop.equals(key.split(_)[0])) {switch (key) { // case hadoop_0: // partitions 0; // break;case hadoop_1:partitions 1;break;case hadoop_2:partitions 2;break;}} else {// 正常的key还是按照默认的Hash取余进行分区partitions (key.hashCode() Integer.MAX_VALUE) % numPartitions;}return partitions;} }
http://www.hkea.cn/news/14311070/

相关文章:

  • 自己做网站做淘宝联盟电脑城网站开发需求分析
  • 杭州包装网站建设方案wordpress 浏览次数
  • 装饰公司网站源码下载做个医院网站多少钱
  • 大型电商网站开发方案网页设计教育培训
  • ie的常用网站外贸网站如何换域名
  • 中国电商排名前十名seo外包公司哪家专业
  • wordpress网站维护中只有一个页面的网站
  • 怎么把统计代码加到网站弄一个app要多少钱
  • 网站模板建设二月网站建设南宁
  • 修改网站主目录的位置股票网站模板 dedecms
  • 手机网站微信分享代码随州seo优化
  • 如何用电脑记事本做网站如何查找网站死链
  • 网站 栏目添加 文章不显示网站内容通过服务器会不会被更改
  • 免费做网站报价科技网站制作
  • esc怎么做网站上海专业网站建设价
  • 农业电商网站建设pptcom域名需要备案吗
  • 珠海网站建设公建筑模板质量标准
  • 企业展示型电商网站模板建设网站的意义 作用是什么
  • 创一家网站写出网站建设的基本流程
  • 无锡论坛网本地网站大型企业网络建设方案
  • 广州黄埔做网站的公司开创集团网站建设
  • 网站首页添加浮动飘窗统一门户网站建设规范
  • 厦门营销网站制作linux 安装wordpress
  • 宣讲网站建设松江佘山网站建设
  • html5 php 网站源码一般制作一个app需要多少钱
  • 河北建网站电子商务网站建设与管理—李建忠
  • 怎么申请一个商城网站.桐城住房和城乡建设局网站
  • 啥网站都能看的浏览器超市网站开发建设建议
  • 代理厦门网站设计公司无货源电商怎样
  • 做网站 微信开发前景郑州企业网站模板建站