filehash-class: Filehash Class

filehash-classR Documentation

Filehash Class

Description

These functions form the interface for a simple file-based key-value database (i.e. hash table).

Usage

## S4 method for signature 'filehash'
show(object)

## S4 method for signature 'ANY'
dbCreate(db, type = NULL, ...)

## S4 method for signature 'ANY'
dbInit(db, type = NULL, ...)

## S4 method for signature 'filehash'
names(x)

## S4 method for signature 'filehash'
length(x)

## S4 method for signature 'filehash'
with(data, expr, ...)

## S4 method for signature '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 signature 'filehash,character,missing'
x[[i, j]]

## S4 method for signature 'filehash'
x$name

## S4 replacement method for signature 'filehash,character,missing'
x[[i, j]] <- value

## S4 replacement method for signature 'filehash'
x$name <- value

## S4 method for signature 'filehash,character,missing,missing'
x[i, j, drop]

Arguments

object

a filehash object

db

a filehash object

type

filehash database type

...

arguments passed to other methods

x

a filehash object

data

a filehash object

expr

an R expression to be evaluated

X

a filehash object

FUN

a function to be applied

keep.names

Should the key names be returned in the resulting list?

key

a character vector indicating a key (or keys) to retreive

value

an R object

i

a character index

j

not used

name

the name of the element in the filehash database

drop

should dimensions be dropped? (not used)

Details

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

Methods (by generic)

  • 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

Functions

  • 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.

Slots

name

Object of class "character", name of the database.


filehash documentation built on June 26, 2024, 1:06 a.m.