Functions for getting physical and virtual attributes of ffdf objects.

# S3 method for class 'ffdf'
physical(x)
# S3 method for class 'ffdf'
virtual(x)

Arguments

x

an ffdf object

Details

ffdf objects enjoy a complete decoupling of virtual behaviour from physical storage. The physical component is simply a (potentially named) list where each element represents an atomic ff vector or matrix. The virtual component is itself a dataframe, each row of which defines a column of the ffdf through a mapping to the physical component.

Value

'physical.ffdf' returns a list with atomic ff objects.
'virtual.ffdf' returns a data.frame with the following columns

VirtualVmode

the vmode of this row (=ffdf column)

AsIs

logical defining the AsIs status of this row (=ffdf column)

VirtualIsMatrix

logical defining whether this row (=ffdf column) represents a matrix

PhysicalIsMatrix

logical reporting whether the corresponding physical element is a matrix

PhysicalElementNo

integer identifying the corresponding physical element

PhysicalFirstCol

integer identifying the first column of the corresponding physical element (1 if it is not a matrix)

PhysicalLastCol

integer identifying the last column of the corresponding physical element (1 if it is not a matrix)

Author

Jens Oehlschlägel

See also

Examples

  x <- 1:2
  y <- matrix(1:4, 2, 2)
  z <- matrix(1:4, 2, 2)

  message("Here the y matrix is first converted to single columns by data.frame, 
then those columns become ff")
#> Here the y matrix is first converted to single columns by data.frame, 
#> then those columns become ff
  d <- as.ffdf(data.frame(x=x, y=y, z=I(z)))
  physical(d)
#> $x
#> ff (open) integer length=2 (2)
#> [1]     [2] 
#>   1   :   2 
#> 
#> $y.1
#> ff (open) integer length=2 (2)
#> [1]     [2] 
#>   1   :   2 
#> 
#> $y.2
#> ff (open) integer length=2 (2)
#> [1]     [2] 
#>   3   :   4 
#> 
#> $z
#> ff (open) integer length=4 (4) dim=c(2,2) dimorder=c(1,2)
#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4
#> 
  virtual(d)
#>     VirtualVmode  AsIs VirtualIsMatrix PhysicalIsMatrix PhysicalElementNo
#> x        integer FALSE           FALSE            FALSE                 1
#> y.1      integer FALSE           FALSE            FALSE                 2
#> y.2      integer FALSE           FALSE            FALSE                 3
#> z        integer  TRUE            TRUE             TRUE                 4
#>     PhysicalFirstCol PhysicalLastCol
#> x                  1               1
#> y.1                1               1
#> y.2                1               1
#> z                  1               2

  message("Here the y matrix is first converted to ff, and then stored still as matrix 
in the ffdf object (although virtually treated as columns of ffdf)")
#> Here the y matrix is first converted to ff, and then stored still as matrix 
#> in the ffdf object (although virtually treated as columns of ffdf)
  d <- ffdf(x=as.ff(x), y=as.ff(y), z=I(as.ff(z)))
  physical(d)
#> $x
#> ff (open) integer length=2 (2)
#> [1]     [2] 
#>   1   :   2 
#> 
#> $y
#> ff (open) integer length=4 (4) dim=c(2,2) dimorder=c(1,2)
#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4
#> 
#> $z
#> ff (open) integer length=4 (4) dim=c(2,2) dimorder=c(1,2)
#>      [,1] [,2]
#> [1,]    1    3
#> [2,]    2    4
#> 
  virtual(d)
#>     VirtualVmode  AsIs VirtualIsMatrix PhysicalIsMatrix PhysicalElementNo
#> x        integer FALSE           FALSE            FALSE                 1
#> y.1      integer FALSE           FALSE             TRUE                 2
#> y.2      integer FALSE           FALSE             TRUE                 2
#> z        integer  TRUE            TRUE             TRUE                 3
#>     PhysicalFirstCol PhysicalLastCol
#> x                  1               1
#> y.1                1               1
#> y.2                2               2
#> z                  1               2

  message("Apply the usual methods extracting physical attributes")
#> Apply the usual methods extracting physical attributes
  lapply(physical(d), filename)
#> $x
#> [1] "/tmp/Rtmph7o01n/ff/clone345fc075b292be.ff"
#> 
#> $y
#> [1] "/tmp/Rtmph7o01n/ff/clone345fc04fa84f59.ff"
#> 
#> $z
#> [1] "/tmp/Rtmph7o01n/ff/clone345fc06adb98cb.ff"
#> 
  lapply(physical(d), vmode)
#> $x
#> [1] "integer"
#> 
#> $y
#> [1] "integer"
#> 
#> $z
#> [1] "integer"
#> 
  message("And don't confuse with virtual vmode")
#> And don't confuse with virtual vmode
  vmode(d)
#>         x       y.1       y.2         z 
#> "integer" "integer" "integer" "integer" 

  rm(d); gc()
#>           used (Mb) gc trigger  (Mb) max used  (Mb)
#> Ncells 1162688 62.1    1994352 106.6  1994352 106.6
#> Vcells 2167146 16.6    8790397  67.1  8790397  67.1