对内存限制的大量数据排序文件 [英] Sort a file with huge volume of data given memory constraint

查看:154
本文介绍了对内存限制的大量数据排序文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

积分:


  • 我们同时处理一天中的数千个平面文件。

  • 内存限制是一个主要问题。

  • 我们为每个文件进程使用线程。

  • 我们不按列排序。文件中的每一行(记录)被视为一列。

  • We process thousands of flat files in a day, concurrently.
  • Memory constraint is a major issue.
  • We use thread for each file process.
  • We don't sort by columns. Each line (record) in the file is treated as one column.

不能做:


  • 我们不能使用unix / linux的排序命令。

  • 我们无法使用任何数据库系统,无论它们有多轻。 li>
  • We cannot use unix/linux's sort commands.
  • We cannot use any database system no matter how light they can be.

现在,我们不能将所有东西加载到集合中并使用排序机制。它会吃掉所有的内存,程序会收到堆错误。

Now, we cannot just load everything in a collection and use the sort mechanism. It will eat up all the memory and the program is gonna get a heap error.

在这种情况下,你将如何对文件中的记录/行进行排序? p>

In that situation, how would you sort the records/lines in a file?

推荐答案

看起来你正在寻找的是
外部排序

It looks like what you are looking for is external sorting.

基本上,您首先排序小块数据,将其写回磁盘,然后迭代这些排序。

Basically, you sort small chunks of data first, write it back to the disk and then iterate over those to sort all.

这篇关于对内存限制的大量数据排序文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆