Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试通过 stdin 一次读取一个 100gb 文件,使用
Port = open_port({fd, 0, 1}, [in, binary, {line, 4096}]),
但这会使我的系统充满消息,直到我用完 ram。有没有办法让它像 {active, once} 与端口?还有 io:get_line() 但我想知道这是否可行。
不,对端口没有流量控制,因此如果处理速度不够快,则应使用另一种处理方法。STDIN您可以在使用时设置二进制模式
STDIN
ok = io:setopts(standard_io, [binary]),
file:read_line(standard_io)如果您使用的是版本 17 或更高版本(存在影响性能的错误),则可以使用它来阅读它。
file:read_line(standard_io)