Skip to content

ff() sometimes gets wrong length when reading from disk

1 message · Jens Oehlschlägel

#
Andrew,

Everything is fine!

# look at this small example
library(ff)
x <- ff(1:3, filename="c:/temp/x.ff")
y <- ff(c(F,F,T), filename="c:/temp/y.ff")
d <- ffdf(x,y)

# reading this gives length 3 as expected
x2 <- ff(vmode="integer", filename="c:/temp/x.ff")
# reading this gives length 16 because logicals are stored compressed to 2bits per element rounded up to full integers (the file has 4 bytes = 32 bits = 16 logicals)
y2 <- ff(vmode="logical", filename="c:/temp/y.ff")
# and since ffdf expects equal lengths you get that error
ffdf(x2,y2)
# you could theoretically fix that by explicitely specifying the length on reading the file
y2 <- ff(vmode="logical", filename="c:/temp/y.ff", length=3)
ffdf(x2,y2)
# but it is much easier to save the R-side metadata of your ffdf
save(d, file="c:/temp/d.RData")
# close R
# open R
# and after
library(ff)
load(file="c:/temp/d.RData")
open(d)
# you can continue working with that ffdf as if R was never closed

Cheers
Jens


-----Urspr?ngliche Nachricht-----
Von: "Andrew Piskorski" <atp at piskorski.com>
Gesendet: 25.05.2011 23:07:41
An: "Dr. Jens Oehlschlaegel" <Jens.Oehlschlaegel at truecluster.com>
Betreff: ff() sometimes gets wrong length when reading from disk