Description Details Author(s) References See Also Examples
Package provides a low and high level interface to the C API of the Oracle Berkeley DB embedded database product.
Initial implementation will be to provide direct access to the low-level API calls in their entirety.
The project will eventually include a higher-level interface to make using the DB from R easier.
A large part of the API had been coded, though a much smaller subset is currently documented with respect to differences of design or necessity between RBerkleley and the C-API.
Primary difference with respect to design include the
automatic serialization of R objects via serialize
.
This can be bypassed by providing a RAW type vector to the get
and put
operations.
From a API perspective, some functions related to threads are not yet implemented, as they are not an absolute priority. Additionally functions that require C level callback function pointers have also been intentionally skipped until a later time.
All functions that appear in the RBerkeley documentation with an asterisk next to them are currently not available in the R API.
Jeffrey A. Ryan
Oracle Berkey DB
http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/overview/index.html
Databases
,
Environments
,
Cursors
,
Mutexes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | ## Not run:
db_version()
dbh <- db_create()
# set some flags and open new db
db_get_flags(dbh)
db_set_flags(dbh,mkFlags(DB_DUP))
db_open(dbh,flags=mkFlags(DB_CREATE))
db_get_flags(dbh)
db_get_dbname(dbh)
# look for non-existant key
db_get(dbh, key="mykey")
# add a key=>value
db_put(dbh, key=charToRaw("myKey"), data="myValue")
x <- matrix(1:10)
db_put(dbh, key="myKey2", data=x)
db_put(dbh, key="myKey3", data="newValue")
db_put(dbh, key="myKey4", data="myValue")
db_key_range(dbh, key="myKey2")
# add a few hundred keys/values
system.time(
for(i in 1:1000)
{
db_put(dbh, key=i, data=x)
}
)
# get value by key
db_get(dbh, key="myKey2")
db_set_priority(dbh, priority=mkFlags(DB_PRIORITY_VERY_LOW))
xr <- db_get(dbh, key="myKey2")
xr
unserialize(xr)
# cursors
dbc <- db_cursor(dbh)
dbc2 <- dbcursor_dup(dbc)
dbc2
dbcursor_get_priority(dbc)
dbcursor_set_priority(dbc, flags=mkFlags(DB_PRIORITY_LOW))
dbcursor_get_priority(dbc)
dbcursor_get(dbc, key=NULL, data=NULL, flags=0L, n=1L)
# using mkFlags for bitwise OR operations on DB constants
mkFlags(DB_SET);
dbcursor_get(dbc2, key="myKey2", data=NULL, flags=mkFlags(DB_SET), n=1L)
dbcursor_put(dbc2, key="mynewKey", data="MyNewValue", flags=mkFlags(DB_KEYFIRST))
dbcursor_get(dbc2, key="myKey2", data=NULL, flags=mkFlags(DB_PREV), n=1L)
dbcursor_get(dbc2, key="myKey2", data=NULL, flags=mkFlags(DB_FIRST), n=1L)
dbcursor_get(dbc, key=NULL, data=NULL, flags=0L, n=2L) # get 2 records
dbcursor_close(dbc)
dbcursor_close(dbc2)
dbc <- db_cursor(dbh)
dbcursor_get(dbc, key=NULL, data=NULL, flags=0L, n=-1L)
db_stat_print(dbh)
db_stat_print(dbh, flags=mkFlags(DB_FAST_STAT))
dbcursor_close(dbc)
db_exists(dbh, NULL, "myKey2", 0L)
db_get(dbh,key="myKey")
# flush to disk
db_sync(dbh)
db_get_type(dbh)
# close db
db_close(dbh)
# remove (need new handle)
dbh <- db_create()
db_remove(dbh, "access.db", NULL)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.