Skip to content

Commit

Permalink
M%ake compression_from_name() vectorized
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Sep 27, 2019
1 parent 86d9ff4 commit 004cf90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions r/R/compression.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,15 @@ Codec <- R6Class("Codec", inherit = Object,
Codec$create <- function(type = "gzip", compression_level = NA) {
if (is.character(type)) {
type <- unique_ptr(Codec, util___Codec__Create(
CompressionType[[match.arg(toupper(type), names(CompressionType))]],
compression_level
compression_from_name(type), compression_level
))
}
assert_is(type, "Codec")
type
}

compression_from_name <- function(name) {
CompressionType[[match.arg(toupper(name), names(CompressionType))]]
map_int(name, ~CompressionType[[match.arg(toupper(.x), names(CompressionType))]])
}

#' @title Compressed stream classes
Expand Down
4 changes: 2 additions & 2 deletions r/R/parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ ParquetWriterPropertiesBuilder <- R6Class("ParquetWriterPropertiesBuilder", inhe
} else {
column_names <- names(table)
if (is.character(compression) && is.null(names(compression)) && length(compression) == length(column_names)) {
parquet___ArrowWriterProperties___Builder__set_compressions(self, column_names, map_int(compression, compression_from_name))
parquet___ArrowWriterProperties___Builder__set_compressions(self, column_names, compression_from_name(compression))
} else if (is.character(compression) && all(names(compression) %in% column_names)) {
parquet___ArrowWriterProperties___Builder__set_compressions(self, names(compression), map_int(compression, compression_from_name))
parquet___ArrowWriterProperties___Builder__set_compressions(self, names(compression), compression_from_name(compression))
} else {
abort("unsupported compression= specification")
}
Expand Down

0 comments on commit 004cf90

Please sign in to comment.