Reading and writing vectors (low-level)
readwrite.ff.rdSimpe low-level interface for reading and writing vectors from ff files.
Details
readwrite.ff combines the effects of read.ff and write.ff in a single operation: it retrieves the old values starting from position i before changing them.
getset.ff will maintain na.count.
Value
read.ff returns a vector of values, write.ff returns the 'changed' ff object (like all assignment functions do) and readwrite.ff returns the values at the target position.
More precisely readwrite.ff(x, i, value, add=FALSE) returns the old values at the position i while readwrite.ff(x, i, value, add=TRUE) returns the incremented values of x.
Note
read.ff, write.ff and readwrite.ff are low level functions that do not support ramclass and ramattribs and thus will not give the expected result with factor and POSIXct
Examples
x <- ff(0, length=12)
read.ff(x, 3, 6)
#> [1] 0 0 0 0 0 0
write.ff(x, 3, rep(1, 6))
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 1 1 1 1 : 1 1 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 1 1 1 : 1 1 0 0 0 0
write.ff(x, 3, rep(1, 6), add=TRUE)
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 2 2 2 2 : 2 2 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 2 2 2 : 2 2 0 0 0 0
readwrite.ff(x, 3, rep(1, 6), add=TRUE)
#> [1] 3 3 3 3 3 3
readwrite.ff(x, 3, rep(1, 6))
#> [1] 3 3 3 3 3 3
x
#> ff (open) double length=12 (12)
#> [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]
#> 0 0 1 1 1 1 : 1 1 0 0 0 0
rm(x); gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1260935 67.4 2239654 119.7 2239654 119.7
#> Vcells 2325853 17.8 8388608 64.0 8387257 64.0