28 karma · joined January 10, 2020
0:x uses 1:x and then it splits the content into lines. unfortunately splitting requires copying, so you'd be limited by the amount of ram (let's ignore "swap").
i don't use mmap for writing/amendment yet. i'll be working on it.
the way modern hardware works is like this: every process run by the os has its own view of the (typically 48-bit) address space. a process can request from the os that a part of that address space be "backed" by a certain file. this means that every time the process touches (i.e. tries to read or write) a virgin memory page there (usually page=4k, always aligned), the os will be automatically notified and will make sure to fill it in with actual content from the file, before the process even knows. from that point on, the page will occupy physical ram. if the os is low on memory later, it may decide to free up the page and return it to its previous state.
in effect, data from disk (or any disk-like storage) can be "streamed" while your program uses ordinary array indexing. the word "streaming" though implies reading from start to end in order (which is additionally sped up by prefetch, but that's a different story..); memory mapping is more general - it allows random access.
0:"path" /read lines
"path"0:("line1";"line2") /write lines
1:"path" /read bytes
"path"1:"content" /write bytesacross operating systems: it works on linux and freebsd as-is (thanks bakul), and with a few changes on windows+libc (thanks ktye) - https://github.com/ktye/i/tree/master/_/ngn though i personally never use windows