首页 \ 问答 \ 使用Map Reduce(Cloudera Hadoop 0.20.2)比较两个大小接近3GB的文本文件(Comparing using Map Reduce(Cloudera Hadoop 0.20.2) two text files of size of almost 3GB)

使用Map Reduce(Cloudera Hadoop 0.20.2)比较两个大小接近3GB的文本文件(Comparing using Map Reduce(Cloudera Hadoop 0.20.2) two text files of size of almost 3GB)

我正在尝试在hadoop map / reduce中执行以下操作(用java编写,linux内核操作系统)

  1. 文本文件'rules-1'和'rules-2'(总共3GB大小)包含一些规则,每个规则由endline字符分隔,因此可以使用readLine()函数读取文件。

  2. 这些文件'rules-1'和'rules-2'需要作为一个整体从hdfs导入到我的集群中的每个映射函数中,即这些文件不能跨不同的映射函数分割。

  3. 映射器映射函数的输入是一个名为'record'的文本文件(每行都以endline character结尾),所以从'record'文件中我们得到(key,value)对。 该文件是可拆分的,可以作为整个地图/缩小过程中使用的不同地图功能的输入。

  4. 需要做的是比较每个值(即来自记录文件的行)与'rules-1'和'rules-2'内的规则,

问题是,如果我将每行rule-1和rules-2文件仅抽出一次到静态数组列表,以便每个映射器可以共享相同的arraylint并尝试比较数组列表中的元素与记录中的每个输入值文件,我得到一个内存溢出错误,因为3GB不能一次存储在数组列表中。

另外,如果我一次只导入rules-1和rules-2文件中的几行,并将它们与每个值进行比较,则map / reduce将花费大量时间完成其工作。

你们能否给我提供任何其他替代想法?如何在没有内存溢出错误的情况下完成这项工作? 如果我将这些文件1和文件2放入hdfs支持数据库或其他内容中,会有帮助吗? 我真的会出来的想法。真的很感激,如果你们中的一些人可以提供给我你宝贵的建议。


I'm trying to do the following in hadoop map/reduce( written in java, linux kernel OS)

  1. Text files 'rules-1' and 'rules-2' (total 3GB in size) contains some rules, each rule are separated by endline character, so the files can be read using readLine() function.

  2. These files 'rules-1' and 'rules-2' needs to be imported as a whole from hdfs in every map function in my cluster i.e. these file are not splittable across different map function.

  3. Input to the mapper's map function is a text file called 'record' (each line is terminated by endline character), so from the 'record' file we get the (key, value) pair. The file is splittable and can be given as input to different map function used in the whole map/reduce process.

  4. What needs to be done is compare each value(i.e. lines from record file) with the rules inside 'rules-1' and 'rules-2'

Problem is, if I pull out each line of rules-1 and rules-2 files to a static arraylist only once, so that each mapper can share the same arraylint and try to compare elements in the arraylist with the each input value from the record file, I get a memory overflow error, since 3GB cannot be stored at a time in the arraylist.

Alternatively, if I import only few lines from the rules-1 and rules-2 files at a time and compare them to each value, map/reduce is taking a lot time to finish its job.

Could you guys provide me any other alternative ideas how can this be done without the memory overflow error? Will it help if I put those file-1 and file-2 inside a hdfs supporting database or something? I'm going out of ideas actually.Would really appreciate if some of you guys could provide me your valuable suggestions.


原文:https://stackoverflow.com/questions/5606927
更新时间:2023-08-31 07:08

最满意答案

简而言之 :不,project.lock.file不应该签入源代码管理 - 你应该配置版本控制系统忽略它(即将它添加到.gitignore,如果你使用的是git)。

长答案 :project.lock.json包含项目整个依赖关系树的快照 - 不仅仅是“依赖关系”部分列出的包,还包括所有已解决的依赖关系的依赖关系,等等。 但它不像ruby的Gemfile.lock 。 与Gemfile.lock不同,project.lock.json不会告诉dotnet restore哪些准确版本的软件包应该被恢复 - 它只是被覆盖。 因此,它应该像缓存文件一样对待,并且永远不会检入源代码管理。

如果您将其签入版本控制,那么很可能在其他机器上:

  • dotnet会认为所有的软件包都被恢复了,但实际上有些软件包可能会丢失,并且构建失败,而不会暗示开发者运行dotnet restore
  • project.lock.json将在dotnet restore过程中被覆盖,并且在大多数情况下会与源代码控制中存储的版本不同。 所以它几乎在每一次提交中都会被修改
  • project.lock.json将在合并期间导致冲突

Short answer: No, project.lock.file should not be checked into source control - you should configure the version control system to ignore it (i.e. add it to .gitignore if you're using git).

Long answer: The project.lock.json contains a snapshot of project's whole dependency tree - not just packages listed in "dependencies" sections, but also all resolved dependencies of those dependencies, and so on. But it is not like ruby's Gemfile.lock. Unlike Gemfile.lock, project.lock.json doesn't tell dotnet restore which exact versions of packages should be restored - it simply gets overwritten. As such, it should be treated like a cache file and never be checked into source control.

If you check it into version control, then most probably on other machine:

  • dotnet will think that all packages are restored, but in fact some packages might be missing and the build will fail, without hinting the developer to run dotnet restore
  • project.lock.json will be overwritten during dotnet restore and in most cases will be different than the version stored in source control. So it will be modified in almost every commit
  • project.lock.json will cause conflicts during merge

相关问答

更多
  • 简而言之 :不,project.lock.file不应该签入源代码管理 - 你应该配置版本控制系统忽略它(即将它添加到.gitignore,如果你使用的是git)。 长答案 :project.lock.json包含项目整个依赖关系树的快照 - 不仅仅是“依赖关系”部分列出的包,还包括所有已解决的依赖关系的依赖关系,等等。 但它不像ruby的Gemfile.lock 。 与Gemfile.lock不同,project.lock.json不会告诉dotnet restore哪些准确版本的软件包应该被恢复 - 它 ...
  • 如果文件已经被跟踪到git,那么你必须首先删除它(物理文件必须暂时放在git文件夹外),提交更改并再次将文件添加到文件夹。 然后git会开始用你的指令忽略它。 If file is already tracked to git, then you must first remove it(physically file must be placed out of git folder for the time), commit changes and add the file again to folder ...
  • 简短的答案:在恢复项目的软件包时,由.net工具生成的project.lock.json 。 您不应该触摸它或检查它到源代码控制。 直接编辑project.json 更长的答案:在包恢复过程( dotnet restore )期间,NuGet必须分析项目的依赖关系,散布其依赖关系图,并找出应该为项目安装哪些软件包和项目的依赖关系。 这是一个不平凡的工作量,所以结果缓存在project.lock.json ,使后续恢复更快更有效率。 如果project.json被修改并再次执行了dotnet restore则 ...
  • 尝试从您的依赖关系中删除"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final" 。 混合来自不同版本的软件包 - 在这种情况下,RTM和1.1.0版本通常会导致API不明确。 Try removing "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final" from your dependencies. Mixing packages from different re ...
  • "commands"元素不适用于dotnet 。 要配置URL ,可以在.UseUrls("http://unix:/var/aspnet/HelloMVC/kestrel.sock")使用.UseUrls("http://unix:/var/aspnet/HelloMVC/kestrel.sock") ,或者设置命令行配置,然后运行dotnet run --server.urls http://unix:/var/aspnet/HelloMVC/kestrel.sock 。 The "commands" ...
  • 将我的评论更改为答案: 在任何需要它的东西之前添加会话中间件。 否则,它在请求管道中的正确位置将不可用。 中间件本质上是按顺序运行的 - 您使用.UseXyz()添加的每个中间件组件都按顺序运行。 所以如果MVC在会话之前运行,那么MVC无法从会话中间件中看到会话获取。 Changing my comment to an answer: Add the session middleware before anything that needs it. Otherwise it won't be availa ...
  • 您不需要NUnit.Runners或NUnit.Console NuGet包。 您关注的我的博客上的帖子是使用NUnitLite ,这是在早期使用NUnit编写.NET Core单元测试的唯一方法。 从那以后, dotnet-test-nunit就是你要走的路。 它与Visual Studio集成,允许您使用dotnet test命令从Test Explorer窗口或命令行运行dotnet test 。 您的单元测试项目应该只是一个.NET Core类库,而不是一个控制台应用程序或Web应用程序。 高级步骤 ...
  • 问题是prebuild.ps1脚本和我的项目结构没有匹配。 修复脚本中使用的路径解决了问题。 The problem was the prebuild.ps1 script and my project structure didnt match up. Fixing the paths used inside the scripts solved the problem.
  • Azure CLI将很快更新,但您可以直接使用kuduscript npm包来使用最新kuduscript 。 安装它使用: npm install -g kuduscript 然后,您可以使用类似的东西生成ASP.NET Core脚本(根据需要替换名称): kuduscript -y --aspNetCore src\AspNetCoreVS\project.json -s AspNetCoreVS.sln 或者,如果您没有解决方案文件,则可以跳过生成稍微不同的脚本的文件。 请注意,在一般情况下,Ku ...
  • 编译项目时,可以指定要复制到buildOptions输出文件。 "buildOptions": { "copyToOutput": [ "../../../copyme.txt" ] } 该文件的路径是相对于project.json所在的文件夹。 就我而言: Root folder: -copyme.txt -WebApplication\src\WebApplication\project.json You can specify files you want to co ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)