Stores R values. It stores the values in an efficient ways that scales to millions of unique values and provides a rich query API to find values from the database.
db <- open_db("cran_db")
add_val(db, 45)
add_val(db, list(a = 34, b = c(34.5, 45), c = "test"))
add_val_origin(db, 450, "pkg", "fun", "arg1")
print(sample_val(db))
db2 <- open_db("db2")
merge_db(db, db2)
close_db(db)
close_db(db2)
db <- open_db("cran_db", quiet=FALSE)
add_val(db, 45)
db[0]
summary(db)
length(db)
close(db)
To serialize and faithfully reconstruct arbitrary R values in a performant way, sxpdb's C++ code
reads and writes SEXP internals through a few R entry points that are not part
of the public C API: ATTRIB, LEVELS, SETLEVELS, and REFCNT. These cover
the object's attributes, its gp "general purpose" bits, and its reference
count, for which R currently exposes no supported public equivalent.
R CMD check reports this under "checking compiled code" ("Found non-API calls
to R").
The trade-off is that R core may change or remove them without
notice, which could require updating sxpdb to keep pace.
Make sure to activate pre-commit hooks. We use pre-commit