we can use toc() and lload() for each and then compare the results.
toc( "inst/sampleRDA/utilsNamespace.rda")
Error for toc( "inst/sampleRDA/NULL.rda")
Error in names(ans)[name] = tag :
'names' attribute [1] must be the same length as the vector [0]
Problem is that we are populating a list() and the first value is
NULL. When we insert that with ans[[1]] = NULL
, we end up with an empty list.
Then we set the name and there is no element.
We can use list(NULL)
for the first element.
[check result] Error toc("inst/sampleRDA/emptyenv.rda")
[check result] Error toc("inst/sampleRDA/symbol.rda")
See wrapObject() and setOffset()
Check examples
rdas = list.files("../inst/sampleRDA", pattern = "\\.rda", full = TRUE)
tmp = structure(lapply(rdas, function(x) try(toc(x))), names = rdas)
err = sapply(tmp, inherits, 'try-error')
table(err)
tt = table(unlist(lapply(tmp[!err], function(x) as.data.frame(x)$type)))
setdiff(names(RDAInfo:::SEXPMap), names(tt))
Currently errors for 3 of 43
function_with_attrs.rda - lload() messes up the function - no body.
18 SEXP types remaining
WEAKREFSXP = 23
NILSXP
ALTREP_SXP
Not mentioned in serialize.c
√ EXPRSXP = 20 check
√ SYMSXP <<<<<<<<<<<<< not in test cases
See traceSEXP.R for determining which SEXP types were processed.
√ Change in R-devel for OBJSXP and not S4SXP
BCODESXP
"~/OGS/SUForm/ProcessForm/June8.rda"
ALTREP_SXP
sexp type = 2 depth = 0 hastag = 1 hasattr = 0
sexp type = 1 depth = 1 hastag = 0 hasattr = 0
sexp type = 9 depth = 2 hastag = 0 hasattr = 0
sexp type = 238 depth = 1 hastag = 0 hasattr = 0
sexp type = 2 depth = 2 hastag = 0 hasattr = 0
sexp type = 1 depth = 3 hastag = 0 hasattr = 0
sexp type = 9 depth = 4 hastag = 0 hasattr = 0
sexp type = 2 depth = 2 hastag = 0 hasattr = 0
sexp type = 1 depth = 3 hastag = 0 hasattr = 0
sexp type = 9 depth = 4 hastag = 0 hasattr = 0
sexp type = 2 depth = 2 hastag = 0 hasattr = 0
sexp type = 13 depth = 3 hastag = 0 hasattr = 0
sexp type = 254 depth = 2 hastag = 0 hasattr = 0
sexp type = 2 depth = 2 hastag = 0 hasattr = 0
sexp type = 16 depth = 3 hastag = 0 hasattr = 0
sexp type = 9 depth = 4 hastag = 0 hasattr = 0
.... repeated for 264 elements
sexp type = 13 depth = 2 hastag = 0 hasattr = 0 <<<<<<<<<<<<<<<<
sexp type = 2 depth = 2 hastag = 1 hasattr = 0 <<<<<<<<<<<<<<<<
sexp type = 1 depth = 3 hastag = 0 hasattr = 0
sexp type = 9 depth = 4 hastag = 0 hasattr = 0
sexp type = 16 depth = 3 hastag = 0 hasattr = 0
In the R code, this last entry does not have a tag. The value is simply 2. So reading the next entry goes wrong. This is the start of the readPairList
When we read the 13 as the next element of the state pair list after the character vector, we have a ty of 13, but then call ReadItem which reads the type. We already have the type.
References at the toplevel
capture concept that restoring b means binding to the value of a.
[test] Capture the references.
√ See Expression.rda. The second call has "20" where a should be.
Handling character encoding.
See ReadChar in serialize.c. The encoding is in the levs flag.
get file name from the connection
add it to the RDAToc object returned by toc() if we start with a connection.
FIX: doesn't work. But lapply(unclass(info), ...)
does.
f = "inst/sampleRDA/class_named_integer_logical_character_uncompress.rda"
info = toc(f)
sapply(info, function(x) x$offset)
sapply(unclass(info), function(x) x$offset) # works
A method for lapply()? for RDA.toc
[ok but could be better] seek() on a gzfile to an offset is not working reliably.
d$offset = p : object of type
'symbol' is not subsettable
which we see when reading a simple symbol.11: readRDA.R#39: readExternalPointer(con, elInfo, skipValue, hdr, de
12: readRDA.R#688: ReadItem(con, skipValue, hdr, depth + 1)
13: readRDA.R#39: readREFSXP(con, ty, hdr)
14: readRDA.R#751: get(as.character(ref - 1), hdr$references)
would have to change ReadItem for this object to collect the number of expressions or we can set skipValue = FALSE and reconstruct the body.
Do we want the attributes on an expression
See inst/sampleRDA/Expression.rda and srcref, wholeref
Do we want the srcref for functions?
√ S4 - putting the tag on an empty ans in readPairList names(ans)[name] = tag
√ In addDescAttrs(), ignore values that have length 0.
See "../inst/sampleRDA/dotsFunction.rda"
√ In readEnvironment(), wrap the ans$names value in a list() since a data.frame with 1 row.
was getting all the remaining elements after this object.
√ factor() example.
see toc("inst/sampleRDA/factor.rda")
√ regular list objects
o = toc("inst/sampleRDA/list.rda")
√ names of parameters
EXTPTRSXP = 22
z = toc("inst/sampleRDA/externalpointer_withAttrs.rda")
Example objects to test.
√ Do we handle NAs in character vectors.
√ name for object in simpleFunction.rda Seems to be 1, not simpleFun.
√ References for ENVSXP.
√ make [.RDAToc open the file once, read the objects in order of smallest offset and jump to the next amount.
√ When read the entire file in toc mode, then access an object, the second read/pass will add references that are already in the references.
perhaps toc() "locks" the environment as it knows it has done a pass over the entire file
√ Registering each symsxp twice. and in pairs, i.e., not interspersed by others.
solved - readSYMSXP() was calling readTag() and then registering the result. But readTag() was also registering the result.
√ combine the data.frames when printing.
√ Implement [[ integer for RDAToc.
√ Fix putting formals() on the function in readFunction when not skipping value.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.