java mapreduce编程_Hadoop实验——MapReduce编程(1)

article/2025/10/16 17:51:10

实验目的

通过实验掌握基本的MapReduce编程方法。

掌握用MapReduce解决一些常见的数据处理问题,包括数据去重、数据排序和数据挖掘等。

通过操作MapReduce的实验,模仿实验内容,深入理解MapReduce的过程,熟悉MapReduce程序的编程方式。

实验平台

操作系统:Ubuntu-16.04

Hadoop版本:2.6.0

JDK版本:1.8

IDE:Eclipse

实验内容和要求

一,编程实现文件合并和去重操作:

对于两个输入文件,即文件A和文件B,请编写MapReduce程序,对两个文件进行合并,并剔除其中重复的内容,得到一个新的输出文件C。下面是输入文件和输出文件的一个样例供参考。

输入文件f1.txt的样例如下:

20150101 x

20150102 y

20150103 x

20150104 y

20150105 z

20150106 x

输入文件f2.txt的样例如下:

20150101 y

20150102 y

20150103 x

20150104 z

20150105 y

根据输入文件f1和f2合并得到的输出文件的样例如下:

20150101 x

20150101 y

20150102 y

20150103 x

20150104 y

20150104 z

20150105 y

20150105 z

20150106 x

实验过程:

创建文件f1.txt和f2.txt

7328bb45a7cd

将上面样例内容复制进去

在HDFS建立input文件夹(执行这步之前要开启hadoop相关进程)

7328bb45a7cd

上传样例到HDFS中的input文件夹

7328bb45a7cd

接着打开eclipse

Eclipse的使用

点开项目,找到 src 文件夹,右键选择 New -> Class

7328bb45a7cd

输入 Package 和 Name,然后Finish

7328bb45a7cd

写好Java代码(给的代码里要修改HDFS和本地路径),右键选择 Run As -> Run on Hadoop,结果在HDFS系统中查看

7328bb45a7cd

实验代码:

package cn.edu.zucc.mapreduce;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;

import org.apache.hadoop.mapreduce.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class Merge {

public static class Map extends Mapper {

private static Text text = new Text();

@Override

public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

text = value;

context.write(text, new Text(""));

}

}

public static class Reduce extends Reducer {

@Override

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

context.write(key, new Text(""));

}

}

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

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://localhost:9000");

String[] otherArgs = new String[]{"input", "output"};

if (otherArgs.length != 2) {

System.err.println("Usage: Merge and duplicate removal ");

System.exit(2);

}

Job job = Job.getInstance(conf, "Merge");

job.setJarByClass(Merge.class);

job.setMapperClass(Map.class);

job.setReducerClass(Reduce.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(Text.class);

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

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

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

}

}

模仿上题完成以下内容:对于两个输入文件,即文件A和文件B,请编写MapReduce程序,对两个文件进行统计单词数量,得到一个新的输出文件C。下面是输入文件和输出文件的一个样例供参考。

输入文件a.txt的样例如下:

hello world

wordcount java

android hbase

hive pig

输入文件b.txt的样例如下:

hello hadoop

spring mybatis

hive hbase

pig android

输出文件的结果为:

android 2

hadoop 1

hbase 2

hello 2

hive 2

java 1

mybatis 1

pig 2

spring 1

wordcount 1

world 1

实验代码:

package cn.edu.zucc.mapreduce;

import java.io.IOException;

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.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class WordCount {

public static class Map extends Mapper {

private static final IntWritable one = new IntWritable(1);

private Text word = new Text();

@Override

public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

String lineValue = value.toString();

String[] words = lineValue.split(" ");

for (String singleWord : words) {

word.set(singleWord);

context.write(word, one);

}

}

}

public static class Reduce extends Reducer {

private IntWritable result = new IntWritable();

@Override

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

int sum = 0;

for (IntWritable value : values) {

sum += value.get();

}

result.set(sum);

context.write(key, result);

}

}

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

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://localhost:9000");

String[] otherArgs = new String[]{"input_1", "output_1"};

if (otherArgs.length != 2) {

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

System.exit(2);

}

Job job = Job.getInstance(conf, "Wordcount");

job.setJarByClass(WordCount.class);

job.setMapperClass(Map.class);

job.setReducerClass(Reduce.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(IntWritable.class);

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

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

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

}

}

二,编写程序实现对输入文件的排序:

现在有多个输入文件,每个文件中的每行内容均为一个整数。要求读取所有文件中的整数,进行升序排序后,输出到一个新的文件中,输出的数据格式为每行两个整数,第一个数字为第二个整数的排序位次,第二个整数为原待排列的整数。下面是输入文件和输出文件的一个样例供参考。

输入文件file1.txt的样例如下:

33

37

12

40

输入文件file2.txt的样例如下:

4

16

39

5

输入文件file3.txt的样例如下:

1

45

25

根据输入文件file1.txt、file2.txt和file3.txt得到的输出文件如下:

1 1

2 4

3 5

4 12

5 16

6 25

7 33

8 37

9 39

10 40

11 45

实验过程:

创建文件file1.txt、file2.txt和file3.txt

7328bb45a7cd

将上面样例内容复制进去

在HDFS建立input2文件夹

7328bb45a7cd

上传样例到HDFS中的input2文件夹

7328bb45a7cd

到eclipse上执行代码

实验代码:

package cn.edu.zucc.mapreduce;

import java.io.IOException;

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.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class ContentSort {

public static class Map extends Mapper {

private static IntWritable data = new IntWritable();

@Override

public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

String line = value.toString();

data.set(Integer.parseInt(line));

context.write(data, new IntWritable(1));

}

}

public static class Reduce extends Reducer {

private static IntWritable linenum = new IntWritable(1);

@Override

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

for (IntWritable val : values) {

context.write(linenum, key);

linenum = new IntWritable(linenum.get() + 1);

}

}

}

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

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://localhost:9000");

String[] otherArgs = new String[]{"input2", "output2"};

if (otherArgs.length != 2) {

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

System.exit(2);

}

Job job = Job.getInstance(conf, "ContentSort");

job.setJarByClass(ContentSort.class);

job.setMapperClass(Map.class);

job.setReducerClass(Reduce.class);

job.setOutputKeyClass(IntWritable.class);

job.setOutputValueClass(IntWritable.class);

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

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

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

}

}

模仿上题完成以下内容:对于三个输入文件,即文件math、文件china和文件english,请编写MapReduce程序,对三个文件进行统计平均分,得到一个新的输出文件。下面是输入文件和输出文件的一个样例供参考。

输入文件math.txt的样例如下:

张三 88

李四 99

王五 66

赵六 77

输入文件algs.txt的样例如下:

张三 78

李四 89

王五 96

赵六 67

输入文件english.txt的样例如下:

张三 80

李四 82

王五 84

赵六 86

输出文件结果为:

张三 82

李四 90

王五 82

赵六 76

实验代码:

package cn.edu.zucc.mapreduce;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import org.apache.hadoop.conf.Configuration;

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.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;

public class AvgScore {

public static class Map extends Mapper {

@Override

public void map(LongWritable key, Text value, Context context)

throws IOException, InterruptedException {

String line = value.toString();

String[] nameAndScore = line.split(" ");

List list = new ArrayList<>(2);

for (String nameOrScore : nameAndScore) {

if (!"".equals(nameOrScore)) {

list.add(nameOrScore);

}

}

context.write(new Text(list.get(0)), new IntWritable(Integer.parseInt(list.get(1))));

}

}

public static class Reduce extends Reducer {

@Override

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

int sum = 0;

int count = 0;

for (IntWritable value : values) {

sum += Integer.parseInt(value.toString());

count++;

}

int average = sum / count;

context.write(key, new IntWritable(average));

}

}

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

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://localhost:9000");

String[] otherArgs = new String[]{"input_2", "output_2"};

if (otherArgs.length != 2) {

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

System.exit(2);

}

Job job = Job.getInstance(conf, "AvgScore");

job.setJarByClass(AvgScore.class);

job.setMapperClass(Map.class);

job.setReducerClass(Reduce.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(IntWritable.class);

job.setInputFormatClass(TextInputFormat.class);

job.setOutputFormatClass(TextOutputFormat.class);

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

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

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

}

}

三,对给定的表格进行信息挖掘:

下面给出一个child-parent的表格,要求挖掘其中的父子辈关系,给出祖孙辈关系的表格。

输入文件table.txt内容如下:

child parent

Steven Lucy

Steven Jack

Jone Lucy

Jone Jack

Lucy Mary

Lucy Frank

Jack Alice

Jack Jesse

David Alice

David Jesse

Philip David

Philip Alma

Mark David

Mark Alma

输出文件内容如下:

grandchild grandparent

Mark Jesse

Mark Alice

Philip Jesse

Philip Alice

Jone Jesse

Jone Alice

Steven Jesse

Steven Alice

Steven Frank

Steven Mary

Jone Frank

Jone Mary

实验过程:

创建文件table

7328bb45a7cd

将上面样例内容复制进去

在HDFS建立input3文件夹

7328bb45a7cd

上传样例到HDFS中的input3文件夹

7328bb45a7cd

到eclipse上执行代码

实验代码:

package cn.edu.zucc.mapreduce;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;

import org.apache.hadoop.mapreduce.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class STJoin {

public static int time = 0;

public static class Map extends Mapper {

@Override

public void map(Object key, Text value, Context context) throws IOException, InterruptedException {

String line = value.toString();

String[] childAndParent = line.split(" ");

List list = new ArrayList<>(2);

for (String childOrParent : childAndParent) {

if (!"".equals(childOrParent)) {

list.add(childOrParent);

}

}

if (!"child".equals(list.get(0))) {

String childName = list.get(0);

String parentName = list.get(1);

String relationType = "1";

context.write(new Text(parentName), new Text(relationType + "+"

+ childName + "+" + parentName));

relationType = "2";

context.write(new Text(childName), new Text(relationType + "+"

+ childName + "+" + parentName));

}

}

}

public static class Reduce extends Reducer {

@Override

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

if (time == 0) {

context.write(new Text("grand_child"), new Text("grand_parent"));

time++;

}

List grandChild = new ArrayList<>();

List grandParent = new ArrayList<>();

for (Text text : values) {

String s = text.toString();

String[] relation = s.split("\\+");

String relationType = relation[0];

String childName = relation[1];

String parentName = relation[2];

if ("1".equals(relationType)) {

grandChild.add(childName);

} else {

grandParent.add(parentName);

}

}

int grandParentNum = grandParent.size();

int grandChildNum = grandChild.size();

if (grandParentNum != 0 && grandChildNum != 0) {

for (int m = 0; m < grandChildNum; m++) {

for (int n = 0; n < grandParentNum; n++) {

context.write(new Text(grandChild.get(m)), new Text(

grandParent.get(n)));

}

}

}

}

}

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

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://localhost:9000");

String[] otherArgs = new String[]{"input3", "output3"};

if (otherArgs.length != 2) {

System.err.println("Usage: Single Table Join ");

System.exit(2);

}

Job job = Job.getInstance(conf, "Single table Join ");

job.setJarByClass(STJoin.class);

job.setMapperClass(Map.class);

job.setReducerClass(Reduce.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(Text.class);

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

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

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

}

}

模仿上题完成以下内容:现有两个输入文件两个文件,一个是工厂名与地址编号的对应关系;另一个是地址编号和地址名的对应关系。要求从输入数据中找出工厂名和地址名的对应关系,输出"工厂名——地址名"表。

输入文件factory.txt:

factoryname addressID

Beijing Red Star 1

Shenzhen Thunder 3

Guangzhou Honda 2

Beijing Rising 1

Guangzhou Development Bank 2

Tencent 3

Bank of Beijing 1

输入文件address.txt:

addressID addressname

1 Beijing

2 Guangzhou

3 Shenzhen

4 Xian

输出文件内容如下:

factoryname addressname

Back of Beijing     Beijing

Beijing Rising   Beijing

Beijing Red Star     Beijing

Guangzhou Development Bank   Guangzhou

Guangzhou Honda       Guangzhou

Tencent         Shenzhen

Shenzhen Thunder       Shenzhen

实验代码:

package cn.edu.zucc.mapreduce;

import java.io.IOException;

import java.util.ArrayList;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import org.apache.hadoop.conf.Configuration;

import org.apache.hadoop.fs.Path;

import org.apache.hadoop.io.Text;

import org.apache.hadoop.mapreduce.Job;

import org.apache.hadoop.mapreduce.Mapper;

import org.apache.hadoop.mapreduce.Reducer;

import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;

import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import org.apache.hadoop.util.GenericOptionsParser;

public class MTJoin {

public static int time = 0;

public static class Map extends Mapper {

@Override

protected void map(Object key, Text value, Context context) throws IOException, InterruptedException {

String line = value.toString();

if (line.contains("factoryname") || line.contains("addressID")) {

return;

}

String[] strings = line.split(" ");

List list = new ArrayList<>();

for (String information : strings) {

if (!"".equals(information)) {

list.add(information);

}

}

String addressID;

StringBuilder stringBuilder = new StringBuilder();

if (StringUtils.isNumeric(list.get(0))) {

addressID = list.get(0);

for (int i = 1; i < list.size(); i++) {

if (i != 1) {

stringBuilder.append(" ");

}

stringBuilder.append(list.get(i));

}

context.write(new Text(addressID), new Text("1+" + stringBuilder.toString()));

} else {

addressID = list.get(list.size() - 1);

for (int i = 0; i < list.size() - 1; i++) {

if (i != 0) {

stringBuilder.append(" ");

}

stringBuilder.append(list.get(i));

}

context.write(new Text(addressID), new Text("2+" + stringBuilder.toString()));

}

}

}

public static class Reduce extends Reducer {

@Override

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

if (time == 0) {

context.write(new Text("factoryname"), new Text("addressname"));

time++;

}

List factory = new ArrayList<>();

List address = new ArrayList<>();

for (Text text : values) {

String s = text.toString();

String[] relation = s.split("\\+");

if ("1".equals(relation[0])) {

address.add(relation[1]);

} else {

factory.add(relation[1]);

}

}

int factoryNum = factory.size();

int addressNum = address.size();

if (factoryNum != 0 && addressNum != 0) {

for (int m = 0; m < factoryNum; m++) {

for (int n = 0; n < addressNum; n++) {

context.write(new Text(factory.get(m)),

new Text(address.get(n)));

}

}

}

}

}

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

Configuration conf = new Configuration();

conf.set("fs.defaultFS", "hdfs://localhost:9000");

String[] ioArgs = new String[]{"input_3", "output_3"};

String[] otherArgs = new GenericOptionsParser(conf, ioArgs)

.getRemainingArgs();

if (otherArgs.length != 2) {

System.err.println("Usage: Multiple Table Join ");

System.exit(2);

}

Job job = Job.getInstance(conf, "Mutiple table join ");

job.setJarByClass(MTJoin.class);

job.setMapperClass(Map.class);

job.setReducerClass(Reduce.class);

job.setOutputKeyClass(Text.class);

job.setOutputValueClass(Text.class);

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

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

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

}

}


http://chatgpt.dhexx.cn/article/fBaK94rj.shtml

相关文章

MapReduce编程初级实践

一、实验目的 通过实验掌握基本的MapReduce编程方法&#xff1b;掌握用MapReduce解决一些常见的数据处理问题&#xff0c;包括数据去重、数据排序和数据挖掘等。 二、 实验平台 操作系统&#xff1a;ubuntu18 Hadoop版本&#xff1a;3.2.2 HBase版本&#xff1a;2.2.2 JDK版…

MapReduce编程练习

目录 编程实现按日期统计访问次数 2.编程实现按访问次数排序 获取成绩表最高分 编译jar包方法 编程实现按日期统计访问次数 (1) 定义输入/输出格式 社交网站用户的访问日期在格式上属于文本格式&#xff0c;访问次数为整型数值格式。其组成的键值对为<访问日…

云计算实验 MapReduce编程

一、实验题目 MapReduce编程 二、实验内容 本实验利用 Hadoop 提供的 Java API 进行编程进行 MapReduce 编程。 三、实验目标 掌握MapReduce编程。 理解MapReduce原理 【实验作业】简单流量统计 有如下这样的日志文件&#xff1a; 13726230503 00-FD-07-A4-72-B8:CMCC 120.19…

Hadoop实验4:MapReduce编程

目录 一. 【实验准备】 1.工作目录 2.打开eclipse并配置工作空间 二、准备工作 1. 新建项目 2. 准备测试数据 3. 添加 MapReduce 编程框架 三、Map过程 四、Reduce过程 五、执行MapReduce任务 六、实验结果 七、准备工作 1. 新建项目 2. 准备relation.dat 3. 添加…

MapReduce 编程规范 (以WordCount为例)

先介绍一下常用的数据序列化类型 在MapReduce编程中&#xff0c;需要进行数据传输&#xff0c;比如将Mapper的结果传入Reducer中进行汇总&#xff0c;媒介就是context,所以需要可以序列化的数据类型。 MapReduce编程规范 Mapper阶段、Reducer阶段&#xff0c;Driver阶段 Map…

MapReduce 编程实战

MapReduce 采用了「分而治之」的思想。在分布式计算中&#xff0c;MapReduce 框架负责处理并行编程中分布式存储、工作调度、负载均衡、容错均衡、容错处理以及网络通信等复杂问题&#xff0c;把处理过程高度抽象为两个函数&#xff1a;map&#xff0c;把一个任务分解成多个任务…

实验三-MapReduce编程

前提&#xff1a;安装好Hadoop 参考文章&#xff1a; MapReduce编程实践(Hadoop3.1.3)_厦大数据库实验室博客 实验要求 基于MapReduce执行“词频统计”任务。 将提供的A&#xff0c;B&#xff0c;C文件上传到HDFS上&#xff0c;之后编写MapReduce代码并将其部署到hadoop&…

MapReduce编程模型

1.MapReduce简介 MapReduce是一个分布式运算程序的编程框架&#xff0c;核心功能是将用户编写的业务逻辑代码和自带默认组件整合成一个完整的分布式运算程序&#xff0c;并发运行在Hadoop集群上。 一个完整的mapreduce程序在分布式运行时有三类实例进程&#xff1a; MRAppMaste…

MapReduce编程框架

1、MapReduce思想 MapReduce思想在生活中处处可见。我们或多或少都曾接触过这种思想。MapReduce的思想核心是分而治之&#xff0c;充分利用了并行处理的优势。即使是发布过论文实现分布式计算的谷歌也只是实现了这种思想&#xff0c;而不是自己原创。 MapReduce任务过程是分为…

MapReduce编程实践

MapReduce编程实践 重要知识点&#xff1a; MapReduce是一种分布式并行编程模型,是Hadoop核心子项目之一,如果已经安装了Hadoop&#xff0c;就不需要另外安装MapReduce。主要的理论知识点包括&#xff1a;MapReduce概述、MapReduce的工作流程&#xff0c;WordCount实例分析&a…

mapreduce 编程模型

MapReduce是在总结大量应用的共同特点的基础上抽象出来的分布式计算框架&#xff0c;它适用的应用场景往往具有一个共同的特点&#xff1a;任务可被分解成相互独立的子问题。基于该特点&#xff0c;MapReduce编程模型给出了其分布式编程方法&#xff0c;共分5个步骤&#xff1a…

MapReduce编程基础

&#xff08;一&#xff09;实现词频统计的基本的MapReduce编程。 ①在/user/hadoop/input文件夹(该文件夹为空)&#xff0c;创建文件wordfile1.txt和wordfile2.txt上传到HDFS中的input文件夹下。 文件wordfile1.txt的内容如下&#xff1a; I love Spark I love Hadoop 文件wor…

(超详细)MapReduce工作原理及基础编程

MapReduce工作原理及基础编程&#xff08;代码见文章后半部分&#xff09; JunLeon——go big or go home 目录 MapReduce工作原理及基础编程&#xff08;代码见文章后半部分&#xff09; 一、MapReduce概述 1、什么是MapReduce&#xff1f; 2、WordCount案例解析MapRed…

【小白视角】大数据基础实践(五) MapReduce编程基础操作

目录 1. MapReduce 简介1.1 起源1.2 模型简介1.3 MRv1体系结构1.4 YARN1.4.1 YARN体系结构1.4.2 YARN工作流程 2. MapReduce 工作流程3. Java Api要点4. 实验过程最后 1. MapReduce 简介 1.1 起源 在函数式语言里&#xff0c;map表示对一个列表&#xff08;List&#xff09;中…

MapReduce编程

一、MapReduce编程规范 MapReduce的开发一共又八个步骤&#xff0c;其中Map阶段分为2个步骤&#xff0c;Shuffle阶段4个步骤&#xff0c;Reduce阶段分为2个步骤。 1.1 步骤流程 Map阶段2个步骤 设置InputFormat类&#xff0c;将数据切分为key-value&#xff08;k1和v1&#x…

SSL/TLS

SSL/TLS 一、SSL/TLS1.1 历史发展1.2 使用场景1.3 解决的问题1.4 工作流程 二、对称加密&#xff08;Symmetric Cryptography&#xff09;2.1 工作原理2.2 翻转攻击2.3 认证加密&#xff08;Authentication Encryption&#xff09;2.4 Diffie-Hellman2.5 KDF2.6 Diffie-Hellman…

HTTPS,SSL,TLS

SSL TLS secure sockets layer 安全套接字层&#xff0c;Netscape公司研发。 transport layer security 安全传输层协议 定义 协议 年份 SSL 1.0 未知 SSL 2.0 1995 SSL 3.0 1996 TLS 1.0 1999 TLS 1.1 2006 TLS 1.2 2008 TLS 1.3 2018 IETF&#xff08;The…

TLS传输协议

TLS&#xff1a;安全传输层协议&#xff08;TLS&#xff09;用于在两个通信应用程序之间提供保密性和数据完整性。 该协议由两层组成&#xff1a;TLS 记录协议&#xff08;TLS Record&#xff09;和 TLS 握手协议&#xff08;TLS Handshake&#xff09;。 传输层安全性协议&a…

LVGL misc tlsf算法(lv_tlsf.c)

更多源码分析请访问:LVGL 源码分析大全 目录 1、概述2、算法特点3、同类型算法举例1、概述 LVGL采用的内存分配器是使用的tlsf算法。因为这个算法只是一个实时系统常用的算法,可以看作是一个工具,对LVGL本身并没有逻辑上的关联,所以这里只介绍一下算法的基本知识,就不过…

TLS/SSL 协议详解(17) Certificate verify

发送这个类型的握手需要2个前提条件 &#xff08;1&#xff09;&#xff1a;服务器端请求了客户端证书 &#xff08;2&#xff09;&#xff1a;客户端发送了非0长的证书 此时&#xff0c;客户端想要证明自己拥有该证书&#xff0c;必然需要私钥签名一段数据发给服务器验证。 …