网站怎么做微信登录界面,如何制作小程序图片,郑州住建局官网查询,专业邯郸做网站目录 一、MapReduce 示例程序的导入并运行测试
二、准备 4 个小文件#xff08;文件大小分别为 1.7M#xff0c;5.1M#xff0c;3.4M#xff0c;6.8M#xff09;
1. 第一种情况#xff0c;默认分片#xff1a;不修改程序代码#xff0c;直接使用 WordCount 源程序
2…目录 一、MapReduce 示例程序的导入并运行测试
二、准备 4 个小文件文件大小分别为 1.7M5.1M3.4M6.8M
1. 第一种情况默认分片不修改程序代码直接使用 WordCount 源程序
2. 第二种情况在代码中增加如下内容
3. 第三种情况将数值设为 20M
三、对 sogou.500w.utf8 数据进行分析使用 MapReduce 编写程序完成。
1. 程序源代码
2. 程序输出结果 一、MapReduce 示例程序的导入并运行测试
步骤 1在 eclipse 中创建 Java Project → new Package
步 骤 2 将 /home/2130502441ryx/hadoop-3.1.3-src/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples 目录下的 WordCount.java 文件通过复制命令 cp 放到桌面/home/gdpu/Desktop如下所示
// 解压压缩包tar -zxvf /home/2130502441ryx/hadoop-3.1.3-src.tar.gz /home/2130502441ryx // 复制文件cp /home/2130502441ryx/hadoop-3.1.3-src/hadoop-mapreduce-project/hadoop-mapreduce-examples/src/main/java/org/apache/hadoop/examples/WordCount.java 步骤 3将 WordCount.java 文件通过复制粘贴拷贝至 eclipse 对应项目的包下。 步骤 4导入依赖包 External jars将以下文件夹里面的 jar 加入到项目的 build path。
\share\hadoop\common\share\hadoop\common\lib\share\hadoop\hdfs\share\hadoop\mapreduce\share\hadoop\yarn 步骤 5将项目打包成 jar 包项目点右键--- export --- Java(JAR file)。 步骤 6在 HDFS 文件系统上创建文件夹 input并上传一些文本文件到该目录文件自行在操作系统上选取。
hdfs dfs -mkdir /inputhdfs dfs -ls / hdfs dfs -put /home/2130502441ryx/testWordCount /inputhdfs dfs -ls /inputhdfs dfs -cat /input/testWordCount 步骤 7运行 WordCount 示例程序将运行程序的命令和结果截图在下面。
hadoop jar /home/2130502441ryx/MapReduceTest.jar org/ryx/WordCount /input hdfs dfs -ls /output hdfs dfs -cat /output/part-r-00000 二、准备 4 个小文件文件大小分别为 1.7M5.1M3.4M6.8M a.txt在我上传的资源中可以免费下载 https://download.csdn.net/download/m0_67830223/89498183?spm1001.2014.3001.5503 cat a.txt b.txt
cat a.txt b.txt cat a.txt c.txt
cat a.txt c.txt
cat a.txt c.txt cat a.txt d.txt
cat a.txt d.txt
cat a.txt d.txt
cat a.txt d.txt 将上述 4 个文件上传至 HDFS 文件系统作为 WordCount 的输入运行WordCount 程序观察分片情况。
hdfs dfs -ls /input1 1. 第一种情况默认分片不修改程序代码直接使用 WordCount 源程序
hadoop jar /home/2130502441ryx/MapReduceTest.jar org/ryx/WordCount /input1 /output1 2. 第二种情况在代码中增加如下内容
job.setInputFormatClass(CombineTextInputFormat.class);CombineTextInputFormat.setMaxInputSplitSize(job, 4194304);
添加代码如下 运行截图
hadoop jar /home/2130502441ryx/MapReduceTest.jar org/ryx/WordCount /input1 /output2 3. 第三种情况将数值设为 20M
CombineTextInputFormat.setMaxInputSplitSize(job, 20971520);
修改代码如下 运行截图
hadoop jar /home/2130502441ryx/MapReduceTest.jar org/ryx/WordCount /input1 /output3 三、对 sogou.500w.utf8 数据进行分析使用 MapReduce 编写程序完成。
将程序主要代码复制或者截图在下面包括主要的 Mapper 类Reducer 类和Partition 类并将打包运行后的结果输出并截图。
分析统计用户查询关键字长度的次数分布关键字长度为 1 的搜索次数长度为 2 的搜索次数…,长度为 N 的搜索次数。输出结果将按搜索长度分为 3 组长度在小于等于 5 的分一组长度在 6 到 10 之间的分一组大于 10 的分一组。
hdfs dfs -ls / 1. 程序源代码
① KeywordLengthMapper ② KeywordLengthReducer ③ KeywordLengthPartitioner ④ KeywordLengthAnalysis 2. 程序输出结果
hadoop jar /home/2130502441ryx/MapReduceTest.jar org/ryx/KeyWordLengthAnalysis /sogou.500.utf8 /output4 hdfs dfs -ls /output4 hdfs dfs -cat /output4/part-r-00000hdfs dfs -cat /output4/part-r-00001hdfs dfs -cat /output4/part-r-00002