我正在使用非常大的bigint数字,我需要将它们写入磁盘并稍后再读取它们,因为它们一次都不适合内存.
当前的Chapel实现首先将其转换bigint为a string,然后将其写入string磁盘[1].这对于大整数来说需要很长时间.
var outputFile = open("outputPath", iomode.cwr);
var writer = outputFile.writer();
writer.write(reallyLargeBigint);
writer.close();
outputFile.close();
Run Code Online (Sandbox Code Playgroud)
有没有办法使用GMP的mpz_out_raw()/ mpz_inp_raw()[2]或mpz_export()/ mpz_import()[3]或其他类似的方式bigint直接将字节转储到磁盘而不事先转换为字符串然后将字节读回到bigint对象?
这也适用于bigint阵列吗?
如果在当前状态下不可能将这些功能添加到Chapel的标准库中,怎么可能?
[1] https://github.com/chapel-lang/chapel/blob/master/modules/standard/BigInteger.chpl#L346
[2] https://gmplib.org/manual/I_002fO-of-Integers.html
[3] https://gmplib.org/manual/Integer-Import-and-Export.html