Skip to content

Commit

Permalink
Clean up Rd file names, experiment with documenting constructors, and…
Browse files Browse the repository at this point in the history
… start updating pkgdown
  • Loading branch information
nealrichardson committed Sep 10, 2019
1 parent 2d1b738 commit 71cac57
Show file tree
Hide file tree
Showing 61 changed files with 242 additions and 313 deletions.
20 changes: 7 additions & 13 deletions r/R/Field.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,16 @@
# under the License.

#' @include arrow-package.R

#' @title class arrow::Field
#'
#' @usage NULL
#' @format NULL
#' @docType class
#'
#' @section Methods:
#'
#' TODO
#' - `f$ToString()`: convert to a string
#' - `f$Equals(other)`: test for equality. More naturally called as `f == other`
#'
#' @rdname arrow__Field
#' @name arrow__Field
#' @rdname Field
#' @name Field
Field <- R6Class("Field", inherit = Object,
public = list(
ToString = function() {
Expand Down Expand Up @@ -57,18 +54,15 @@ Field <- R6Class("Field", inherit = Object,
lhs$Equals(rhs)
}

#' Factory for a Field
#'
#' @param name field name
#' @param type logical type, instance of DataType
#' @param type logical type, instance of [DataType]
#' @param metadata currently ignored
#'
#' @examples
#' \donttest{
#' try({
#' field("x", int32())
#' })
#' field("x", int32())
#' }
#' @rdname Field
#' @export
field <- function(name, type, metadata) {
assert_that(inherits(name, "character"), length(name) == 1L)
Expand Down
8 changes: 4 additions & 4 deletions r/R/RecordBatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#'
#' TODO
#'
#' @rdname arrow__RecordBatch
#' @name arrow__RecordBatch
#' @rdname RecordBatch
#' @name RecordBatch
RecordBatch <- R6Class("RecordBatch", inherit = Object,
public = list(
column = function(i) shared_ptr(Array, RecordBatch__column(self, i)),
Expand Down Expand Up @@ -99,11 +99,11 @@ as.data.frame.RecordBatch <- function(x, row.names = NULL, optional = FALSE, use
RecordBatch__to_dataframe(x, use_threads = option_use_threads())
}

#' Create an [arrow::RecordBatch][arrow__RecordBatch] from a data frame
#' Create an [arrow::RecordBatch][RecordBatch] from a data frame
#'
#' @param ... A variable number of Array
#' @param schema a arrow::Schema
#'
#' @return a [arrow::RecordBatch][arrow__RecordBatch]
#' @return a [arrow::RecordBatch][RecordBatch]
#' @export
record_batch <- RecordBatch$create
12 changes: 6 additions & 6 deletions r/R/RecordBatchReader.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#'
#' TODO
#'
#' @rdname arrow__RecordBatchReader
#' @name arrow__RecordBatchReader
#' @rdname RecordBatchReader
#' @name RecordBatchReader
RecordBatchReader <- R6Class("RecordBatchReader", inherit = Object,
public = list(
read_next_batch = function() {
Expand All @@ -50,8 +50,8 @@ RecordBatchReader <- R6Class("RecordBatchReader", inherit = Object,
#'
#' TODO
#'
#' @rdname arrow__ipc__RecordBatchStreamReader
#' @name arrow__ipc__RecordBatchStreamReader
#' @rdname RecordBatchStreamReader
#' @name RecordBatchStreamReader
RecordBatchStreamReader <- R6Class("RecordBatchStreamReader", inherit = RecordBatchReader,
public = list(
batches = function() map(ipc___RecordBatchStreamReader__batches(self), shared_ptr, class = RecordBatch)
Expand All @@ -76,8 +76,8 @@ RecordBatchStreamReader$create <- function(stream){
#'
#' TODO
#'
#' @rdname arrow__ipc__RecordBatchFileReader
#' @name arrow__ipc__RecordBatchFileReader
#' @rdname RecordBatchFileReader
#' @name RecordBatchFileReader
RecordBatchFileReader <- R6Class("RecordBatchFileReader", inherit = Object,
# Why doesn't this inherit from RecordBatchReader?
public = list(
Expand Down
20 changes: 10 additions & 10 deletions r/R/RecordBatchWriter.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#'
#' @section Derived classes:
#'
#' - [arrow::RecordBatchStreamWriter][arrow__ipc__RecordBatchStreamWriter] implements the streaming binary format
#' - [arrow::RecordBatchFileWriter][arrow__ipc__RecordBatchFileWriter] implements the binary file format
#' - [arrow::RecordBatchStreamWriter][RecordBatchStreamWriter] implements the streaming binary format
#' - [arrow::RecordBatchFileWriter][RecordBatchFileWriter] implements the binary file format
#'
#' @rdname arrow__ipc__RecordBatchWriter
#' @name arrow__ipc__RecordBatchWriter
#' @rdname RecordBatchWriter
#' @name RecordBatchWriter
RecordBatchWriter <- R6Class("RecordBatchWriter", inherit = Object,
public = list(
write_batch = function(batch) ipc___RecordBatchWriter__WriteRecordBatch(self, batch),
Expand Down Expand Up @@ -80,14 +80,14 @@ RecordBatchWriter <- R6Class("RecordBatchWriter", inherit = Object,
#' The [RecordBatchStreamWriter()] function creates a record batch stream writer.
#'
#' @section Methods:
#' inherited from [arrow::RecordBatchWriter][arrow__ipc__RecordBatchWriter]
#' inherited from [arrow::RecordBatchWriter][RecordBatchWriter]
#'
#' - `$write_batch(batch)`: Write record batch to stream
#' - `$write_table(table)`: write Table to stream
#' - `$close()`: close stream
#'
#' @rdname arrow__ipc__RecordBatchStreamWriter
#' @name arrow__ipc__RecordBatchStreamWriter
#' @rdname RecordBatchStreamWriter
#' @name RecordBatchStreamWriter
RecordBatchStreamWriter <- R6Class("RecordBatchStreamWriter", inherit = RecordBatchWriter)

RecordBatchStreamWriter$create <- function(sink, schema) {
Expand Down Expand Up @@ -123,14 +123,14 @@ RecordBatchStreamWriter$create <- function(sink, schema) {
#' The [RecordBatchFileWriter()] function creates a record batch stream writer.
#'
#' @section Methods:
#' inherited from [arrow::RecordBatchWriter][arrow__ipc__RecordBatchWriter]
#' inherited from [arrow::RecordBatchWriter][RecordBatchWriter]
#'
#' - `$write_batch(batch)`: Write record batch to stream
#' - `$write_table(table)`: write Table to stream
#' - `$close()`: close stream
#'
#' @rdname arrow__ipc__RecordBatchFileWriter
#' @name arrow__ipc__RecordBatchFileWriter
#' @rdname RecordBatchFileWriter
#' @name RecordBatchFileWriter
RecordBatchFileWriter <- R6Class("RecordBatchFileWriter", inherit = RecordBatchStreamWriter)

RecordBatchFileWriter$create <- function(sink, schema) {
Expand Down
21 changes: 8 additions & 13 deletions r/R/Schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
# under the License.

#' @include arrow-package.R

#' @title class arrow::Schema
#'
#' @description Create a `Schema` when you
#' want to convert an R `data.frame` to Arrow but don't want to rely on the
#' default mapping of R types to Arrow types, such as when you want to choose a
#' specific numeric precision.
#'
#' @usage NULL
#' @format NULL
#' @docType class
Expand All @@ -39,8 +43,8 @@
#' - `$num_fields()`: returns the number of fields
#' - `$field(i)`: returns the field at index `i` (0-based)
#'
#' @rdname arrow__Schema
#' @name arrow__Schema
#' @rdname Schema
#' @name Schema
Schema <- R6Class("Schema",
inherit = Object,
public = list(
Expand All @@ -60,18 +64,9 @@ Schema$create <- function(...) shared_ptr(Schema, schema_(.fields(list2(...))))
#' @export
`==.Schema` <- function(lhs, rhs) lhs$Equals(rhs)

#' Create a schema
#'
#' This function lets you define a schema for a table. This is useful when you
#' want to convert an R `data.frame` to Arrow but don't want to rely on the
#' default mapping of R types to Arrow types, such as when you want to choose a
#' specific numeric precision.
#'
#' @param ... named list of [data types][data-type]
#'
#' @return A [schema][arrow__Schema] object.
#'
#' @export
#' @rdname Schema
# TODO (npr): add examples once ARROW-5505 merges
schema <- Schema$create

Expand Down
4 changes: 2 additions & 2 deletions r/R/Table.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
#'
#' TODO
#'
#' @rdname arrow__Table
#' @name arrow__Table
#' @rdname Table
#' @name Table
#' @export
Table <- R6Class("Table", inherit = Object,
public = list(
Expand Down
2 changes: 1 addition & 1 deletion r/R/csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#' @param convert_options see [csv_convert_options()]
#' @param read_options see [csv_read_options()]
#' @param as_tibble Should the function return a `data.frame` or an
#' [arrow::Table][arrow__Table]?
#' [arrow::Table][Table]?
#'
#' @return A `data.frame`, or an Table if `as_tibble = FALSE`.
#' @export
Expand Down
6 changes: 3 additions & 3 deletions r/R/dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#'
#' TODO
#'
#' @rdname arrow__DictionaryType
#' @name arrow__DictionaryType
#' @rdname DictionaryType
#' @name DictionaryType
DictionaryType <- R6Class("DictionaryType",
inherit = FixedWidthType,

Expand All @@ -46,7 +46,7 @@ DictionaryType <- R6Class("DictionaryType",
#' @param value_type value type, probably [utf8()]
#' @param ordered Is this an ordered dictionary ?
#'
#' @return An [DictionaryType][arrow__DictionaryType]
#' @return A [DictionaryType]
#' @seealso [Other Arrow data types][data-type]
#' @export
dictionary <- function(index_type, value_type, ordered = FALSE) {
Expand Down
2 changes: 1 addition & 1 deletion r/R/feather.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ FeatherTableWriter$create <- function(stream) {
#' @inheritParams read_delim_arrow
#' @param ... additional parameters
#'
#' @return A `data.frame` if `as_tibble` is `TRUE` (the default), or a [arrow::Table][arrow__Table] otherwise
#' @return A `data.frame` if `as_tibble` is `TRUE` (the default), or a [arrow::Table][Table] otherwise
#'
#' @export
#' @examples
Expand Down
46 changes: 23 additions & 23 deletions r/R/io.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Writable <- R6Class("Writable", inherit = Object,
#' - Buffer `Read`(`int` nbytes): Read `nbytes` bytes
#' - `void` `close`(): close the stream
#'
#' @rdname arrow__io__OutputStream
#' @name arrow__io__OutputStream
#' @rdname OutputStream
#' @name OutputStream
OutputStream <- R6Class("OutputStream", inherit = Writable,
public = list(
close = function() io___OutputStream__Close(self),
Expand All @@ -57,8 +57,8 @@ OutputStream <- R6Class("OutputStream", inherit = Writable,
#'
#' TODO
#'
#' @rdname arrow__io__FileOutputStream
#' @name arrow__io__FileOutputStream
#' @rdname FileOutputStream
#' @name FileOutputStream
FileOutputStream <- R6Class("FileOutputStream", inherit = OutputStream)

FileOutputStream$create <- function(path) {
Expand All @@ -77,8 +77,8 @@ FileOutputStream$create <- function(path) {
#'
#' TODO
#'
#' @rdname arrow__io__MockOutputStream
#' @name arrow__io__MockOutputStream
#' @rdname MockOutputStream
#' @name MockOutputStream
MockOutputStream <- R6Class("MockOutputStream", inherit = OutputStream,
public = list(
GetExtentBytesWritten = function() io___MockOutputStream__GetExtentBytesWritten(self)
Expand All @@ -97,8 +97,8 @@ MockOutputStream$create <- function() {
#'
#' TODO
#'
#' @rdname arrow__io__BufferOutputStream
#' @name arrow__io__BufferOutputStream
#' @rdname BufferOutputStream
#' @name BufferOutputStream
BufferOutputStream <- R6Class("BufferOutputStream", inherit = OutputStream,
public = list(
capacity = function() io___BufferOutputStream__capacity(self),
Expand All @@ -124,8 +124,8 @@ BufferOutputStream$create <- function(initial_capacity = 0L) {
#'
#' TODO
#'
#' @rdname arrow__io__FixedSizeBufferWriter
#' @name arrow__io__FixedSizeBufferWriter
#' @rdname FixedSizeBufferWriter
#' @name FixedSizeBufferWriter
FixedSizeBufferWriter <- R6Class("FixedSizeBufferWriter", inherit = OutputStream)

FixedSizeBufferWriter$create <- function(x) {
Expand All @@ -147,8 +147,8 @@ FixedSizeBufferWriter$create <- function(x) {
#'
#' TODO
#'
#' @rdname arrow__io__Readable
#' @name arrow__io__Readable
#' @rdname Readable
#' @name Readable
Readable <- R6Class("Readable", inherit = Object,
public = list(
Read = function(nbytes) shared_ptr(Buffer, io___Readable__Read(self, nbytes))
Expand All @@ -166,8 +166,8 @@ Readable <- R6Class("Readable", inherit = Object,
#'
#' TODO
#'
#' @rdname arrow__io__InputStream
#' @name arrow__io__InputStream
#' @rdname InputStream
#' @name InputStream
InputStream <- R6Class("InputStream", inherit = Readable,
public = list(
close = function() io___InputStream__Close(self)
Expand All @@ -185,8 +185,8 @@ InputStream <- R6Class("InputStream", inherit = Readable,
#'
#' TODO
#'
#' @rdname arrow__io__RandomAccessFile
#' @name arrow__io__RandomAccessFile
#' @rdname RandomAccessFile
#' @name RandomAccessFile
RandomAccessFile <- R6Class("RandomAccessFile", inherit = InputStream,
public = list(
GetSize = function() io___RandomAccessFile__GetSize(self),
Expand Down Expand Up @@ -225,8 +225,8 @@ RandomAccessFile <- R6Class("RandomAccessFile", inherit = InputStream,
#' @seealso [mmap_open()], [mmap_create()]
#'
#'
#' @rdname arrow__io__MemoryMappedFile
#' @name arrow__io__MemoryMappedFile
#' @rdname MemoryMappedFile
#' @name MemoryMappedFile
MemoryMappedFile <- R6Class("MemoryMappedFile", inherit = RandomAccessFile,
public = list(
Resize = function(size) io___MemoryMappedFile__Resize(self, size)
Expand All @@ -244,8 +244,8 @@ MemoryMappedFile <- R6Class("MemoryMappedFile", inherit = RandomAccessFile,
#'
#' TODO
#'
#' @rdname arrow__io__ReadableFile
#' @name arrow__io__ReadableFile
#' @rdname ReadableFile
#' @name ReadableFile
ReadableFile <- R6Class("ReadableFile", inherit = RandomAccessFile)

ReadableFile$create <- function(path) {
Expand All @@ -262,8 +262,8 @@ ReadableFile$create <- function(path) {
#'
#' TODO
#'
#' @rdname arrow__io__BufferReader
#' @name arrow__io__BufferReader
#' @rdname BufferReader
#' @name BufferReader
BufferReader <- R6Class("BufferReader", inherit = RandomAccessFile)

BufferReader$create <- function(x) {
Expand All @@ -276,7 +276,7 @@ BufferReader$create <- function(x) {
#' @param path file path
#' @param size size in bytes
#'
#' @return a [arrow::io::MemoryMappedFile][arrow__io__MemoryMappedFile]
#' @return a [arrow::io::MemoryMappedFile][MemoryMappedFile]
#'
#' @export
mmap_create <- function(path, size) {
Expand Down
Loading

0 comments on commit 71cac57

Please sign in to comment.