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

使用动易模版制作网站seo标签优化

使用动易模版制作网站,seo标签优化,wordpress评论框插件,wordpress 评论模板制作这篇文章主要介绍了Java执行hadoop的基本操作实例代码的相关资料,需要的朋友可以参考下Java执行hadoop的基本操作实例代码向HDFS上传本地文件public static void uploadInputFile(String localFile) throws IOException{Configuration conf new Configuration();String hdfsPa…

这篇文章主要介绍了Java执行hadoop的基本操作实例代码的相关资料,需要的朋友可以参考下

Java执行hadoop的基本操作实例代码

向HDFS上传本地文件

public static void uploadInputFile(String localFile) throws IOException{

Configuration conf = new Configuration();

String hdfsPath = "hdfs://localhost:9000/";

String hdfsInput = "hdfs://localhost:9000/user/hadoop/input";

FileSystem fs = FileSystem.get(URI.create(hdfsPath), conf);

fs.copyFromLocalFile(new Path(localFile), new Path(hdfsInput));

fs.close();

System.out.println("已经上传文件到input文件夹啦");

}

将output文件下载到本地

public static void getOutput(String outputfile) throws IOException{

String remoteFile = "hdfs://localhost:9000/user/hadoop/output/part-r-00000";

Path path = new Path(remoteFile);

Configuration conf = new Configuration();

String hdfsPath = "hdfs://localhost:9000/";

FileSystem fs = FileSystem.get(URI.create(hdfsPath),conf);

fs.copyToLocalFile(path, new Path(outputfile));

System.out.println("已经将输出文件保留到本地文件");

fs.close();

}

删除hdfs中的文件

public static void deleteOutput() throws IOException{

Configuration conf = new Configuration();

String hdfsOutput = "hdfs://localhost:9000/user/hadoop/output";

String hdfsPath = "hdfs://localhost:9000/";

Path path = new Path(hdfsOutput);

FileSystem fs = FileSystem.get(URI.create(hdfsPath), conf);

fs.deleteOnExit(path);

fs.close();

System.out.println("output文件已经删除");

}

执行mapReduce程序

创建Mapper类和Reducer类

public static class TokenizerMapper extends Mapper{

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{

String line = value.toString();

line = line.replace("\\", "");

String regex = "性别:(.*?)";

Pattern pattern = Pattern.compile(regex);

Matcher matcher = pattern.matcher(line);

while(matcher.find()){

String term = matcher.group(1);

word.set(term);

context.write(word, one);

}

}

}

public static class IntSumReducer extends Reducer{

private IntWritable result = new IntWritable();

public void reduce(Text key, Iterable values, Context context) throws IOException, InterruptedException{

int sum = 0;

for(IntWritable val :values){

sum+= val.get();

}

result.set(sum);

context.write(key, result);

}

}

执行mapReduce程序

public static void runMapReduce(String[] args) throws Exception {

Configuration conf = new Configuration();

String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();

if(otherArgs.length != 2){

System.err.println("Usage: wordcount");

System.exit(2);

}

Job job = new Job(conf, "word count");

job.setJarByClass(WordCount.class);

job.setMapperClass(TokenizerMapper.class);

job.setCombinerClass(IntSumReducer.class);

job.setReducerClass(IntSumReducer.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(IntWritable.class);

FileInputFormat.addInputPath(job, new Path(otherArgs[0]));

FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));

System.out.println("mapReduce 执行完毕!");

System.exit(job.waitForCompletion(true)?0:1);

}

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

http://www.lbrq.cn/news/2384137.html

相关文章:

  • 公司网站 优帮云营销策略ppt模板
  • 网站建设用什么语言好湖南网站seo推广
  • 做网站要学些什么条件深圳seo秘籍
  • 社区论坛网站建设企业网络推广计划书
  • 花都网站开发网站seo搜索引擎优化案例
  • 动态网站中如何做项目栏北京网站推广营销策划
  • 怎么做五个页面网站网站编辑seo
  • 佛山网站建设设计一个新产品的营销方案
  • 中国万网注册网站有什么推广产品的渠道
  • 专门做生鲜的网站重庆百度seo整站优化
  • 涟源市建设局网站免费网站生成器
  • 想弄个网站怎么出售友情链接
  • 网站开发工作协议书范本广告推广免费平台
  • 沧浪seo网站优化软件有哪些平台可以免费发广告
  • 杭州雄飞网站建设网络公司东莞谷歌推广公司
  • 网站建设前台后台设计外贸推广是做什么的
  • godaddy网站建设教程优秀软文范例100字
  • 建设六马路小学 网站千锋教育官方网
  • 什么网站值得做河南seo网站多少钱
  • 自己有域名要怎么制作网站电商运营培训哪个机构好
  • 网站建设丨选择金手指排名15高端网站建设公司
  • 福州 网站建设百度竞价优化排名
  • 如何快速建立一个网站必应搜索网站
  • 黄冈app推广服务机构seo排名优化公司
  • 阿里云做网站官网跨境电商营销推广
  • 宜昌永东建设网站营销策略的思路
  • 大连做网站海外推广渠道都有哪些
  • ssh网站开发公司品牌宣传
  • 建外贸网站用什么主机百度seo效果
  • 手机网站怎么做微信登陆seo诊断专家
  • Excel导出实战:从入门到精通 - 构建专业级数据报表的完整指南
  • 基于K8s ingress灰度发布配置
  • div和span区别
  • 使用位运算优化 Vue.js 应用:高效状态管理技巧
  • AllDup(重复文件查找)v4.5.70 便携版
  • 面向向量检索的教育QA建模:九段日本文化研究所日本语学院的Prompt策略分析(6 / 500)