Skip to content

Commit

Permalink
Fix issues highlighted by @lmullen
Browse files Browse the repository at this point in the history
- donttest examples should be happy now
- spelling fixed
- suggest, not import, dbplyr
  • Loading branch information
cboettig committed Jun 11, 2018
1 parent 63a62a2 commit 1a33432
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 33 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: arkdb
Version: 0.0.0.9000
Title: Archive and Unarchive Databases Using Flat Files
Description: Flat text files provide a more robust, compressable,
Description: Flat text files provide a more robust, compressible,
and portable way to store tables. This package provides convenient
functions for exporting tables from relational database connections
into compressed text files and streaming those text files back into
Expand All @@ -21,14 +21,14 @@ VignetteBuilder: knitr
RoxygenNote: 6.0.1.9000
Roxygen: list(markdown = TRUE)
Imports:
dbplyr,
DBI,
readr,
progress,
dplyr,
methods,
tools
Suggests:
dbplyr,
nycflights13,
testthat,
knitr,
Expand Down
16 changes: 7 additions & 9 deletions R/ark.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' Archive tables from a database as flat files
#'
#' @param db_con a database connection
#' @param dir a directory where we will write the compressed text files ouput
#' @param dir a directory where we will write the compressed text files output
#' @param lines the number of lines to use in each single chunk
#' @param compress file compression algorithm. Should be one of "bzip2" (default),
#' "gzip" (faster write times, a bit less compression), or "xz".
Expand All @@ -13,7 +13,7 @@
#' is probably why you are using a database in the first place!) Compressed
#' text files will likely take up much less space, making them easier to store and
#' transfer over networks. Compressed plain-text files are also more archival
#' friendly, as they rely on widely avialable and long-established open source compression
#' friendly, as they rely on widely available and long-established open source compression
#' algorithms and plain text, making them less vulnerable to loss by changes in
#' database technology and formats.
#'
Expand All @@ -23,17 +23,15 @@
#'
#' @examples
#' \donttest{
#' sql_path <- tempdir()
#' db <- dbplyr::nycflights13_sqlite(sql_path)
#' dir <- file.path(tempdir(), "nycflights")
#' dir.create(dir)
#' # setup
#' library(dplyr)
#' dir <- tempdir()
#' db <- dbplyr::nycflights13_sqlite(tempdir())
#'
#' ## And here we go:
#' ark(db, dir)
#' list.files(dir)
#'
#'
#' ## clean up
#' unlink(dir, TRUE)
#' }
ark <- function(db_con, dir, lines = 10000L,
compress = c("bzip2", "gzip", "xz")){
Expand Down
11 changes: 5 additions & 6 deletions R/unark.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## 1. consider supporting non tsv formats?


#' Unarchive a list of compressed tsv files into a databaase
#' Unarchive a list of compressed tsv files into a database
#' @param files vector of filenames to be read in. Must be `tsv`
#' format compressed using `bzip2`, `gzip`, `zip`, or `xz` format
#' at present.
Expand All @@ -23,23 +23,22 @@
#' @return a database connection (invisibly)
#'
#' @examples \donttest{
#'
#' ## Setup: create an archive.
#' library(dplyr)
#' dir <- tempdir()
#' db <- dbplyr::nycflights13_sqlite(tempdir())
#'
#' ## database -> .tsv.bz2
#' ark(db)
#' ark(db, dir)
#'
#' ## list all files in archive (full paths)
#' files <- list.files(dir, "[.tsv.gz]", full.names = TRUE)
#' files <- list.files(dir, "[.]tsv\\.bz2$", full.names = TRUE)
#'
#' ## Read archived files into a new database (defaults to sqlite)
#' new_db <- src_sqlite("local.sqlite", create=TRUE)
#' new_db <- src_sqlite(file.path(dir, "local.sqlite"), create=TRUE)
#' unark(files, new_db)
#'
#' ## Prove table is returned successfully.
#' library(dplyr)
#' tbl(new_db, "flights")
#'
#' }
Expand Down
16 changes: 7 additions & 9 deletions man/ark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions man/unark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1a33432

Please sign in to comment.