https://github.com/gokceneraslan/rcppleveldb
Rcpp bindings for Google's leveldb
https://github.com/gokceneraslan/rcppleveldb
leveldb leveldb-binding r rcpp
Last synced: about 1 year ago
JSON representation
Rcpp bindings for Google's leveldb
- Host: GitHub
- URL: https://github.com/gokceneraslan/rcppleveldb
- Owner: gokceneraslan
- License: gpl-2.0
- Created: 2015-09-22T08:17:22.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-01-19T10:54:29.000Z (over 10 years ago)
- Last Synced: 2023-03-22T22:57:13.514Z (over 3 years ago)
- Topics: leveldb, leveldb-binding, r, rcpp
- Language: C++
- Size: 12.7 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## RcppLevelDB [](http://www.gnu.org/licenses/gpl-2.0.html)
RcppLevelDB is a Rcpp based LevelDB binding for R
### Dependencies
- [leveldb](https://github.com/google/leveldb), leveldb C++ library, e.g. via [libleveldb-dev](https://packages.debian.org/sid/libleveldb-dev) on Debian or Ubuntu
- [Rcpp](https://github.com/RcppCore/Rcpp) for seamless R and C++ integration
- [RApiSerialize](https://github.com/eddelbuettel/rapiserialize) for C-level serialization from the R API
### Getting Started
```r
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
```
### TODO
- 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](https://plyvel.readthedocs.org/en/latest/api.html) is a nice leveldb binding example to get some influence regarding new features
### Authors
Gökcen Eraslan, based on RcppRedis by Dirk Eddelbuettel
Support for iterators was added by Gabe Rudy.
### License
GPL (>= 2)