filehash-class           package:filehash           R Documentation

_C_l_a_s_s "_f_i_l_e_h_a_s_h"

_D_e_s_c_r_i_p_t_i_o_n:

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

_O_b_j_e_c_t_s _f_r_o_m _t_h_e _C_l_a_s_s:

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

_S_l_o_t_s:

     '_n_a_m_e': Object of class '"character"', name of the database.

_A_d_d_i_t_i_o_n_a_l _s_l_o_t_s _f_o_r "_f_i_l_e_h_a_s_h_D_B_1":

     '_d_a_t_a_f_i_l_e': full path to the database file.

     '_m_e_t_a': list containing an environment for database metadata.

_A_d_d_i_t_i_o_n_a_l _s_l_o_t_s _f_o_r "_f_i_l_e_h_a_s_h_R_D_S":

     _d_i_r: Directory where files are stored.

_M_e_t_h_o_d_s:

     _d_b_D_e_l_e_t_e 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.

     _d_b_E_x_i_s_t_s check to see if a key exists.

     _d_b_F_e_t_c_h retrieve the value associated with a given key.

     _d_b_M_u_l_t_i_F_e_t_c_h retrieve values associated with multiple keys (a list
          of those values is returned).

     _d_b_I_n_s_e_r_t insert a key-value pair into the database.  If that key
          already exists, its associated value is overwritten.

     _d_b_L_i_s_t list all keys in the database.

     _d_b_R_e_o_r_g_a_n_i_z_e 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.

     _d_b_U_n_l_i_n_k delete an entire database from the disk

     _s_h_o_w print method

     _w_i_t_h allows 'with' to be used with '"filehash"' objects much like
          it can be used with lists or data frames

     [[,[[<- elements of a database can be accessed using the '[['
          operator much like a list or environment, but only character
          indices are allowed

     $,$<- elements of a database can be accessed using the '$'
          operator much like with a list or environment

     _l_a_p_p_l_y works much like 'lapply' with lists; a list is returned.

_A_u_t_h_o_r(_s):

     Roger D. Peng rpeng@jhsph.edu

_E_x_a_m_p_l_e_s:

     dbCreate("myDB")  ## Create database 'myDB'
     db <- dbInit("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) ## "b"

     with(db, mean(b))

