在 Rebol 中读取大型二进制文件失败
以下 Rebol 代码由于内存不足
错误而失败:
read/binary http://mirror.bytemark.co.uk/ubuntu-releases/lucid/
ubuntu-10.04-desktop-i386.iso
How can I use Rebol to read Large bin files over HTTP?
The following Rebol code fails due to an out of memory
error:
read/binary http://mirror.bytemark.co.uk/ubuntu-releases/lucid/
ubuntu-10.04-desktop-i386.iso
How can I use Rebol to read large binary files over HTTP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Rebol 2 端口有些混乱。因此,您不能直接应用如何分段读取大文件的示例因为
read
在 R2 中的port!
上不起作用(更不用说read/part
起作用了)。但是,如果您跳过一些麻烦并使用
/direct
细化直接打开文件,您会得到一些有用的东西:(更新:我没有请注意 Sunanda 引用的 READ-IO 示例,因为我不太使用 R2,也没有见过 READ-IO。它可能也可以在 http 上工作并且具有更好的性能,但我会让你
在 Rebol 3 中 进行比较。您可以从
端口读取和写入!
。这意味着对大文件示例的修改应该可以工作,理论上...然而,当前版本的 R3 alpha 中存在一个错误,该错误忽略了
/part如果方案是 HTTP,则在读取期间继续细化并返回整个文件的内容。 :(
Rebol 2 ports are something of a mess. So you can't directly apply the sample of how to read a large file in parts because
read
doesn't work onport!
in R2 (much less doesread/part
work).But if you jump through some hoops and use the
/direct
refinement to directly open the file, you get something that will work:(UPDATE: I didn't notice the READ-IO sample that Sunanda cites, as I don't use R2 much and hadn't ever seen READ-IO. It may also work on http and have better performance. But I'll let you do that comparison. :P)
In Rebol 3, you can read and write from a
port!
. That means a modification of the large file sample should work, in theory...Yet there's a bug in the current build of R3 alpha that ignores the
/part
refinement and goes ahead and returns the contents of the whole file duringread
if the scheme is HTTP. :(使用这个 http://anton.wildit.net.au/rebol/ util/batch-download.r 下载大文件。
Use this http://anton.wildit.net.au/rebol/util/batch-download.r to download large files.
直接读取大文件可能会失败,因为它保存在内存中,并且可能会耗尽可用内存。
本参考描述了一种以块的形式读取文件的方法,前提是您可以找到 FTP 服务器来获取该文件:
http://www.rebol.com/docs/core23/ rebolcore-13.html#section-11.12
快速搜索后发现有适用于 Ubuntu 的 FTP 服务器,但我还没有检查它们是否涵盖了您需要的版本。祝你好运!
A straight read of a large file may fail as it is held in memory and may exhaust the available memory.
This reference describes a way to read a file in chunks, provided you can find an FTP server to source it:
http://www.rebol.com/docs/core23/rebolcore-13.html#section-11.12
A quick search suggests there are FTP servers for Ubuntu, but I have not checked if they cover the version you need. Good luck!