Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
23 changes: 13 additions & 10 deletions r/R/compression.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ Codec <- R6Class("Codec", inherit = Object)
#'
#' @export
compression_codec <- function(type = "GZIP") {
type <- CompressionType[[match.arg(type, names(CompressionType))]]
unique_ptr(Codec, util___Codec__Create(type))
if (is.character(type)) {
type <- unique_ptr(Codec, util___Codec__Create(
CompressionType[[match.arg(type, names(CompressionType))]]
))
} else if (!inherits(type, "Codec")) {
abort("Not compatible with requested type")
}

type
}

#' @title Compressed stream classes
Expand Down Expand Up @@ -56,11 +63,8 @@ compression_codec <- function(type = "GZIP") {
#' @export
#' @include arrow-package.R
CompressedOutputStream <- R6Class("CompressedOutputStream", inherit = OutputStream)
CompressedOutputStream$create <- function(stream, codec = compression_codec()){
if (.Platform$OS.type == "windows") {
stop("'CompressedOutputStream' is unsupported in Windows.")
}
assert_is(codec, "Codec")
CompressedOutputStream$create <- function(stream, codec = "GZIP"){
codec <- compression_codec(codec)
if (is.character(stream)) {
stream <- FileOutputStream$create(stream)
}
Expand All @@ -73,9 +77,8 @@ CompressedOutputStream$create <- function(stream, codec = compression_codec()){
#' @format NULL
#' @export
CompressedInputStream <- R6Class("CompressedInputStream", inherit = InputStream)
CompressedInputStream$create <- function(stream, codec = compression_codec()){
# TODO (npr): why would CompressedInputStream work on Windows if CompressedOutputStream doesn't? (and is it still the case that it does not?)
assert_is(codec, "Codec")
CompressedInputStream$create <- function(stream, codec = "GZIP"){
codec <- compression_codec(codec)
if (is.character(stream)) {
stream <- ReadableFile$create(stream)
}
Expand Down
3 changes: 2 additions & 1 deletion r/data-raw/codegen.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ suppressPackageStartupMessages({
library(dplyr)
library(purrr)
library(glue)
library(vctrs)
})

if (packageVersion("decor") < '0.0.0.9001') {
Expand All @@ -53,7 +54,7 @@ decorations <- cpp_decorations() %>%
# more concisely
# rap( ~ decor:::parse_cpp_function(context))
mutate(functions = map(context, decor:::parse_cpp_function)) %>%
{ bind_cols(., bind_rows(pull(., functions))) } %>%

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this necessary? If so, please add vctrs to the README where the codegen script dependencies are discussed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nevermind, I see we already Suggest vctrs.

{ vec_cbind(., vec_rbind(!!!pull(., functions))) } %>%
select(-functions)

message(glue("*** > {n} functions decorated with [[arrow::export]]", n = nrow(decorations)))
Expand Down
2 changes: 1 addition & 1 deletion r/tests/testthat/helper-arrow.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

# Wrap testthat::test_that with a check for the C++ library
options(..skip.tests = !arrow::arrow_available())
options(..skip.tests = !arrow:::arrow_available())

test_that <- function(what, code) {
testthat::test_that(what, {
Expand Down