Functions to represent a
Vector on disk in efficient, if
This module uses memory-mapping, a feature of all modern operating-systems, to mirror the disk contents in memory. There are quite a few advantages to memory-mapping files instead of reading the files traditionally:
- Speed: memory-mapping is often much faster than traditional reading.
- Memory efficiency: Memory-mapped files are loaded into RAM on-demand, and easily swapped out. The upside is that the program can work with data-sets larger than the available RAM, as long as they are accessed carefully.
The caveat to using memory-mapping is that it makes the files specific to the current architecture because of the endianness of the data. For more information, see the description in System.IO.MMap
Vector from disk
|:: forall a . Storable a|
Path of the file to map
|-> Maybe (Int64, Int)|
|-> IO (Vector a)|
Map a file into memory (read-only) as a
It is considered unsafe because changes to the underlying file may
(or may not) be reflected in the
Vector, which breaks referential
Vector to disk
These functions write the
Vector in a way suitable for
reading back with
Write out a vector verbatim into an open file handle.