Skip to content

Commit

Permalink
+ feather prefix -> feather_table_writer and feather_table_reader
Browse files Browse the repository at this point in the history
  • Loading branch information
romainfrancois committed Nov 12, 2018
1 parent e0db6cc commit d5e118e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
16 changes: 8 additions & 8 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ S3method(buffer,numeric)
S3method(buffer,raw)
S3method(buffer_reader,"arrow::Buffer")
S3method(buffer_reader,default)
S3method(feather_table_reader,"arrow::io::RandomAccessFile")
S3method(feather_table_reader,"arrow::ipc::feather::TableReader")
S3method(feather_table_reader,character)
S3method(feather_table_reader,default)
S3method(feather_table_reader,fs_path)
S3method(feather_table_writer,"arrow::io::OutputStream")
S3method(fixed_size_buffer_writer,"arrow::Buffer")
S3method(fixed_size_buffer_writer,default)
S3method(length,"arrow::Array")
Expand Down Expand Up @@ -48,12 +54,6 @@ S3method(record_batch_file_reader,character)
S3method(record_batch_file_reader,fs_path)
S3method(record_batch_stream_reader,"arrow::io::InputStream")
S3method(record_batch_stream_reader,raw)
S3method(table_reader,"arrow::io::RandomAccessFile")
S3method(table_reader,"arrow::ipc::feather::TableReader")
S3method(table_reader,character)
S3method(table_reader,default)
S3method(table_reader,fs_path)
S3method(table_writer,"arrow::io::OutputStream")
S3method(write_arrow,"arrow::RecordBatch")
S3method(write_arrow,"arrow::Table")
S3method(write_arrow,data.frame)
Expand Down Expand Up @@ -91,6 +91,8 @@ export(date32)
export(date64)
export(decimal)
export(dictionary)
export(feather_table_reader)
export(feather_table_writer)
export(file_open)
export(file_output_stream)
export(fixed_size_buffer_writer)
Expand Down Expand Up @@ -123,8 +125,6 @@ export(schema)
export(str.integer64)
export(struct)
export(table)
export(table_reader)
export(table_writer)
export(time32)
export(time64)
export(timestamp)
Expand Down
30 changes: 15 additions & 15 deletions r/R/feather.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
#' @param stream an OutputStream
#'
#' @export
table_writer <- function(stream) {
UseMethod("table_writer")
feather_table_writer <- function(stream) {
UseMethod("feather_table_writer")
}

#' @export
`table_writer.arrow::io::OutputStream` <- function(stream){
`feather_table_writer.arrow::io::OutputStream` <- function(stream){
unique_ptr(`arrow::ipc::feather::TableWriter`, ipc___feather___TableWriter__Open(stream))
}

Expand Down Expand Up @@ -107,7 +107,7 @@ write_feather_RecordBatch <- function(data, stream) {
#' @export
#' @method write_feather_RecordBatch arrow::io::OutputStream
`write_feather_RecordBatch.arrow::io::OutputStream` <- function(data, stream) {
ipc___TableWriter__RecordBatch__WriteFeather(table_writer(stream), data)
ipc___TableWriter__RecordBatch__WriteFeather(feather_table_writer(stream), data)
}

#' A arrow::ipc::feather::TableReader to read from a file
Expand All @@ -117,44 +117,44 @@ write_feather_RecordBatch <- function(data, stream) {
#' @param ... extra parameters
#'
#' @export
table_reader <- function(file, ...){
UseMethod("table_reader")
feather_table_reader <- function(file, ...){
UseMethod("feather_table_reader")
}

#' @export
table_reader.default <- function(file, ...) {
feather_table_reader.default <- function(file, ...) {
stop("unsupported")
}

#' @export
table_reader.character <- function(file, mmap = TRUE, ...) {
table_reader(fs::path_abs(file), mmap = mmap, ...)
feather_table_reader.character <- function(file, mmap = TRUE, ...) {
feather_table_reader(fs::path_abs(file), mmap = mmap, ...)
}

#' @export
table_reader.fs_path <- function(file, mmap = TRUE, ...) {
feather_table_reader.fs_path <- function(file, mmap = TRUE, ...) {
stream <- if(isTRUE(mmap)) mmap_open(file, ...) else file_open(file, ...)
table_reader(stream)
feather_table_reader(stream)
}

#' @export
`table_reader.arrow::io::RandomAccessFile` <- function(file, ...){
`feather_table_reader.arrow::io::RandomAccessFile` <- function(file, ...){
unique_ptr(`arrow::ipc::feather::TableReader`, ipc___feather___TableReader__Open(file))
}

#' @export
`table_reader.arrow::ipc::feather::TableReader` <- function(file){
`feather_table_reader.arrow::ipc::feather::TableReader` <- function(file){
file
}

#' Read a feather file
#'
#' @param file a arrow::ipc::feather::TableReader or whatever the [table_reader()] function can handle
#' @param file a arrow::ipc::feather::TableReader or whatever the [feather_table_reader()] function can handle
#' @param ... additional parameters
#'
#' @return an arrow::Table
#'
#' @export
read_feather <- function(file, ...){
table_reader(file, ...)$Read()
feather_table_reader(file, ...)$Read()
}
6 changes: 3 additions & 3 deletions r/man/table_reader.Rd → r/man/feather_table_reader.Rd

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

6 changes: 3 additions & 3 deletions r/man/table_writer.Rd → r/man/feather_table_writer.Rd

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

2 changes: 1 addition & 1 deletion r/man/read_feather.Rd

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

0 comments on commit d5e118e

Please sign in to comment.