Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ffindexget

Reading and writing ff vectors using ff subscripts


Description

Function ffindexget allows to extract elements from an ff vector according to positive integer suscripts stored in an ff vector.
Function ffindexset allows the inverse operation: assigning to elements of an ff vector according to positive integer suscripts stored in an ff vector. These functions allow more control than the method dispatch of [ and [<- if an ff integer subscript is used.

Usage

ffindexget(x, index, indexorder = NULL, FF_RETURN = NULL
, BATCHSIZE = NULL, BATCHBYTES = getOption("ffmaxbytes"), VERBOSE = FALSE)
ffindexset(x, index, value, indexorder = NULL
, BATCHSIZE = NULL, BATCHBYTES = getOption("ffmaxbytes"), VERBOSE = FALSE)

Arguments

x

A ff vector containing the elements

index

A ff integer vector with integer subscripts in the range from 1 to length(x).

value

An ff vector of the same vmode as x containing the values to be assigned

indexorder

Optionally the return value of ffindexorder, see details

FF_RETURN

Optionally an ff vector of the same vmode as x in which the returned values shall be stored, see details.

BATCHSIZE

Optinal limit for the batchsize (see details)

BATCHBYTES

Limit for the number of bytes per batch

VERBOSE

Logical scalar for verbosing

Details

Accessing integer positions in an ff vector is a non-trivial task, because it could easily lead to random-access to a disk file. We avoid random access by loading batches of the subscript values into RAM, order them ascending, and only then access the ff values on disk. Since ordering is expensive, it may pay to do the batched ordering once upfront and then re-use it with ffindexorder, similar to storing and using hybrid index information with as.hi.

Value

Function ffindexget returns an ff vector with the extracted elements.
Function ffindexset returns the ff vector in which we have updated values.

Author(s)

Jens Oehlschlägel

See Also

Examples

message("ff integer subscripts with ff return/assign values")
x <- ff(factor(letters))
i <- ff(2:9)
xi <- x[i]
xi
xi[] <- NA
xi
x[i] <- xi
x
message("ff integer subscripts: more control with ffindexget/ffindexset")
xi <- ffindexget(x, i, FF_RETURN=xi)
x <- ffindexset(x, i, xi)
rm(x, i, xi)
gc()

ff

Memory-Efficient Storage of Large Data on Disk and Fast Access Functions

v4.0.4
GPL-2 | GPL-3 | file LICENSE
Authors
Daniel Adler [aut], Christian Gläser [aut], Oleg Nenadic [aut], Jens Oehlschlägel [aut, cre], Martijn Schuemie [aut], Walter Zucchini [aut]
Initial release
2020-10-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.