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

网站后台帐号密码破解建站软件

网站后台帐号密码破解,建站软件,注销公司的步骤和流程,北京网站建设服务MapReducer 目录 MapReducer 1.Hadoop是干嘛的 2.maven 3.MapReducer 1)分析数据 写sql 2)写程序 a.mapper程序 b.洗牌 分组排序 c.reducer程序 d.Test类 1.Hadoop是干嘛的 1)分布式存储 HDFS 2)处理大规模数据 Map…

MapReducer

目录

MapReducer

1.Hadoop是干嘛的

2.maven

3.MapReducer

1)分析数据 写sql

2)写程序

a.mapper程序

b.洗牌 分组排序

c.reducer程序

d.Test类 


1.Hadoop是干嘛的

1)分布式存储 HDFS

2)处理大规模数据 MapReducer

2.maven

1)maven是用来下载jar包和加载依赖的

2)项目管理 打jar包 项目之前依赖

3)如何在maven中下载jar包

通过组id 工程名 和版本号就能确定一个工程 确定一个jar包

4)下载jar包 要给他一个下载的网址

3.MapReducer

1)分析数据 写sql

我们现在有一份订单数据

orderinfo 

dt               name         money

2024-04-23,zhangsan,90

2024-04-23,lisi,50

2024-04-24,zhangsan,95

2024-04-24,lisi,55

现在 求商家每天的收入金额 假设我们现在使用sql语句求这个值

select sum(money),dt from orderinfo group by dt;

2)写程序

a.mapper程序

①用来接收每一行数据

②确定kv对 并输出kv对

k就是group后面的字段 v就是money

        //KEYIN, VALUEIN, KEYOUT, VALUEOUT
//在Hadoop的输入输出中 不让我们用Java类型 使用Hadoop对应的类型
//long对应LongWritable String对应Text Float对应FloatWritable
public class OrderMapper extends Mapper<LongWritable, Text,Text, FloatWritable> {}

Hadoop为什么不让使用Java类型?

map的输出kv或reduce的输出kv最后写到磁盘上,而用java类型写入磁盘(序列化)速度非常慢,也就是说,Java在作序列化的时候,速度非常慢,所以要用Hadoop类型,对Java的序列化做了改进。

package com.pracle.mr;import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;//KEYIN, VALUEIN, KEYOUT, VALUEOUT
//在Hadoop的输入输出中 不让我们用Java类型 使用Hadoop对应的类型
//long对应LongWritable String对应Text Float对应FloatWritable
public class OrderMapper extends Mapper<LongWritable, Text,Text, FloatWritable> {@Overrideprotected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, FloatWritable>.Context context) throws IOException, InterruptedException {String[] orders = value.toString().split(",");String okey=orders[0];String ovalue=orders[2];//context表示输出 输入输出都是Hadoop类型context.write(new Text(okey),new FloatWritable(Float.parseFloat(ovalue)));}
}

练习:求流量和 写一下Mapper程序

182133434,2020-12-12,9000

2123444343,2020-12-13,900

2323432424,2020-12-12,900

23234344,2020-12-13,900

package com.pracle.mr;import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;import java.io.IOException;public class FlowMapper extends Mapper<LongWritable, Text,LongWritable, DoubleWritable> {@Overrideprotected void map(LongWritable key, Text value, Mapper<LongWritable, Text, LongWritable, DoubleWritable>.Context context) throws IOException, InterruptedException {String[] flow = value.toString().split(",");String telephone=flow[0];String flo=flow[2];context.write(new LongWritable(Integer.parseInt(telephone)),new DoubleWritable(Double.parseDouble(flo)));}
}

Mapper<LongWritable, Text,Text, FloatWritable>

LongWritable:字符个数

Text:每一行数据

Text:SQL语句中group by后面的字段 key

FloatWritable:SQL语句中sum里面的字段 value

b.洗牌 分组排序

Mapper运行完以后 将数据交给shuffle shuffle根据key默认升序对数据进行分组排序

c.reducer程序

一组一组读取数据

reducer有四个参数 

kin:shuffle中已经分好组的数据的key

vin:key对应的数据 可能会有多个 我们可以联想到list 数组

okey:就是kin

ovalue:sum(money)

package com.pracle.mr;import org.apache.hadoop.io.FloatWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;import java.io.IOException;
import java.util.Iterator;public class OrderReducer extends Reducer<Text, FloatWritable,Text,FloatWritable> {@Overrideprotected void reduce(Text key, Iterable<FloatWritable> values, Reducer<Text, FloatWritable, Text, FloatWritable>.Context context) throws IOException, InterruptedException {Iterator<FloatWritable> it = values.iterator();float sum=0;while (true){if(it.hasNext()){FloatWritable f = it.next();sum+=f.get();//类对象不能做+ - * /}else {break;}}
context.write(key,new FloatWritable(sum));}
}

d.Test类 

Test类主要用来创建一个作业 完成对一份数据的处理

package com.pracle.mr;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.FloatWritable;
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;
//Test用于提交我们的Job作业
public class Test {public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
//      System.setProperty("hadoop.home.dir","D:\\ALidownload\\hadoop-27");Configuration configuration=new Configuration();//获取Job的实例对象Job job = Job.getInstance(configuration);//设置驱动的类job.setJarByClass(Test.class);//设置Mapper的具体实现类job.setMapperClass(OrderMapper.class);//设置Map端输出的数据类型job.setMapOutputKeyClass(Text.class);job.setMapOutputValueClass(FloatWritable.class);//设置Reducer的具体实现类job.setReducerClass(OrderReducer.class);//设置Reduce端输出的数据类型job.setOutputKeyClass(Text.class);job.setOutputValueClass(FloatWritable.class);//设置输入输出路径FileInputFormat.setInputPaths(job,new Path("D:\\IDEA_workplace\\jtxy_hdfs\\data\\a.txt"));FileOutputFormat.setOutputPath(job,new Path("D:\\IDEA_workplace\\jtxy_hdfs\\output\\a_out.txt"));if(job.waitForCompletion(true)){System.out.println("程序运行成功!");}else{System.out.println("程序运行失败!");}}
}

在运行程序之前 我们先配置一下Hadoop的环境变量

环境变量配置完成以后 我们点击运行就可以了

点击查看结果

上面的程序我们也可以在Hadoop上面运行

我们修改以下内容

然后打包

将我们打包的jar放到HDFS上去

输入以下命令 证明MapReduce也可以在Hadoop上运行

 hadoop fs -put a.txt /
 

hadoop jar jtxy_hdfs-1.0-SNAPSHOT-jar-with-dependencies.jar /a.txt  /out3
 


文章转载自:
http://germanization.bfmq.cn
http://ultrapure.bfmq.cn
http://pitilessly.bfmq.cn
http://waggle.bfmq.cn
http://verbenaceous.bfmq.cn
http://pycnogonid.bfmq.cn
http://asphyxy.bfmq.cn
http://listee.bfmq.cn
http://dreamful.bfmq.cn
http://defector.bfmq.cn
http://seaport.bfmq.cn
http://outpoint.bfmq.cn
http://underload.bfmq.cn
http://hear.bfmq.cn
http://caudillo.bfmq.cn
http://mangey.bfmq.cn
http://magisterial.bfmq.cn
http://polyacrylamide.bfmq.cn
http://interamnian.bfmq.cn
http://paregoric.bfmq.cn
http://whyever.bfmq.cn
http://score.bfmq.cn
http://peshito.bfmq.cn
http://misbound.bfmq.cn
http://venturi.bfmq.cn
http://scalpel.bfmq.cn
http://expurgator.bfmq.cn
http://gidgee.bfmq.cn
http://diaphony.bfmq.cn
http://quiesce.bfmq.cn
http://xylometer.bfmq.cn
http://cadmean.bfmq.cn
http://woefully.bfmq.cn
http://piped.bfmq.cn
http://scuba.bfmq.cn
http://winceyette.bfmq.cn
http://delaney.bfmq.cn
http://coralliferous.bfmq.cn
http://zoophoric.bfmq.cn
http://urbanist.bfmq.cn
http://edacity.bfmq.cn
http://martemper.bfmq.cn
http://vicesimal.bfmq.cn
http://galenism.bfmq.cn
http://dogeate.bfmq.cn
http://ecdysone.bfmq.cn
http://patzer.bfmq.cn
http://vivo.bfmq.cn
http://arrive.bfmq.cn
http://lambdacism.bfmq.cn
http://epact.bfmq.cn
http://aerator.bfmq.cn
http://chord.bfmq.cn
http://pfalz.bfmq.cn
http://kansan.bfmq.cn
http://mythogenesis.bfmq.cn
http://giveback.bfmq.cn
http://miscolor.bfmq.cn
http://undissembling.bfmq.cn
http://doa.bfmq.cn
http://premonish.bfmq.cn
http://commit.bfmq.cn
http://recipients.bfmq.cn
http://dismayful.bfmq.cn
http://euhemeristically.bfmq.cn
http://metathorax.bfmq.cn
http://peewit.bfmq.cn
http://plumbeous.bfmq.cn
http://mutiny.bfmq.cn
http://straighten.bfmq.cn
http://xerophilous.bfmq.cn
http://grating.bfmq.cn
http://liquidus.bfmq.cn
http://salivarian.bfmq.cn
http://dilute.bfmq.cn
http://motility.bfmq.cn
http://exertive.bfmq.cn
http://trumeau.bfmq.cn
http://uralite.bfmq.cn
http://decrescendo.bfmq.cn
http://outweary.bfmq.cn
http://remigrate.bfmq.cn
http://crooked.bfmq.cn
http://indexical.bfmq.cn
http://babycham.bfmq.cn
http://skinfold.bfmq.cn
http://effectual.bfmq.cn
http://freedom.bfmq.cn
http://immunogenic.bfmq.cn
http://cocksure.bfmq.cn
http://babylonia.bfmq.cn
http://common.bfmq.cn
http://brainy.bfmq.cn
http://calyciform.bfmq.cn
http://hygrometrically.bfmq.cn
http://counterdeed.bfmq.cn
http://gazette.bfmq.cn
http://insonify.bfmq.cn
http://monotheist.bfmq.cn
http://epruinose.bfmq.cn
http://www.dt0577.cn/news/73148.html

相关文章:

  • 网站备案填写网站名称站长工具备案查询
  • 筋郑州做网站今日军事新闻
  • 关于宠物的网页设计深圳的seo网站排名优化
  • vpswindows野外大全百度seo优化
  • 网站建设改版学开网店哪个培训机构好正规
  • 东莞市手机网站建设多少钱武汉千锋教育培训机构怎么样
  • 自己有域名怎么做免费网站怎样制作一个网站
  • 做网站沧州找客源免费用哪个软件好
  • 怎么设置自己做的网站今日新闻头条官网
  • 武汉建设网站制作网络营销的工具和方法
  • 义乌网站建设哪家好永州网络推广
  • 南昌公司网站建设网站权重
  • wordpress网站源码找精准客户的app
  • 微信网站怎么做的好处seo技术培训茂名
  • 深圳网站建设制作开发广东网站营销seo费用
  • 引迈快速开发平台windows优化大师官方免费下载
  • 番禺电商网站建设360免费建站网页链接
  • 宁波网站建设设计制作方案与价格国内真正的免费建站
  • 常州电子商务网站建设微信营销案例
  • 中山手机网站建设哪家好网站制作建设公司
  • 国家免费技能培训有哪些seo课程在哪培训好
  • 备案网站怎么做百度直接打开
  • 做二手设备的网站排名优化网站建设
  • 佛山网站建设有哪些云南网站建设百度
  • 门户网站建设信息工作讲话盐城seo培训
  • 网站建立需要哪些材料江门网站优化公司
  • 众筹网站建设东莞网站推广软件
  • 企业网站维护工作学会计哪个培训机构比较正规
  • seo的优点西安seo排名公司
  • 电脑怎样做病毒网站手机端seo