Learn R Programming

ff (version 4.5.0)

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

Description

The ff package provides data structures that are stored on disk but behave (almost) as if they were in RAM by transparently mapping only a section (pagesize) in main memory - the effective virtual memory consumption per ff object. ff supports R's standard atomic data types 'double', 'logical', 'raw' and 'integer' and non-standard atomic types boolean (1 bit), quad (2 bit unsigned), nibble (4 bit unsigned), byte (1 byte signed with NAs), ubyte (1 byte unsigned), short (2 byte signed with NAs), ushort (2 byte unsigned), single (4 byte float with NAs). For example 'quad' allows efficient storage of genomic data as an 'A','T','G','C' factor. The unsigned types support 'circular' arithmetic. There is also support for close-to-atomic types 'factor', 'ordered', 'POSIXct', 'Date' and custom close-to-atomic types. ff not only has native C-support for vectors, matrices and arrays with flexible dimorder (major column-order, major row-order and generalizations for arrays). There is also a ffdf class not unlike data.frames and import/export filters for csv files. ff objects store raw data in binary flat files in native encoding, and complement this with metadata stored in R as physical and virtual attributes. ff objects have well-defined hybrid copying semantics, which gives rise to certain performance improvements through virtualization. ff objects can be stored and reopened across R sessions. ff files can be shared by multiple ff R objects (using different data en/de-coding schemes) in the same process or from multiple R processes to exploit parallelism. A wide choice of finalizer options allows to work with 'permanent' files as well as creating/removing 'temporary' ff files completely transparent to the user. On certain OS/Filesystem combinations, creating the ff files works without notable delay thanks to using sparse file allocation. Several access optimization techniques such as Hybrid Index Preprocessing and Virtualization are implemented to achieve good performance even with large datasets, for example virtual matrix transpose without touching a single byte on disk. Further, to reduce disk I/O, 'logicals' and non-standard data types get stored native and compact on binary flat files i.e. logicals take up exactly 2 bits to represent TRUE, FALSE and NA. Beyond basic access functions, the ff package also provides compatibility functions that facilitate writing code for ff and ram objects and support for batch processing on ff objects (e.g. as.ram, as.ff, ffapply). ff interfaces closely with functionality from package 'bit': chunked looping, fast bit operations and coercions between different objects that can store subscript information ('bit', 'bitwhich', ff 'boolean', ri range index, hi hybrid index). This allows to work interactively with selections of large datasets and quickly modify selection criteria. Further high-performance enhancements can be made available upon request.

Copy Link

Version

Install

install.packages('ff')

Monthly Downloads

11,235

Version

4.5.0

License

GPL-2 | GPL-3 | file LICENSE

Issues

Pull Requests

Stars

Forks

Last Published

September 20th, 2024

Functions in ff (4.5.0)

chunk.ffdf

Chunk ff_vector and ffdf
as.ff.bit

Conversion between bit and ff boolean
as.ffdf

Coercing to ffdf and data.frame
clone.ffdf

Cloning ffdf objects
as.vmode

Coercing to virtual mode
bigsample

Sampling from large pools
dimnames.ffdf

Getting and setting dimnames of ffdf
delete

Deleting the file behind an ff object
ffapply

Apply for ff objects
dummy.dimnames

Array: make dimnames
ff

ff classes for representing (large) atomic data
ffconform

Get most conforming argument
dim.ff

Getting and setting dim and dimorder
getpagesize

Get page size information
geterror.ff

Get error and error string
ffreturn

Return suitable ff object
dimorderCompatible

Test for dimorder compatibility
ffsave

Save R and ff objects
ffload

Reload ffSaved Datasets
ffindexget

Reading and writing ff vectors using ff subscripts
ffsort

Sorting of ff vectors
ffdfsort

Sorting: convenience wrappers for data.frames
ffindexorder

Sorting: chunked ordering of integer suscript positions
ffinfo

Inspect content of ff saves
dimnames.ff

Getting and setting dimnames
ffdf

ff class for data.frames
ffsuitable

Test ff object for suitability
ffdrop

Delete an ffarchive
finalizer

Get and set finalizer (name)
ffdfindexget

Reading and writing ffdf data.frame using ff subscripts
fixdiag

Test for fixed diagonal
length.ff

Getting and setting length
maxffmode

Lossless vmode coercability
is.ff

Test for class ff
length.ffdf

Getting length of a ffdf dataframe
getset.ff

Reading and writing vectors of values (low-level)
hi

Hybrid index class
matcomb

Array: make matrix indices from row and columns positions
matprint

Print beginning and end of big matrix
is.ffdf

Test for class ff
names.ff

Getting and setting names
finalize

Call finalizer
filename

Get or set filename
file.resize

Change size of move an existing file
ffxtensions

Test for availability of ff extensions
print.ff

Print and str methods
hiparse

Hybrid Index, parsing
is.open

Test if object is opened
fforder

Sorting: order from ff vectors
mismatch

Test for recycle mismatch
na.count

Getting and setting 'na.count' physical attribute
vmode

Virtual storage mode
physical.ff

Getting and setting physical and virtual attributes of ff objects
physical.ffdf

Getting physical and virtual attributes of ffdf objects
is.readonly

Get readonly status
symmetric

Test for symmetric structure
symmIndex2vectorIndex

Array: make vector positions from symmetric array index
ramsort.default

Sorting: Sort R vector in-RAM and in-place
length.hi

Hybrid Index, querying
is.sorted

Getting and setting 'is.sorted' physical attribute
ramorder.default

Sorting: order R vector in-RAM and in-place
repnam

Replicate with names
maxlength

Get physical length of an ff or ram object
read.table.ffdf

Importing csv files into ff data.frames
splitPathFile

Analyze pathfile-strings
sortLevels

Factor level manipulation
vecprint

Print beginning and end of big vector
swap

Reading and writing in one operation (high-level)
vector.vmode

Create vector of virtual mode
vt

Virtual transpose
vw

Getting and setting virtual windows
nrowAssign

Assigning the number of rows or columns
levels.ff

Getting and setting factor levels
vector2array

Array: make array from vector
open.ff

Opening an ff file
vectorIndex2arrayIndex

Array: make array from index vector positions
ram2ffcode

Factor codings
write.table.ffdf

Exporting csv files from ff data.frames
unsort

Hybrid Index, internal utilities
update.ff

Update ff content from another object
ramattribs

Get ramclass and ramattribs
readwrite.ff

Reading and writing vectors (low-level)
regtest.fforder

Sorting: regression tests
pagesize

Pagesize of ff object
undim

Undim
unclass_-

Unclassed assignement
vmode.ffdf

Virtual storage mode of ffdf
CFUN

Collapsing functions for batch processing
add

Incrementing an ff or ram object
as.ff

Coercing ram to ff and ff to ram objects
Internal_ffdf

Internal ffdf functions
array2vector

Array: make vector from array
arrayIndex2vectorIndex

Array: make vector positions from array index
Extract.ffdf

Reading and writing data.frames (ffdf)
Extract.ff

Reading and writing vectors and arrays (high-level)
LimWarn

ff Limitations and Warnings
as.hi

Hybrid Index, coercion to
Forbidden_ffdf

Forbidden ffdf functions
close.ff

Closing ff files
as.integer.hi

Hybrid Index, coercing from
clone.ff

Cloning ff and ram objects