RcppLevelDB is a Rcpp based LevelDB binding for R
- leveldb, leveldb C++ library, e.g. via libleveldb-dev on Debian or Ubuntu
- Rcpp for seamless R and C++ integration
- RApiSerialize for C-level serialization from the R API
library(RcppLevelDB)
ldb <- new(LevelDB, 'my-leveldb') #creates the DB, if not exists
ldb$Put('key1', list(a=c(1,2,3), b='sometext', c=42))
#>[1] TRUE
ldb$Put('anotherkey', 'somevalue')
#>[1] TRUE
#vectorized Get & Delete operations
ldb$Get(c('key1', 'anotherkey'))
#>[[1]]
#>[[1]]$a
#>[1] 1 2 3
#>
#>[[1]]$b
#>[1] "sometext"
#>
#>[[1]]$c
#>[1] 42
#>
#>
#>[[2]]
#>[1] "somevalue"
#>
#Iteration
ldb$StartIteration()
#>[1] TRUE
ldb$IterNext()
#>[[1]]
#>[1] "anotherkey"
#>
#>[[2]]
#>[1] "somevalue"
#>
> ldb$IterNext()
#>[[1]]
#>[1] "key1"
#>
#>[[2]]
#>[[2]]$a
#>[1] 1 2 3
#>
#>[[2]]$b
#>[1] "sometext"
#>
#>[[2]]$c
#>[1] 42
#>
ldb$IterNext()
#>[[1]]
#>[1] NA
#>
#>
#Deletion
ldb$Delete(c('key1', 'anotherkey'))
#>[1] TRUE TRUE
ldb$Get(c('key1', 'anotherkey'))
#>[[1]]
#>[1] NA
#>
#>[[2]]
#>[1] NA
#>
rm(ldb) #to close the database safely
gc() # remove all handles
- Expose
Options/ReadOptions/WriteOptions
structs to R - Add default arguments to constructor and Put/Get/Delete methods e.g.
create_if_missing=TRUE
,sync=FALSE
etc. - Add support for BloomFilter policies, WriteBatch, and Iterators
- Add RepairDB and DestroyDB functions
- Something like
Structured Get
operation: create a data.frame out of values of the given query keys, when the values have a pre-defined structure - plyvel is a nice leveldb binding example to get some influence regarding new features
Gökcen Eraslan, based on RcppRedis by Dirk Eddelbuettel
Support for iterators was added by Gabe Rudy.
GPL (>= 2)