These functions form the interface for a simple file-based key-value database (i.e. hash table).
# S4 method for filehash
show(object)# S4 method for ANY
dbCreate(db, type = NULL, ...)
# S4 method for ANY
dbInit(db, type = NULL, ...)
# S4 method for filehash
names(x)
# S4 method for filehash
length(x)
# S4 method for filehash
with(data, expr, ...)
# S4 method for filehash
lapply(X, FUN, ..., keep.names = TRUE)
dbMultiFetch(db, key, ...)
dbInsert(db, key, value, ...)
dbFetch(db, key, ...)
dbExists(db, key, ...)
dbList(db, ...)
dbDelete(db, key, ...)
dbReorganize(db, ...)
dbUnlink(db, ...)
# S4 method for filehash,character,missing
[[(x, i, j)
# S4 method for filehash
$(x, name)
# S4 method for filehash,character,missing
[[(x, i, j) <- value
# S4 method for filehash
$(x, name) <- value
# S4 method for filehash,character,missing,missing
[(x, i, j, drop)
a filehash object
a filehash object
filehash database type
arguments passed to other methods
a filehash object
a filehash object
an R expression to be evaluated
a filehash object
a function to be applied
Should the key names be returned in the resulting list?
a character vector indicating a key (or keys) to retreive
an R object
a character index
not used
the name of the element in the filehash database
should dimensions be dropped? (not used)
show(filehash)
: Print a filehash object
dbCreate(ANY)
: Create a filehash database
dbInit(ANY)
: Initialize an existing filehash database
names(filehash)
: Return the keys stored in a filehash database
length(filehash)
: Return the number of objects in a filehash database
with(filehash)
: Use a filehash database as an evaluation environment
lapply(filehash)
: Apply a function over the elements of a filehash database
x[[i
: Extract elements of a filehash database using character names
$
: Extract elements of a filehash database using character names
`[[`(x = filehash, i = character, j = missing) <- value
: Replace elements of a filehash database
`$`(filehash) <- value
: Replace elements of a filehash database
x[i
: Retrieve multiple elements of a filehash database
dbMultiFetch()
: Retrieve values associated with multiple keys (a list of those values is returned).
dbInsert()
: Insert a key-value pair into the database. If that key already exists, its associated value is overwritten. For "RDS"
type databases, there is a safe
option (defaults to TRUE
) which allows the user to insert objects somewhat more safely (objects should not be lost in the event of an interrupt).
dbFetch()
: Retrieve the value associated with a given key.
dbExists()
: Check to see if a key exists.
dbList()
: List all keys in the database.
dbDelete()
: The dbDelete
function is for deleting elements, but for the "DB1"
format all it does is remove the key from the lookup table. The actual data are still in the database (but inaccessible). If you reinsert data for the same key, the new data are simply appended on to the end of the file. Therefore, it's possible to have multiple copies of data lying around after a while, potentially making the database file big. The "RDS"
format does not have this problem.
dbReorganize()
: The dbReorganize
function is there for the purpose of rewriting the database to remove all of the stale entries. Basically, this function creates a new copy of the database and then overwrites the old copy. This function has not been tested extensively and so should be considered experimental. dbReorganize
is not needed when using the "RDS"
format.
dbUnlink()
: Delete an entire database from the disk.
name
Object of class "character"
, name of the database.
Objects can be created by calls of the form new("filehash", ...)
.