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

沈阳建设网站服务公司河南工程建设信息网站

沈阳建设网站服务公司,河南工程建设信息网站,门户网站开发文档,濮阳网红apache hadoop目前#xff0c;我正在接受Coursera的培训“ 挖掘海量数据集 ”。 我对MapReduce和Apache Hadoop感兴趣已有一段时间了#xff0c;通过本课程#xff0c;我希望对何时以及如何MapReduce可以帮助解决一些现实世界中的业务问题有更多的了解#xff08;我在这里介… apache hadoop 目前我正在接受Coursera的培训“ 挖掘海量数据集 ”。 我对MapReduce和Apache Hadoop感兴趣已有一段时间了通过本课程我希望对何时以及如何MapReduce可以帮助解决一些现实世界中的业务问题有更多的了解我在这里介绍了另一种解决方法。 该Coursera课程主要侧重于使用算法的理论而较少涉及编码本身。 第一周是关于PageRanking以及Google如何使用它来对页面进行排名。 幸运的是与Hadoop结合可以找到很多关于该主题的信息。 我到这里结束并决定仔细看一下这段代码。 我所做的就是获取这段代码 将其分叉并重新编写了一下。 我创建的映射器单元测试和减速器跟我描述这里 。 作为测试用例我使用了课程中的示例。 我们有三个相互链接和/或彼此链接的网页 此链接方案应解析为以下页面排名 Y 7/33 5/33 M 21/33 由于MapReduce示例代码期望输入“ Wiki页面” XML 因此我创建了以下测试集 mediawiki xmlnshttp://www.mediawiki.org/xml/export-0.10/ xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-0.10.xsd version0.10 xml:langenpagetitleA/titleid121173/idrevision...text xml:spacepreserve bytes6523[[Y]] [[M]]/text/revision/pagepagetitleY/titleid121173/idrevision...text xml:spacepreserve bytes6523[[A]] [[Y]]/text/revision/pagepagetitleM/titleid121173/idrevision...text xml:spacepreserve bytes6523[[M]]/text/revision/page /mediawiki 原始页面本身已经很好地解释了它的全局工作方式。 我将仅描述我创建的单元测试。 有了原始的解释和我的单元测试您应该能够解决问题并了解发生了什么。 如上所述整个工作分为三个部分 解析 计算 订购 在解析部分中将原始XML提取分割成多个页面并进行映射以便我们获得该页面作为键和具有出站链接的页面值作为输出。 因此单元测试的输入将是三个“ Wiki”页面XML如上所示。 预期带有链接页面的页面的“标题”。 单元测试如下 package net.pascalalma.hadoop.job1;...public class WikiPageLinksMapperTest {MapDriverLongWritable, Text, Text, Text mapDriver;String testPageA page\n titleA/title\n ... text xml:space\preserve\ bytes\6523\[[Y]] [[M]]/text\n /revision;String testPageY page\n titleY/title\n ... text xml:space\preserve\ bytes\6523\[[A]] [[Y]]/text\n /revision\n /page;String testPageM page\n titleM/title\n ... text xml:space\preserve\ bytes\6523\[[M]]/text\n /revision\n /page;Beforepublic void setUp() {WikiPageLinksMapper mapper new WikiPageLinksMapper();mapDriver MapDriver.newMapDriver(mapper);}Testpublic void testMapper() throws IOException {mapDriver.withInput(new LongWritable(1), new Text(testPageA));mapDriver.withInput(new LongWritable(2), new Text(testPageM));mapDriver.withInput(new LongWritable(3), new Text(testPageY));mapDriver.withOutput(new Text(A), new Text(Y));mapDriver.withOutput(new Text(A), new Text(M));mapDriver.withOutput(new Text(Y), new Text(A));mapDriver.withOutput(new Text(Y), new Text(Y));mapDriver.withOutput(new Text(M), new Text(M));mapDriver.runTest(false);} } 映射器的输出将成为我们的reducer的输入。 那个的单元测试如下 package net.pascalalma.hadoop.job1; ... public class WikiLinksReducerTest {ReduceDriverText, Text, Text, Text reduceDriver;Beforepublic void setUp() {WikiLinksReducer reducer new WikiLinksReducer();reduceDriver ReduceDriver.newReduceDriver(reducer);}Testpublic void testReducer() throws IOException {ListText valuesA new ArrayListText();valuesA.add(new Text(M));valuesA.add(new Text(Y));reduceDriver.withInput(new Text(A), valuesA);reduceDriver.withOutput(new Text(A), new Text(1.0\tM,Y));reduceDriver.runTest();} } 如单元测试所示我们期望reducer将输入减少到“初始”页面等级1.0的值该等级与关键页面具有传出链接的所有页面连接。 这是该阶段的输出将用作“计算”阶段的输入。 在计算部分中将对进入的页面等级进行重新计算以实现“ 幂迭代 ”方法。 将多次执行此步骤以获得给定页面集的可接受页面排名。 如前所述上一步的输出是该步骤的输入正如我们在此映射器的单元测试中所看到的 package net.pascalalma.hadoop.job2; ... public class RankCalculateMapperTest {MapDriverLongWritable, Text, Text, Text mapDriver;Beforepublic void setUp() {RankCalculateMapper mapper new RankCalculateMapper();mapDriver MapDriver.newMapDriver(mapper);}Testpublic void testMapper() throws IOException {mapDriver.withInput(new LongWritable(1), new Text(A\t1.0\tM,Y));mapDriver.withInput(new LongWritable(2), new Text(M\t1.0\tM));mapDriver.withInput(new LongWritable(3), new Text(Y\t1.0\tY,A));mapDriver.withOutput(new Text(M), new Text(A\t1.0\t2));mapDriver.withOutput(new Text(A), new Text(Y\t1.0\t2));mapDriver.withOutput(new Text(Y), new Text(A\t1.0\t2));mapDriver.withOutput(new Text(A), new Text(|M,Y));mapDriver.withOutput(new Text(M), new Text(M\t1.0\t1));mapDriver.withOutput(new Text(Y), new Text(Y\t1.0\t2));mapDriver.withOutput(new Text(A), new Text(!));mapDriver.withOutput(new Text(M), new Text(|M));mapDriver.withOutput(new Text(M), new Text(!));mapDriver.withOutput(new Text(Y), new Text(|Y,A));mapDriver.withOutput(new Text(Y), new Text(!));mapDriver.runTest(false);} } 源页面中说明了此处的输出。 “额外”项目带有“” 和| 在减少步骤中对于计算是必需的。 减速器的单元测试如下 package net.pascalalma.hadoop.job2; ... public class RankCalculateReduceTest {ReduceDriverText, Text, Text, Text reduceDriver;Beforepublic void setUp() {RankCalculateReduce reducer new RankCalculateReduce();reduceDriver ReduceDriver.newReduceDriver(reducer);}Testpublic void testReducer() throws IOException {ListText valuesM new ArrayListText();valuesM.add(new Text(A\t1.0\t2));valuesM.add(new Text(M\t1.0\t1));valuesM.add(new Text(|M));valuesM.add(new Text(!));reduceDriver.withInput(new Text(M), valuesM);ListText valuesA new ArrayListText();valuesA.add(new Text(Y\t1.0\t2));valuesA.add(new Text(|M,Y));valuesA.add(new Text(!));reduceDriver.withInput(new Text(A), valuesA);ListText valuesY new ArrayListText();valuesY.add(new Text(Y\t1.0\t2));valuesY.add(new Text(|Y,A));valuesY.add(new Text(!));valuesY.add(new Text(A\t1.0\t2));reduceDriver.withInput(new Text(Y), valuesY);reduceDriver.withOutput(new Text(A), new Text(0.6\tM,Y));reduceDriver.withOutput(new Text(M), new Text(1.4000001\tM));reduceDriver.withOutput(new Text(Y), new Text(1.0\tY,A));reduceDriver.runTest(false);} } 如图所示映射器的输出被重新创建为输入我们检查reducer的输出是否与页面等级计算的第一次迭代相匹配。 每次迭代将导致相同的输出格式但可能具有不同的页面等级值。 最后一步是“订购”部分。 这非常简单单元测试也是如此。 这部分仅包含一个映射器该映射器获取上一步的输出并将其“重新格式化”为所需格式pagerank 按pagerank的页面顺序。 当将映射器结果提供给化简器步骤时按键排序是由Hadoop框架完成的因此该排序不会反映在Mapper单元测试中。 此单元测试的代码是 package net.pascalalma.hadoop.job3; ... public class RankingMapperTest {MapDriverLongWritable, Text, FloatWritable, Text mapDriver;Beforepublic void setUp() {RankingMapper mapper new RankingMapper();mapDriver MapDriver.newMapDriver(mapper);}Testpublic void testMapper() throws IOException {mapDriver.withInput(new LongWritable(1), new Text(A\t0.454545\tM,Y));mapDriver.withInput(new LongWritable(2), new Text(M\t1.90\tM));mapDriver.withInput(new LongWritable(3), new Text(Y\t0.68898\tY,A));//Please note that we cannot check for ordering here because that is done by Hadoop after the Map phasemapDriver.withOutput(new FloatWritable(0.454545f), new Text(A));mapDriver.withOutput(new FloatWritable(1.9f), new Text(M));mapDriver.withOutput(new FloatWritable(0.68898f), new Text(Y));mapDriver.runTest(false);} } 因此在这里我们只检查映射器是否接受输入并正确格式化输出。 总结了单元测试的所有示例。 通过这个项目您应该能够自己进行测试并且对原始代码的工作方式有更深入的了解。 它肯定有助于我理解它 包括单元测试在内的完整代码版本可以在这里找到。 翻译自: https://www.javacodegeeks.com/2015/02/calculate-pageranks-apache-hadoop.htmlapache hadoop
http://www.zqtcl.cn/news/714372/

相关文章:

  • 怎么搭建购物网站山东德州网站建设
  • 网站 404 错误页面是否自动跳转太原网站建设王道下拉惠
  • 美仑-专门做服装的网站淘宝详情页制作
  • 网站商城制作策划公司组织结构图
  • 商务网站建设教程企网
  • 北京做网站推广多少钱丽水网站建设公司排名
  • 淄博网站关键词优化安丘网站建设公司
  • 教育建设网站wordpress 创建模板文件
  • 门户网站开发视频教学百度关键词怎么刷上去
  • 做网站搞流量挂联盟广告变现新媒体营销心得体会
  • 网站做信息流网站如何做担保交易平台
  • php网站后台访问统计分析互联网营销师题库
  • 提供建站服务的网络公司的比较注册网站域名后免费建站
  • 颍上建设网站长江商学院 网站建设
  • 做酒店销售上哪个网站好东莞出租车公司
  • 如何在记事本中做网站链接好看的wordpress文章模板下载
  • 做二手衣服的网站有哪些安县移动网站建设
  • 学习资料黄页网站免费美丽乡村 网站建设
  • 仲恺住房和城乡建设局网站上海wordpress
  • 网站整体结构国内现货正规交易平台
  • 正规的网站制作开发平度建设网站
  • 建筑网站在哪里找松岗网站
  • 网站开发后台框架贸易网站建站
  • 定州做网站宝安设备网站设计
  • 高端网站制作技术吉利汽车新能源品牌
  • 阿里云大学 网站建设常州网警
  • 做的网站访问不了lovefort表白网站制作
  • 自己如何做公司网站视频seo快速排名软件首页
  • 一站式做网站技术兰州网站设计哪个平台好
  • 网站按钮psdwordpress哪个主题