Learn R Programming

filehash (version 0.2-1)

filehash-package: filehash overview

Description

Simple file-based hash table

Arguments

Details

ll{ Package: filehash Version: 0.2 Date: 2005-06-25 LazyLoad: yes Depends: R (>= 2.1.0) License: GNU GPL (version 2 or later) URL: http://sandybox.typepad.com/software/ }

Index: db2env Load database into environment dbUtils Simple file-based hash table filehash-class Class "filehash" filehash-package filehash overview

This package implements a very simple file-based hash table (i.e. key-value database). The idea is basically the same as that used by R internally for its lazy-loaded databases but the implementation is far cruder. There is no C code here, just pure R.

One advantage of using a GDBM-type system is that it puts all the data into one file rather than having many files lying around. One disadvantage of using GDBM specifically is that the database file is not portable. For example, you need separate versions of the same database for i686 and x86_64 architectures.

filehash takes objects, serializes them to an ASCII string and converts the string to raw bytes (via charToRaw). The raw sequence of bytes is appended to a database file and the starting and ending offset positions in the file are stored in an environment. When a user requests an object associated with a specific key via dbFetch, the key is used to look up the byte/offset numbers and then the data are read from that position in the database file. The filehash package uses 2 files---one file (with extension idx) to store the index positions and another file (with extension rdb) to store the data.

Examples

Run this code
## See 'class ? filehash' for examples

Run the code above in your browser using DataLab