Skip to content

Commit

Permalink
Use read_delim_chunked(chunk_size=) again
Browse files Browse the repository at this point in the history
This was mistakenly ignored as part of the vroom conversion

Fixes #1248
  • Loading branch information
jimhester committed Jul 27, 2021
1 parent 3c0e4d8 commit 3c46de1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Avoid spurious byte compilation errors due to the programatically generated `spec_*()` functions.

* `read_delim_chunked()` now again correctly respects the `chunk_size` parameter (#1248)

# readr 2.0.0

## second edition changes
Expand Down
9 changes: 5 additions & 4 deletions R/read_delim_chunked.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
generate_read_delimited_chunked <- function(x) {
args <- formals(x)
args <- args[names(args) != "n_max"]
args <- append(args, alist(callback = , chunk_size = 10000), 1)
args <- append(args, alist(callback = , chunk_size =), 1)

# Change guess_max default to use chunk_size
args$guess_max[[3]] <- quote(chunk_size)
Expand Down Expand Up @@ -76,9 +76,10 @@ read_delim_chunked <- function(file, callback, delim = NULL, chunk_size = 10000,
skip_empty_rows = skip_empty_rows
)
read_delimited_chunked(file,
callback = callback, tokenizer = tokenizer, col_names = col_names, col_types = col_types,
locale = locale, skip = skip, skip_empty_rows = skip_empty_rows,
comment = comment, guess_max = guess_max, progress = progress
callback = callback, chunk_size = chunk_size, tokenizer = tokenizer,
col_names = col_names, col_types = col_types, locale = locale, skip = skip,
skip_empty_rows = skip_empty_rows, comment = comment, guess_max = guess_max,
progress = progress
)
}

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-read-chunked.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ test_that("read_delim_chunked", {
expect_true(all(vapply(dims[1:6], identical, logical(1), c(5L, 11L))))
expect_true(identical(dims[[7]], c(2L, 11L)))

# In chunks of 5 with read_delim
dims <- list()
read_delim_chunked(file, delim = ",", get_dims, chunk_size = 5)
expect_true(all(vapply(dims[1:6], identical, logical(1), c(5L, 11L))))
expect_true(identical(dims[[7]], c(2L, 11L)))

# Halting early
get_dims_stop <- function(data, pos) {
dims[[length(dims) + 1]] <<- dim(data)
Expand Down

0 comments on commit 3c46de1

Please sign in to comment.