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 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":

     '_d_a_t_a_f_i_l_e': Object of class '"character"', full path to the
          database file.

     '_m_a_p_f_i_l_e': Object of class '"character"', full path to the index
          file.

_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_b_D_i_r: Directory where files are stored.

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

     _d_b_D_e_l_e_t_e 'signature(db = "filehash", key = "character")': The
          'dbDelete' function is for deleting elements, but for the
          '"DB"' 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 'signature(db = "filehash", key = "character")': check to
          see if a key exists.

     _d_b_F_e_t_c_h 'signature(db = "filehash", key = "character")': retrieve
          the value associated with a given key.

     _d_b_I_n_s_e_r_t 'signature(db = "filehash", key = "character")': insert a
          key-value pair into the database.  If that key already
          exists, its associated value is overwritten.

     _d_b_L_i_s_t 'signature(db = "filehash")': list all keys in the
          database.

     _d_b_R_e_o_r_g_a_n_i_z_e 'signature(db = "filehashDB")': 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_.  '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  

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

     Roger D. Peng rpeng@jhsph.edu

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

     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"

     with(db, mean(b))

