大型文本文件查看器如何工作?如何构建大型文本阅读器

发布于 2024-08-30 14:25:54 字数 398 浏览 5 评论 0原文

大文本文件查看器如何工作

我假设:

  • 线程用于处理文件
  • TextBox 逐行更新
  • 使用有效的内存处理

这些假设是否正确?如果有人要开发自己的产品,必须做什么和不应该做什么?

我希望使用 DataGrid 而不是 TextBox 来实现一个,

我对 C++ 和 python 很熟悉。我可能会使用 QT/PyQT

编辑

我拥有的文件通常在 1.5 到 2 GB 之间。我正在考虑编辑和查看这些文件

how does large text file viewer work?

I'm assuming that:

  • Threading is used to handle the file
  • The TextBox is updated line by line
  • Effective memory handling is used

Are these assumptions correct? if someone were to develop their own, what are the mustsand don'ts?

I'm looking to implement one using a DataGrid instead of a TextBox

I'm comfortable with C++ and python. I'll probably use QT/PyQT

EDIT

The files, I have are usually between 1.5 to 2 GB. I'm looking at editing and viewing these files

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

卸妝后依然美 2024-09-06 14:25:56

我相信诀窍不是将整个文件加载到内存中,而是使用seek等来加载所查看的部分(可能在前后有一个块来处理一些滚动)。也许甚至使用内存映射缓冲区,尽管我没有这些经验。

请务必意识到(快速)修改大文件与仅查看它不同。您可能需要将编辑周围的千兆字节数据复制到新文件中,这可能会很慢。

I believe that the trick is not loading the entire file into memory, but using seek and such to just load the part which is viewed (possibly with a block before and after to handle a bit of scrolling). Perhaps even using memory-mapped buffers, though I have no experience with those.

Do realize that modifying a large file (fast) is different from just viewing it. You might need to copy the gigabytes of data surrounding the edit to a new file, which may be slow.

冬天旳寂寞 2024-09-06 14:25:56

在 Kernighan 和 Paugher 的经典(古董?)书籍“Pascal 中的软件工具”中,他们介绍了 ed(1) 版本的开发和设计选择以及注释

“警告:编辑是一个大问题
计划(不包括来自
translitfindchange;在
950 行,增加了百分之五十
比本书中的任何其他内容都重要。”

而且他们(字面上)甚至没有可以使用的字符串类型。因为他们注意到要编辑的文件可能存在于 磁带 不支持中间的任意写入,他们必须在内存中保留行位置的索引,并使用临时文件来存储更改、删除和添加,通过“保存”命令将整体合并在一起。他们和您一样,担心内存限制其可编辑文件的大小。

这种方法的一般结构保留在 GNU ed 项目,特别是在 buffer.c

In Kernighan and Plaugher's classic (antique?) book "Software Tools in Pascal" they cover the development and design choices of a version of ed(1) and note

"A warning: edit is a big
program (excluding contributions from
translit, find, and change; at
950 lines, it is fifty percent bigger
than anything else in this book."

And they (literally) didn't even have string types to use. Since they note that the file to be edited may exist on tape which doesn't support arbitrary writes in the middle, they had to keep an index of line positions in memory and work with a scratch file to store changes, deletions and additions, merging the whole together upon a "save" command. They, like you, were concerned about memory constraining the size of their editable file.

The general structure of this approach is preserved in the GNU ed project, particularly in buffer.c

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文