Reading and writing vectors of values (low-level)
getset.ff.rdThe three functions get.ff, set.ff and getset.ff provide the simplest interface to access an ff file: getting and setting vector of values identified by positive subscripts
Details
getset.ff combines the effects of get.ff and set.ff in a single operation: it retrieves the old value at position i before changing it.
getset.ff will maintain na.count.
Value
get.ff returns a vector, set.ff returns the 'changed' ff object (like all assignment functions do) and getset.ff returns the value at the subscript positions.
More precisely getset.ff(x, i, value, add=FALSE) returns the old values at the subscript positions i while getset.ff(x, i, value, add=TRUE) returns the incremented values at the subscript positions.
Note
get.ff, set.ff and getset.ff are low level functions that do not support ramclass and ramattribs and thus will not give the expected result with factor and POSIXct
See also
readwrite.ff for low-level access to contiguous chunks and [.ff for high-level access
Examples
x <- ff(0, length=12)
get.ff(x, 3L)
#> [1] 0
set.ff(x, 3L, 1)
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 1 0 0 0 : 0 0 0 0 0 0
x
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 1 0 0 0 : 0 0 0 0 0 0
set.ff(x, 3L, 1, add=TRUE)
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 2 0 0 0 : 0 0 0 0 0 0
x
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 2 0 0 0 : 0 0 0 0 0 0
getset.ff(x, 3L, 1, add=TRUE)
#> [1] 3
getset.ff(x, 3L, 1)
#> [1] 3
x
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 1 0 0 0 : 0 0 0 0 0 0
rm(x); gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1250008 66.8 2239654 119.7 2239654 119.7
#> Vcells 2301070 17.6 8388608 64.0 8387257 64.0