gpt4 book ai didi

ocaml - 在 OCaml 中写入和读取内存映射文件

转载 作者:行者123 更新时间:2023-12-04 23:22:15 25 4
gpt4 key购买 nike

我正在 OCaml 中进行试验,以了解如何从/从内存映射文件读取/写入数值数组。

我想我需要使用 Bigarray 但不确定如何将 Bigarray 数组写入内存映射文件,然后再读回?

我似乎无法在任何地方找到一个例子。我已经检查了 Jane St. 核心的源代码,但无济于事。

最佳答案

由于您似乎对使用核心感兴趣:

这是map_file来自他们的文档 ( https://ocaml.janestreet.com/ocaml-core/109.58.00/doc/core/#Bigstring )

val map_file : shared:bool -> Unix.file_descr -> int -> t

map_file shared fd n memory-maps n characters of the data associated with descriptor fd to a bigstring. Iff shared is true, all changes to the bigstring will be reflected in the file.



但是,您应该接受 Jonathan 创建的答案。

关于ocaml - 在 OCaml 中写入和读取内存映射文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20922676/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com