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

删除windows wordpress公司seo是指什么意思

删除windows wordpress,公司seo是指什么意思,网站建设盈利,下载app下载问题: 使用java语言编辑,实现一个Hadoop MapReduce任务,对大数据集中的数值进行排序和筛选。 解答思路: 下面是一个使用Java编写的Hadoop MapReduce任务,该任务将读取一个数值数据集,然后对数值进行排序和筛…

问题:

       使用java语言编辑,实现一个Hadoop MapReduce任务,对大数据集中的数值进行排序和筛选。

解答思路:

       下面是一个使用Java编写的Hadoop MapReduce任务,该任务将读取一个数值数据集,然后对数值进行排序和筛选。我们将筛选出大于某个特定阈值的数值,并对这些数值进行排序。

       首先,我们需要定义Map类、Reduce类和驱动类。

'IntSumMapper.java':

import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class IntSumMapper extends Mapper<Object, Text, IntWritable, IntWritable> {private final static IntWritable one = new IntWritable(1);private IntWritable outputKey = new IntWritable();public void map(Object key, Text value, Context context) throws IOException, InterruptedException {// 将输入的文本转换成整数int number = Integer.parseInt(value.toString());// 输出该整数及其计数1outputKey.set(number);context.write(outputKey, one);}}

'IntSumReducer.java':

import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class IntSumReducer extends Reducer<IntWritable, IntWritable, IntWritable, Text> {private IntWritable result = new IntWritable();private Text outputValue = new Text();public void reduce(IntWritable key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {int sum = 0;for (IntWritable val : values) {sum += val.get();}result.set(sum);// 仅当数值大于阈值时输出if (sum > 1000) { // 假设阈值为1000outputValue.set(Integer.toString(sum));context.write(key, outputValue);}}}

'IntSumDriver.java':

 

import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.Path;import org.apache.hadoop.io.IntWritable;import org.apache.hadoop.io.Text;import org.apache.hadoop.mapreduce.Job;import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;public class IntSumDriver {public static void main(String[] args) throws Exception {if (args.length != 2) {System.err.println("Usage: IntSumDriver <input path> <output path>");System.exit(-1);}Configuration conf = new Configuration();Job job = Job.getInstance(conf, "int sum");job.setJarByClass(IntSumDriver.class);job.setMapperClass(IntSumMapper.class);job.setCombinerClass(IntSumReducer.class);job.setReducerClass(IntSumReducer.class);job.setOutputKeyClass(IntWritable.class);job.setOutputValueClass(Text.class);job.setSortComparatorClass(LongWritable.class); // 使用LongWritable作为排序的keyjob.setGroupingComparatorClass(LongWritable.class); // 确保所有数值都在一起进行reduceFileInputFormat.addInputPath(job, new Path(args[0]));FileOutputFormat.setOutputPath(job, new Path(args[1]));System.exit(job.waitForCompletion(true) ? 0 : 1);}}

编译这些类:

javac -d classes IntSumMapper.java IntSumReducer.java IntSumDriver.java

打包成jar文件:

jar -cvf IntSum.jar -C classes .

在Hadoop集群上运行MapReduce作业:

hadoop jar IntSum.jar IntSumDriver /input /output

       这里'/input'是输入数据所在的HDFS路径,'/output'是输出结果将写入的HDFS路径。

       该程序将输出所有大于1000的数值,并且这些数值是排序后的。需要注意,这里我们使用了'LongWritable'作为排序的key,因为'IntWritable'不能直接用于排序,而且'IntWritable'的排序是字典序,而不是数值序。使用'LongWritable'可以确保数值按照数值大小进行排序。如果你的数值范围在'IntWritable'的有效范围内,你可以直接使用'IntWritable'。

(文章为作者在学习java过程中的一些个人体会总结和借鉴,如有不当、错误的地方,请各位大佬批评指正,定当努力改正,如有侵权请联系作者删帖。)

http://www.dtcms.com/wzjs/363547.html

相关文章:

  • 郑州营销网站托管公司哪家好厦门网络推广公司
  • 接网站开发做多少钱百度推广运营公司
  • 网站建设毕业设计过程百度热线
  • 哪些分类网站怎么做一个网站
  • b2c网站资料怎么做百度搜索网站优化
  • 如何做阿里详情页面链接到外部网站西安seo排名优化推广价格
  • 网站建设功培训学校怎么招生
  • 怎么投诉网络平台英文seo是什么意思
  • wordpress公司网站世界十大搜索引擎及地址
  • 网站整合建设方案佛山seo网站排名
  • 企业做网站带来的好处谷歌网站推广
  • b站网络营销方式seo关键词优化排名公司
  • 如何建立微网站营销策划机构
  • 温州乐清做网站的公司海淀区seo引擎优化
  • 自己做的手机网站怎么加入小程序打开官方网站
  • 如何做一家类似携程的网站上海最新政策
  • 带商城的企业网站源码今日新闻最新头条
  • 培训网站建设多少钱什么软件可以发帖子做推广
  • 做响应式网站制作搜索引擎营销的手段包括
  • 微商平台app郑州seo公司
  • 怎么接推广南宁seo排名优化
  • 徐州有哪些制作网站的公司吗网络广告是什么
  • 番茄网络营销策划方案seo页面优化技术
  • 中企动力近期做的网站免费发布平台
  • 淡水做网站seo关键词排名优化推荐
  • 如何选择番禺网站建设百度检索入口
  • 建筑给排水代做网站外链工具xg下载
  • 网站建设图片怎么加水印2021搜索引擎排名
  • 一个网站 二级域名百度广告联盟网站
  • 已经有了网站怎么做推广百度怎么优化网站排名