Skip to content

Commit

Permalink
rename arguments to x and sink
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Sep 27, 2019
1 parent cb63c97 commit 354d263
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 28 deletions.
24 changes: 12 additions & 12 deletions r/R/feather.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

#' Write data in the Feather format
#'
#' @param data `data.frame` or RecordBatch
#' @param stream A file path or an OutputStream
#' @param x `data.frame` or RecordBatch
#' @param sink A file path or an OutputStream
#'
#' @export
#' @examples
Expand All @@ -30,20 +30,20 @@
#' })
#' }
#' @include arrow-package.R
write_feather <- function(data, stream) {
if (is.data.frame(data)) {
data <- record_batch(data)
write_feather <- function(x, sink) {
if (is.data.frame(x)) {
x <- record_batch(x)
}
assert_is(data, "RecordBatch")
assert_is(x, "RecordBatch")

if (is.character(stream)) {
stream <- FileOutputStream$create(stream)
on.exit(stream$close())
if (is.character(sink)) {
sink <- FileOutputStream$create(sink)
on.exit(sink$close())
}
assert_is(stream, "OutputStream")
assert_is(sink, "OutputStream")

writer <- FeatherTableWriter$create(stream)
ipc___TableWriter__RecordBatch__WriteFeather(writer, data)
writer <- FeatherTableWriter$create(sink)
ipc___TableWriter__RecordBatch__WriteFeather(writer, x)
}

#' @title FeatherTableWriter class
Expand Down
12 changes: 6 additions & 6 deletions r/R/parquet.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ read_parquet <- function(file,
#' [Parquet](https://parquet.apache.org/) is a columnar storage file format.
#' This function enables you to write Parquet files from R.
#'
#' @param table An [arrow::Table][Table], or an object convertible to it.
#' @param x An [arrow::Table][Table], or an object convertible to it.
#' @param sink an [arrow::io::OutputStream][OutputStream] or a string which is interpreted as a file path
#' @param chunk_size chunk size in number of rows. If NULL, the total number of rows is used.
#'
Expand Down Expand Up @@ -97,7 +97,7 @@ read_parquet <- function(file,
#'
#' }
#' @export
write_parquet <- function(table,
write_parquet <- function(x,
sink,
chunk_size = NULL,

Expand All @@ -110,7 +110,7 @@ write_parquet <- function(table,
data_page_size = NULL,

properties = ParquetWriterProperties$create(
table,
x,
version = version,
compression = compression,
compression_level = compression_level,
Expand All @@ -130,7 +130,7 @@ write_parquet <- function(table,
allow_truncated_timestamps = allow_truncated_timestamps
)
) {
table <- to_arrow(table)
x <- to_arrow(x)

if (is.character(sink)) {
sink <- FileOutputStream$create(sink)
Expand All @@ -139,9 +139,9 @@ write_parquet <- function(table,
abort("sink must be a file path or an OutputStream")
}

schema <- table$schema
schema <- x$schema
writer <- ParquetFileWriter$create(schema, sink, properties = properties, arrow_properties = arrow_properties)
writer$WriteTable(table, chunk_size = chunk_size %||% table$num_rows)
writer$WriteTable(x, chunk_size = chunk_size %||% x$num_rows)
writer$Close()
}

Expand Down
6 changes: 3 additions & 3 deletions r/man/write_feather.Rd

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

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

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

0 comments on commit 354d263

Please sign in to comment.