set_unitizer {unitizer} | R Documentation |
Set and Retrieve Store Contents
Description
These functions are not used directly; rather, they are used by
unitize
to get and set the unitizer
objects.
You should only need to understand these functions if you are
looking to implement a special storage mechanism for the unitizer
objects.
Usage
set_unitizer(store.id, unitizer)
get_unitizer(store.id)
## S3 method for class 'character'
get_unitizer(store.id)
## Default S3 method:
get_unitizer(store.id)
## S3 method for class 'unitizer_result'
get_unitizer(store.id)
## S3 method for class 'unitizer_results'
get_unitizer(store.id)
Arguments
store.id |
a filesystem path to the store (an .rds file) |
unitizer |
a |
Details
By default, only a character method is defined, which will interpret
its inputs as a filesystem path to the unitizer
folder. RDSes of
serialization type 2 will be stored and retrieved from there. The
serialization format may change in the future, but if R maintains
facilities to read/write type 2, we will provide the option to use
that format. At this time there is no API to change the serialization
format.
You may write your own methods for special storage situations (
e.g SQL database, ftp server, etc) with the understanding that the
getting method may only accept one argument, the store.id
, and
the setting method only two arguments, the store.id
and the
unitizer
.
S3 dispatch will be on store.id
, and store.id
may
be any R object that identifies the unitizer. For example, a potential
SQL implementation where the unitizers get stored in blobs may look
like so:
my.sql.store.id <- structure( list( server="myunitizerserver.mydomain.com:3306", database="unitizers", table="project1", id="cornercasetests" ), class="sql_unitizer" ) get_unitizer.sql_unitizer <- function(store.id) { # FUNCTION BODY } set_unitizer.sql_unitizer <- function(store.id, unitizer) { # FUNCTION BODY } unitize("unitizer/cornertestcases.R", my.sql.store.id)
Make sure you also define an as.character
method for your object to
produce a human readable identifying string.
For inspirations for the bodies of the _store functions look at the source
code for unitizer:::get_unitizer.character
and
unitizer:::set_unitizer.character
.
Expectations for the functions are as follows. get_unitizer
must:
return a
unitizer-class
object ifstore.id
exists and contains a valid objectreturn FALSE if the object doesn't exist (e.g. first time run-through, so reference copy doesn't exist yet)
-
stop
on error
set_unitizer
must:
return TRUE on success
-
stop
on error
Value
set_unitizer TRUE if unitizer storing worked, error otherwise
get_unitizer a
unitizer-class
object, FALSE ifstore.id
doesn't exist yet, or error otherwise; note that theunitizer_results
method returns a list