An R6 class that represents a storr interface for TileDB driver.
TileDBStorr replicates the storr interface but also enhances
it with additional new features:
notes and key expiration timestamps
asynchronous writes
Note that the following methods from storr are not supported by
TileDBStorr: $archive_import, $archive_export,
$check and $repair.
This class is not intended to be used directly and the preferred
usage is through storr_tiledb().
Public fields
envirThe object hash table.
envir_metadataThe key metadata hash table.
default_namespaceThe default namespace.
traitsDriver traits.
hash_rawThe hash function.
serialize_objectThe serialisation function.
Methods
Method new()
Initialise TileDBStorr.
Usage
TileDBStorr$new(driver, default_namespace, async = FALSE)Arguments
driverA TileDB driver, see
driver_tiledb().default_namespaceThe default namespace.
asyncShould the mirai::mirai daemons be enabled for async functions? Default is
FALSE.
Method flush_cache()
Flush the cache of R objects.
It removes all items from the hash tables (R objects and their metadata).
Method set()
Set a key value pair.
Usage
TileDBStorr$set(key, value, namespace = self$default_namespace, expires_at,
notes, use_cache = getOption("storr.tiledb.cache", TRUE))Method mset()
Set multiple key value pairs.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mset(key, value, namespace = self$default_namespace, expires_at,
notes, use_cache = getOption("storr.tiledb.cache", TRUE))Method set_async()
Set a key value pair asynchronously.
Usage
TileDBStorr$set_async(key, value, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE),
cfg = NULL)Arguments
keyA scalar character of key name.
valueAn R object to store.
namespaceA scalar character of namespace name.
expires_atA date-time object of class
POSIXct(optional).notesA scalar string of notes (optional).
use_cacheShould the cache be used? Default is
TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Returns
Invisibly, a named list with two elements:
mirai: a named list of twomirai::mirai()objects,objandkey;objrefers to object table andkeyto key table. Both return logicalTRUEif an evaluation is successful.hash: the hash value
Method mset_async()
Set multiple key value pairs asynchronously.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mset_async(key, value, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE),
cfg = NULL)Arguments
keyA character vector of key names.
valueA vector of values to store.
namespaceA character vector of namespaces.
expires_atA vector of date-times of class
POSIXct(optional).notesA character vector of notes (optional).
use_cacheShould the cache be used? Default is
TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Returns
Invisibly, a named list with two elements:
mirai: a named list of twomirai::mirai()objects,objandkey;objrefers to object table andkeyto key table. Both return logicalTRUEif an evaluation is successful.hash: a vector with hash values
Method set_by_value()
Set a key value pair using its hash as key.
Usage
TileDBStorr$set_by_value(value, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE))Method mset_by_value()
Set multiple key value pairs using their hashes as keys.
Usage
TileDBStorr$mset_by_value(value, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE))Method set_by_value_async()
Set a key value pair using its hash as key, asynchronously.
Usage
TileDBStorr$set_by_value_async(value, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE),
cfg = NULL)Arguments
valueAn R object to store.
namespaceA scalar character of namespace name.
expires_atA date-time object of class
POSIXct(optional).notesA scalar string of notes (optional).
use_cacheShould the cache be used? Default is
TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Returns
Invisibly, a named list with two elements:
mirai: a named list of twomirai::mirai()objects,objandkey;objrefers to object table andkeyto key table. Both return logicalTRUEif an evaluation is successful.hash: the hash value
Method mset_by_value_async()
Set multiple key value pairs using their hashes as keys, asynchronously.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mset_by_value_async(value, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE),
cfg = NULL)Arguments
valueA vector of values to store.
namespaceA character vector of namespaces.
expires_atA vector of date-times of class
POSIXct(optional).notesA character vector of notes (optional).
use_cacheShould the cache be used? Default is
TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Returns
Invisibly, a named list with two elements:
mirai: a named list of twomirai::mirai()objects,objandkey;objrefers to object table andkeyto key table. Both return logicalTRUEif an evaluation is successful.hash: a vector with hash values
Method set_value()
Add an R object without key.
This is used internally.
Usage
TileDBStorr$set_value(value, use_cache = getOption("storr.tiledb.cache",
TRUE))Method mset_value()
Add a vector of R objects.
This is used internally.
Usage
TileDBStorr$mset_value(values, use_cache = getOption("storr.tiledb.cache",
TRUE))Method get()
Get an object given a key-namespace pair.
Usage
TileDBStorr$get(key, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE))Method mget()
Get multiple objects.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mget(key, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE), missing = NULL)Method mget_hash()
Get hash values.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Method get_value()
Get an object given its hash.
Usage
TileDBStorr$get_value(hash, use_cache = getOption("storr.tiledb.cache",
TRUE))Method mget_value()
Get multiple objects given their hashes.
Usage
TileDBStorr$mget_value(hash, use_cache = getOption("storr.tiledb.cache",
TRUE), missing = NULL)Method set_keymeta()
Set key metadata.
Usage
TileDBStorr$set_keymeta(key, namespace = self$default_namespace, expires_at,
notes, use_cache = getOption("storr.tiledb.cache", TRUE))Arguments
keyA scalar character of key name.
namespaceA scalar character of namespace name.
expires_atA date-time object of class
POSIXct(optional).notesA scalar string of notes (optional).
use_cacheShould the cache be used to retrieve the metadata? Default is
TRUE. If a key:namespace not found in the cache, it will be fetched from database. Note that when settingFALSE, the cache will always be cleared for this key-namespace; this is to avoid mismatch between cache and database when reading back withuse_cache = TRUE.
Method mset_keymeta()
Set multiple key metadata.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mset_keymeta(key, namespace = self$default_namespace, expires_at,
notes, use_cache = getOption("storr.tiledb.cache", TRUE))Arguments
keyA character vector of key names.
namespaceA character vector of namespaces.
expires_atA vector of date-times of class
POSIXct(optional).notesA character vector of notes (optional).
use_cacheShould the cache be used to retrieve the metadata? Default is
TRUE. If a key:namespace not found in the cache, it will be fetched from database. Note that when settingFALSE, the cache will always be cleared for this key-namespace; this is to avoid mismatch between cache and database when reading back withuse_cache = TRUE.
Method set_keymeta_async()
Set key metadata asynchronously.
Usage
TileDBStorr$set_keymeta_async(key, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE),
cfg = NULL)Arguments
keyA scalar character of key name.
namespaceA scalar character of namespace name.
expires_atA date-time object of class
POSIXct(optional).notesA scalar string of notes (optional).
use_cacheShould the cache be used to retrieve the metadata? Default is
TRUE. If a key:namespace not found in the cache, it will be fetched from database. Note that when settingFALSE, the cache will always be cleared for this key-namespace; this is to avoid mismatch between cache and database when reading back withuse_cache = TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Method mset_keymeta_async()
Set multiple key metadata.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mset_keymeta_async(key, namespace = self$default_namespace,
expires_at, notes, use_cache = getOption("storr.tiledb.cache", TRUE),
cfg = NULL)Arguments
keyA character vector of key names.
namespaceA character vector of namespaces.
expires_atA vector of date-times of class
POSIXct(optional).notesA character vector of notes (optional).
use_cacheShould the cache be used to retrieve the metadata? Default is
TRUE. If a key:namespace not found in the cache, it will be fetched from database. Note that when settingFALSE, the cache will always be cleared for this key-namespace; this is to avoid mismatch between cache and database when reading back withuse_cache = TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Method get_keymeta()
Get key's metadata.
Usage
TileDBStorr$get_keymeta(key, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE))Method mget_keymeta()
Get multiple key metadata.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$mget_keymeta(key, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE), missing = NULL)Method clr_keymeta()
Remove key metadata.
This method is a convenient wrapper around set_keymeta() and mset_keymeta()
and sets the key metadata fields to NA values, i.e., as.POSIXct(NA) and
NA_character.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$clr_keymeta(key, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE))Arguments
keyA character vector of key names.
namespaceA character vector of namespaces.
use_cacheShould the cache be used to retrieve the metadata? Default is
TRUE. If a key:namespace not found in the cache, it will be fetched from database. Note that when settingFALSE, the cache will always be cleared for this key-namespace; this is to avoid mismatch between cache and database when reading back withuse_cache = TRUE.
Method clr_keymeta_async()
Remove key metadata asynchronously.
This method is a convenient wrapper around set_keymeta_async() and mset_keymeta_async()
and sets the key metadata fields to NA values, i.e., as.POSIXct(NA) and
NA_character.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$clr_keymeta_async(key, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE), cfg = NULL)Arguments
keyA character vector of key names.
namespaceA character vector of namespaces.
use_cacheShould the cache be used to retrieve the metadata? Default is
TRUE. If a key:namespace not found in the cache, it will be fetched from database. Note that when settingFALSE, the cache will always be cleared for this key-namespace; this is to avoid mismatch between cache and database when reading back withuse_cache = TRUE.cfgPass a
tiledb::config()object to override context's configuration.
Method fill()
Set one or more keys to the same value.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Usage
TileDBStorr$fill(key, value, namespace = self$default_namespace,
use_cache = getOption("storr.tiledb.cache", TRUE))Method duplicate()
Duplicate a set of keys.
Usage
TileDBStorr$duplicate(key_src, key_dest, namespace = self$default_namespace,
namespace_src = namespace, namespace_dest = namespace)Arguments
key_srcA character vector of source keys.
key_destA character vector of destination keys.
namespaceThe namespace to copy keys within (used only of
namespace_srcandnamespace_destare not provided.namespace_srcThe source namespace - use this where keys are duplicated across namespaces.
namespace_destThe destination namespace - use this where keys are duplicated across namespaces.
Method exists()
Check a key-namespace pair exists.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Method del()
Delete an object from the storr.
The arguments key and namespace can be recycled if any of them is a
scalar character and the other is a vector. No other recycling rule is permitted.
Method keys_with_expiration()
Get the key-namespace pairs with expiration timestamps.
Method expired_keys()
Get the expired key-namespace pairs.
Method list()
List all keys stored in a namespace.
Method gc()
Garbage collect the storr.
Method import()
Import objects to storr.
Usage
TileDBStorr$import(src, list = NULL, namespace = self$default_namespace,
skip_missing = FALSE)Arguments
srcA source to import objects from. It can be a storr, list, or environment.
listNames of objects to import (or
NULLfor all objects) . If given it must be a character vector. If named, the names of the character vector will be the names of the objects as created in the storr.namespaceNamespace to get objects from, and to put objects into. If
NULL, all namespaces fromsrcwill be imported. If named, then the same rule is followed aslist;namespace = c(a = b)will import the contents of namespacebas namespacea.skip_missingLogical, indicating if missing keys (specified in
list) should be skipped over, rather than being treated as an error (the default).
Method export()
Export objects from storr.
Use list() to export to a brand new list, or use as.list(object) for a shorthand.
Usage
TileDBStorr$export(dest, list = NULL, namespace = self$default_namespace,
skip_missing = FALSE)Arguments
destA destination to export objects to. It can be a storr, list, or environment.
listNames of objects to import (or
NULLfor all objects) . If given it must be a character vector. If named, the names of the character vector will be the names of the objects as created in the storr.namespaceNamespace to get objects from, and to put objects into. If
NULL, then this will export namespaces from this (source) storr into the destination; if there is more than one namespace, this is only possible ifdestis a storr (otherwise there will be an error).skip_missingLogical, indicating if missing keys (specified in
list) should be skipped over, rather than being treated as an error (the default).
Method index_import()
Import an index of objects from a storr.
Method export_tdb()
Export objects from storr to another TileDB storr.
Usage
TileDBStorr$export_tdb(key = character(0),
namespace = self$default_namespace, uri_dest, context_dest = NULL)Arguments
keyA character vector of source keys.
namespaceA character vector of namespaces or
NULLfor all namespaces.uri_destThe URI path of destination storr.
context_destOptional tiledb_ctx object for destination storr.