filehash-class {filehash}R Documentation

Class "filehash"

Description

These functions form the interface for a simple file-based hash table not unlike gdbm (although simpler).

Objects from the Class

Objects can be created by calls of the form new("filehash", ...).

Slots

datafile:
Object of class "character", full path to the database file.
mapfile:
Object of class "character", full path to the index file.
name:
Object of class "character", name of the database.

Methods

dbDelete
signature(db = "filehash", key = "character"): The dbDelete function is for deleting elements, but 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.
dbExists
signature(db = "filehash", key = "character"): check to see if a key exists.
dbFetch
signature(db = "filehash", key = "character"): retrieve the value associated with a given key.
dbInsert
signature(db = "filehash", key = "character"): insert a key-value pair into the database. If that key already exists, its associated value is overwritten.
dbList
signature(db = "filehash"): list all keys in the database.
dbReorganize
signature(db = "filehash"): 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 much and so should be considered experimental.
db2env
signature(db = "filehash"): loads "filehash" database into an environment via calls to makeActiveBinding

Author(s)

Roger D. Peng rpeng@jhsph.edu

Examples

dbCreate("myDB")  ## Create files 'myDB.idx' and 'myDB.rdb'
db <- dbInitialize("myDB")
dbInsert(db, "a", 1:10)
dbInsert(db, "b", rnorm(1000))
dbExists(db, "b")  ## 'TRUE'

dbList(db)  ## c("a", "b")
dbDelete(db, "a")
dbList(db) ## "a"

[Package filehash version 0.2 Index]