mtblr
: Tools to work with mtbl
files in R
mtbl
is a C library implementation of the Sorted String Table (SSTable) data structure, based on the SSTable implementation in the open source Google LevelDB library. An SSTable is a file containing an immutable mapping of keys to values. Keys are stored in sorted order, with an index at the end of the file allowing keys to be located quickly.
mtbl
is not a database library. It does not provide an updateable key-value data store, but rather exposes primitives for creating, searching and merging SSTable files. Unlike databases which use the SSTable data structure internally as part of their data store, management of SSTable files -- creation, merging, deletion, combining of search results from multiple SSTables -- is left to the discretion of the mtbl
library user.
The following functions are implemented:
read_mtbl
: Open an mtbl filemtbl_length
: Retrieve the number of records in an open mtbl fileclose_mtbl
: Close an mtbl filemtbl_map
: Start an iterator over an mtbl filemtbl_next
: Iterate over mtbl file entriesmtbl_iter_close
: Close an iterator when finishedmtbl_get
: Retrieve a key/value pair from an mtbl by keymtbl_get_prefix
: Retrieve value(s) for a given key in an mtblmtbl_keys
: Return all the keys of an mtblmtbl_values
: Return all the values of an mtblmtbl_export_values
: Export mtbl values to a fileThe following data sets are included:
system.file("extdata/sample.mtbl", package="mtblr")
0.3.0
mtbl_export_values()
to shunt values from mtbl files to a file0.2.0
read_mtbl()
0.1.0
devtools::install_github("brudis-r7/mtblr")
library(mtblr)
# current verison
packageVersion("mtblr")
## [1] '0.3.0.9000'
mtbl <- read_mtbl(system.file("extdata/sample.mtbl", package="mtblr"))
mtbl_length(mtbl)
## [1] 676
head(mtbl_keys(mtbl))
## [1] "aa" "ab" "ac" "ad" "ae" "af"
head(mtbl_values(mtbl))
## [1] "1" "2" "3" "4" "5" "6"
mtbl_next(mtbl_map(mtbl))[99][[1]]$value
## [1] "99"
mtbl_next(mtbl_get(mtbl, "aa"))[[1]]$value
## [1] "1"
mtbl_next(mtbl_get_prefix(mtbl, "a"))[[10]]$value
## [1] "10"
library(mtblr)
library(testthat)
date()
## [1] "Wed Jun 1 15:18:18 2016"
test_dir("tests/")
## testthat results ========================================================================================================
## OK: 5 SKIPPED: 0 FAILED: 0
##
## DONE ===================================================================================================================
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.