Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions R/streamable_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#' streamable_readr_tsv <- function() {
#' streamable_table(
#' function(file, ...) readr::read_tsv(file, ...),
#' function(x, path, omit_header) {
#' readr::write_tsv(x = x, path = path, omit_header = omit_header)
#' function(x, file, omit_header) {
#' readr::write_tsv(x = x, file = file, omit_header = omit_header)
#' },
#' "tsv"
#' )
Expand Down Expand Up @@ -66,7 +66,7 @@ assert_streamable <- function(x, name = deparse(substitute(x))) {
#'
streamable_vroom <- function() {

## Avoids a hard dependency on readr for this courtesy function
## Avoids a hard dependency on vroom for this courtesy function
if (!requireNamespace("vroom", quietly = TRUE)) {
stop("vroom package must be installed to use readr-based methods",
call. = FALSE
Expand All @@ -80,8 +80,8 @@ streamable_vroom <- function() {
read <- function(file, ...) {
read_tsv(file, ...)
}
write <- function(x, path, omit_header = FALSE) {
write_tsv(x = x, path = path, append = omit_header)
write <- function(x, file, omit_header = FALSE) {
write_tsv(x = x, file = file, append = omit_header)
Comment on lines +83 to +84

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine I'll make similar changes in vroom soon. Same deal.

}

streamable_table(read, write, "tsv")
Expand Down Expand Up @@ -113,8 +113,8 @@ streamable_readr_tsv <- function() {
read <- function(file, ...) {
read_tsv(file, ...)
}
write <- function(x, path, omit_header = FALSE) {
write_tsv(x = x, file = path, append = omit_header)
write <- function(x, file, omit_header = FALSE) {
write_tsv(x = x, file = file, append = omit_header)
}

streamable_table(read, write, "tsv")
Expand All @@ -140,8 +140,8 @@ streamable_readr_csv <- function() {
read <- function(file, ...) {
read_csv(file, ...)
}
write <- function(x, path, omit_header = FALSE) {
write_csv(x = x, file = path, append = omit_header)
write <- function(x, file, omit_header = FALSE) {
write_csv(x = x, file = file, append = omit_header)
}

streamable_table(read, write, "csv")
Expand Down Expand Up @@ -285,14 +285,14 @@ streamable_parquet <- function() {
)
} else {
fls <- list.files(dir_path)

if(length(fls) == 0) {
n <- 1
} else {
# Find max part number, and increment
n <- max(as.integer(gsub(".*?([0-9]+).*", "\\1", fls))) + 1
}

# Overload path accordingly
path <- paste0(
dir_path, "/part-", formatC(n, width=5, flag="0"), ".parquet")
Expand Down
4 changes: 2 additions & 2 deletions vignettes/arkdb.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ unark(files, new_db,
stream <-
streamable_table(
function(file, ...) readr::read_tsv(file, ...),
function(x, path, omit_header)
readr::write_tsv(x = x, path = path, append = omit_header),
function(x, file, omit_header)
readr::write_tsv(x = x, file = file, append = omit_header),
"tsv")

```
Expand Down