Kevin-Jin / mmap

Forked from https://r-forge.r-project.org/scm/?group_id=648
1 stars 1 forks source link

Allow for extraction operations that do not require copying memory #8

Open Kevin-Jin opened 7 years ago

Kevin-Jin commented 7 years ago

Add an optional parameter to the as.mmap() functions that set the default behavior for the subset operator `[` and also add an optional parameter to `[` (similar to the base drop parameter). Users should have the option of either (1) retrieving another mmap object that transparently refers to different offsets of the parent mmap object (using sets of ordered pairs representing start indices and range lengths), or (2) calling extractFUN on the subset.

Naturally, many additional functions will need to be overridden so that useful operations can be performed in place on the mmap object. The list of functions overridden in the ffbase CRAN package is probably a good start.

It will be important to document this departure from R's standard copy-on-write semantics when the feature is released. The optional parameter in as.mmap() should default to calling extractFUN on subsets.

Kevin-Jin commented 7 years ago

mmap objects already depart from copy-on-write semantics because they extend environment types and because calls to mmap_replace() affect the value of all references to the mmap object. In other words, mmap objects are passed by reference rather than passed by value.