update.ff.rdupdate copies updates one ff object with the content of another object.
an ff object to which to update
an object from which to uodate
NA for quick update with file-exchange, TRUE for quick update with deleting the 'from' object after the update, can speed up updating significantly
how to interpret the content of the object, see ff
how to interpret the content of the 'from' object, see ff
BATCHSIZE
BATCHBYTES
VERBOSE
further arguments
If the source object is.ff and not delete=FALSE then instead of slow copying we - if possible - try to swap and rename the files behind the ff objects.
Quick update requires that the two ff objects are vectorCompatible,
that both don't use vw,
that they have identical maxlength
and identical levels.ff.
You don't have a guarantee that with delete=TRUE the 'from' object gets deleted or with delete=NA the 'from' objects carries the content of 'object'.
Such expectations only turn true if really a quick update was possible.
An ff object like the input 'object' updated with the content of the 'from' object.
x <- ff(1:100)
y <- ff(-(1:100))
message("You should make it a habit to re-assign the return value
of update although this is not needed currently.")
#> You should make it a habit to re-assign the return value
#> of update although this is not needed currently.
x <- update(x, from=y)
x
#> ff (open) integer length=100 (100)
#> [1] [2] [3] [4] [5] [6] [7] [8] [93] [94] [95] [96]
#> -1 -2 -3 -4 -5 -6 -7 -8 : -93 -94 -95 -96
#> [97] [98] [99] [100]
#> -97 -98 -99 -100
y
#> ff (open) integer length=100 (100)
#> [1] [2] [3] [4] [5] [6] [7] [8] [93] [94] [95] [96]
#> -1 -2 -3 -4 -5 -6 -7 -8 : -93 -94 -95 -96
#> [97] [98] [99] [100]
#> -97 -98 -99 -100
x[] <- 1:100
x <- update(x, from=y, delete=NA)
x
#> ff (open) integer length=100 (100)
#> [1] [2] [3] [4] [5] [6] [7] [8] [93] [94] [95] [96]
#> -1 -2 -3 -4 -5 -6 -7 -8 : -93 -94 -95 -96
#> [97] [98] [99] [100]
#> -97 -98 -99 -100
y
#> ff (open) integer length=100 (100)
#> [1] [2] [3] [4] [5] [6] [7] [8] [93] [94] [95] [96]
#> 1 2 3 4 5 6 7 8 : 93 94 95 96
#> [97] [98] [99] [100]
#> 97 98 99 100
x <- update(x, from=y, delete=TRUE)
x
#> ff (open) integer length=100 (100)
#> [1] [2] [3] [4] [5] [6] [7] [8] [93] [94] [95] [96]
#> 1 2 3 4 5 6 7 8 : 93 94 95 96
#> [97] [98] [99] [100]
#> 97 98 99 100
y
#> ff (deleted) integer length=100 (100)
x
#> ff (open) integer length=100 (100)
#> [1] [2] [3] [4] [5] [6] [7] [8] [93] [94] [95] [96]
#> 1 2 3 4 5 6 7 8 : 93 94 95 96
#> [97] [98] [99] [100]
#> 97 98 99 100
rm(x,y); gc()
#> used (Mb) gc trigger (Mb) max used (Mb)
#> Ncells 1181890 63.2 1994352 106.6 1994352 106.6
#> Vcells 2206090 16.9 8790397 67.1 8790397 67.1
if (FALSE) { # \dontrun{
message("timings")
x <- ff(1:10000000)
y <- ff(-(1:10000000))
system.time(update(x, from=y))
system.time(update(y, from=x, delete=NA))
system.time(update(x, from=y, delete=TRUE))
rm(x,y); gc()
} # }