I am working with really large bigint
numbers and I need to write them to disk and read them back later because they won't all fit in memory at a time.
The current Chapel implementation first converts the bigint
to a string
and then writes that string
to disk[1]. This is taking a really long time for large integers.
var outputFile = open("outputPath", iomode.cwr);
var writer = outputFile.writer();
writer.write(reallyLargeBigint);
writer.close();
outputFile.close();
Is there any way to use GMP's mpz_out_raw()
/mpz_inp_raw()
[2] or mpz_export()
/mpz_import()
[3] or another similar way to dump the bigint
's bytes to disk directly without converting to string beforehand and then read the bytes back into a bigint
object?
Would that also work for a bigint
array?
How could such functionality be added to Chapel's standard library in case it's not possible in the current state?
[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