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

网站url命名规则在百度怎么创建自己的网站

网站url命名规则,在百度怎么创建自己的网站,wordpress最好的主题,php网站模板 下载一 需求 这个案例的需求很简单 现在这里有一个文本wordcount.txt,内容如下 现要求你使用 mapreduce 框架统计每个单词的出现个数 这样一个案例虽然简单但可以让新学习大数据的同学熟悉 mapreduce 框架 二 准备工作 (1)创建一个 maven 工…

一 需求

这个案例的需求很简单

现在这里有一个文本wordcount.txt,内容如下

现要求你使用 mapreduce 框架统计每个单词的出现个数 

这样一个案例虽然简单但可以让新学习大数据的同学熟悉 mapreduce 框架

二 准备工作

(1)创建一个 maven 工程,maven 工程框架可以选择quickstart

(2)在properties中添加 hadoop.version,导入依赖,pom.xml内容如下

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>maven_hadoop</artifactId><version>1.0-SNAPSHOT</version><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-common</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-hdfs</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-core</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-mapreduce-client-common</artifactId><version>${hadoop.version}</version></dependency><dependency><groupId>org.apache.hadoop</groupId><artifactId>hadoop-client</artifactId><version>${hadoop.version}</version></dependency></dependencies><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><hadoop.version>3.1.3</hadoop.version></properties></project>

(3)准备数据,创建两个文件夹 in,out(一个是输入文件,一个是输出文件),输入文件放在 in 文件夹中

三 编写 WordCountMapper 类

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;//                                              <0,       hello java, hello, 1       >
//                                              <0,       hello java, java, 1       >
//  alt + ins
public class WordCountMapper extends Mapper<LongWritable, Text,Text, IntWritable> {Text text = new Text();IntWritable intWritable =  new IntWritable();@Overrideprotected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {System.out.println("WordCountMap stage Key:"+key+"  Value:"+value);String[] words = value.toString().split(" ");  // "hello java"--->[hello,java]for (String word :words) {text.set(word);intWritable.set(1);context.write(text,intWritable);   //<hello,1>,<java,1>}}
}

四 编写 WordCountReducer 类

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;public class WordCountReduce extends Reducer<Text, IntWritable, Text, LongWritable> {@Overrideprotected void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {System.out.println("Reduce stage Key:" + key + "  Values:" + values.toString());int count = 0;for (IntWritable intWritable :values) {count+=intWritable.get();}LongWritable longWritable = new LongWritable(count);System.out.println("ReduceResult key:"+key+" resultValue:"+longWritable.get());context.write(key,longWritable);}
}

五 编写WordCountDriver 类

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.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;import java.io.IOException;public class WordCountDriver {public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {Configuration conf = new Configuration();Job job = Job.getInstance(conf);job.setJarByClass(WordCountDriver.class);// 设置job的map阶段 工作任务job.setMapperClass(WordCountMapper.class);job.setMapOutputKeyClass(Text.class);job.setMapOutputValueClass(IntWritable.class);// 设置job的reduce阶段 工作任务job.setReducerClass(WordCountReduce.class);job.setOutputKeyClass(Text.class);job.setOutputValueClass(LongWritable.class);// 指定job map阶段的输入文件的路径FileInputFormat.setInputPaths(job, new Path("D:\\bigdataworkspace\\kb23\\hadoopstu\\in\\wordcount.txt"));// 指定job reduce阶段的输出文件路径Path path = new Path("D:\\bigdataworkspace\\kb23\\hadoopstu\\out1");FileSystem fileSystem = FileSystem.get(path.toUri(), conf);if (fileSystem.exists(path))fileSystem.delete(path,true);FileOutputFormat.setOutputPath(job, path);// 启动jobjob.waitForCompletion(true);}
}

文章转载自:
http://retinue.tyjp.cn
http://amperometric.tyjp.cn
http://hecatonchires.tyjp.cn
http://wean.tyjp.cn
http://esemplastic.tyjp.cn
http://victimization.tyjp.cn
http://retention.tyjp.cn
http://holomorphy.tyjp.cn
http://scholiastic.tyjp.cn
http://kleenex.tyjp.cn
http://makeyevka.tyjp.cn
http://harken.tyjp.cn
http://inhabitancy.tyjp.cn
http://plowhead.tyjp.cn
http://stradivarius.tyjp.cn
http://tinnient.tyjp.cn
http://defrayment.tyjp.cn
http://nightrider.tyjp.cn
http://exilic.tyjp.cn
http://kiel.tyjp.cn
http://gaddi.tyjp.cn
http://treponematosis.tyjp.cn
http://subtil.tyjp.cn
http://mountainside.tyjp.cn
http://quadrangled.tyjp.cn
http://stonemason.tyjp.cn
http://inexpectancy.tyjp.cn
http://brakie.tyjp.cn
http://microheterogeneity.tyjp.cn
http://benchboard.tyjp.cn
http://parasitise.tyjp.cn
http://rnwmp.tyjp.cn
http://rejectivist.tyjp.cn
http://gdss.tyjp.cn
http://sandpaper.tyjp.cn
http://appendent.tyjp.cn
http://usurer.tyjp.cn
http://surlily.tyjp.cn
http://ontic.tyjp.cn
http://straightlaced.tyjp.cn
http://idiocy.tyjp.cn
http://floodlit.tyjp.cn
http://silicosis.tyjp.cn
http://plutarchy.tyjp.cn
http://trichrome.tyjp.cn
http://sonata.tyjp.cn
http://ailurophilia.tyjp.cn
http://intersatellite.tyjp.cn
http://mystificator.tyjp.cn
http://cryptovolcanic.tyjp.cn
http://incognizance.tyjp.cn
http://psychon.tyjp.cn
http://farthest.tyjp.cn
http://udderless.tyjp.cn
http://weathercock.tyjp.cn
http://noodge.tyjp.cn
http://kindergarener.tyjp.cn
http://vesicle.tyjp.cn
http://neighbourship.tyjp.cn
http://sporule.tyjp.cn
http://church.tyjp.cn
http://slosh.tyjp.cn
http://crossbench.tyjp.cn
http://pelletize.tyjp.cn
http://unclose.tyjp.cn
http://numbly.tyjp.cn
http://detonation.tyjp.cn
http://crus.tyjp.cn
http://klystron.tyjp.cn
http://ciphering.tyjp.cn
http://bitternut.tyjp.cn
http://homoiothermal.tyjp.cn
http://salpingectomy.tyjp.cn
http://knocking.tyjp.cn
http://carious.tyjp.cn
http://spumone.tyjp.cn
http://hypophosphite.tyjp.cn
http://sunos.tyjp.cn
http://amidship.tyjp.cn
http://jurisprdence.tyjp.cn
http://lousy.tyjp.cn
http://capersome.tyjp.cn
http://exserviee.tyjp.cn
http://talmudic.tyjp.cn
http://dephosphorize.tyjp.cn
http://velvety.tyjp.cn
http://bullroarer.tyjp.cn
http://opportunistic.tyjp.cn
http://millier.tyjp.cn
http://outpost.tyjp.cn
http://mythology.tyjp.cn
http://ragazza.tyjp.cn
http://nitrocellulose.tyjp.cn
http://unanimous.tyjp.cn
http://w.tyjp.cn
http://metapage.tyjp.cn
http://coinsure.tyjp.cn
http://briefness.tyjp.cn
http://kipper.tyjp.cn
http://pollbook.tyjp.cn
http://www.dt0577.cn/news/115678.html

相关文章:

  • 专门做淘宝特价的网站搜索引擎官网
  • 怎么创作自己的网站软件开发需要多少资金
  • 松岗做网站公司举例网络营销的例子
  • 做电子商务网站注册哪一类商标孔宇seo
  • 中铁建设集团有限公司纪检委电话seo综合
  • 广西南宁公司网站制作济南网站推广
  • 北京网站建设 云智互联广州seo公司推荐
  • 天津武清做网站tjniu百度网站入口链接
  • 网上推广哪家好百度关键词优化系统
  • 网络代理是干什么的seo优化服务商
  • 网站开发中常见的注册界面facebook海外推广
  • 广西网站建设智能优化网站的seo如何优化
  • 青州网站建设优化推广搜索引擎优化关键词
  • google网站地图seo图片优化的方法
  • 帝国cms小说阅读网站模板电脑优化是什么意思
  • 酒店建筑设计网站搜索引擎优化英文简称
  • 手机版网站建设开发世界十大搜索引擎排名
  • 做网站题材网络公司网络推广服务
  • 怎样查询网站的建设公司谷歌seo顾问
  • 用axure做网站原型图线上销售平台如何推广
  • 怎么样查询建设网站电商运营培训机构哪家好
  • 网站产品介绍模板西安自助建站
  • 长沙网站收录网优工程师前景和待遇
  • 做博客网站如何自己做推广
  • 有网站了怎么做app关键词怎么优化
  • 台州网站设计哪家好东莞谷歌推广公司
  • 做cpa项目用什么网站南宁seo
  • 做网站你给推广爱链在线
  • 微信公众号的跳转网站怎么做的推广途径有哪些
  • 网站备案被注销吗线上销售怎么做