Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions r/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Suggests:
vctrs
Collate:
'enums.R'
'R6.R'
'arrow-package.R'
'type.R'
'ArrayData.R'
'ChunkedArray.R'
'Column.R'
Expand All @@ -60,7 +61,6 @@ Collate:
'Struct.R'
'Table.R'
'array.R'
'arrow-package.R'
'arrowExports.R'
'buffer.R'
'io.R'
Expand Down
4 changes: 4 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export(TimeUnit)
export(Type)
export(array)
export(arrow_available)
export(bool)
export(boolean)
export(buffer)
export(cast_options)
Expand All @@ -140,9 +141,11 @@ export(dictionary)
export(ends_with)
export(everything)
export(field)
export(float)
export(float16)
export(float32)
export(float64)
export(halffloat)
export(install_arrow)
export(int16)
export(int32)
Expand Down Expand Up @@ -175,6 +178,7 @@ export(read_tsv_arrow)
export(record_batch)
export(schema)
export(starts_with)
export(string)
export(struct)
export(table)
export(time32)
Expand Down
2 changes: 1 addition & 1 deletion r/R/ArrayData.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include type.R

#' @title class arrow::ArrayData
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/ChunkedArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::ChunkedArray
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/Column.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include type.R

#' @title class arrow::Column
#'
Expand Down
11 changes: 9 additions & 2 deletions r/R/Field.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::Field
#'
Expand Down Expand Up @@ -72,7 +72,14 @@
#' @export
field <- function(name, type, metadata) {
assert_that(inherits(name, "character"), length(name) == 1L)
assert_that(inherits(type, "arrow::DataType"))
if (!inherits(type, "arrow::DataType")) {
if (identical(type, double())) {
# Magic so that we don't have to mask this base function
type <- float64()
} else {
stop(name, " must be arrow::DataType, not ", class(type), call. = FALSE)
}
}
assert_that(missing(metadata), msg = "metadata= is currently ignored")
shared_ptr(`arrow::Field`, Field__initialize(name, type, TRUE))
}
Expand Down
4 changes: 2 additions & 2 deletions r/R/List.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include type.R

`arrow::ListType` <- R6Class("arrow::ListType",
inherit = `arrow::NestedType`,
Expand All @@ -25,6 +25,6 @@
)
)

#' @rdname DataType
#' @rdname data-type
#' @export
list_of <- function(type) shared_ptr(`arrow::ListType`, list__(type))
2 changes: 1 addition & 1 deletion r/R/RecordBatch.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::RecordBatch
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/RecordBatchReader.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::RecordBatchReader
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/RecordBatchWriter.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::ipc::RecordBatchWriter
#'
Expand Down
14 changes: 10 additions & 4 deletions r/R/Schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::Schema
#'
Expand Down Expand Up @@ -60,13 +60,19 @@
lhs$Equals(rhs)
}

#' Schema factory
#' Create a schema
#'
#' @param ... named list of data types
#' 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.
#'
#' @return a [schema][arrow__Schema]
#' @param ... named list of [data types][data-type]
#'
#' @return A [schema][arrow__Schema] object.
#'
#' @export
# TODO (npr): add examples once ARROW-5505 merges
schema <- function(...){
shared_ptr(`arrow::Schema`, schema_(.fields(list2(...))))
}
Expand Down
4 changes: 2 additions & 2 deletions r/R/Struct.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include type.R

`arrow::StructType` <- R6Class("arrow::StructType",
inherit = `arrow::NestedType`,
Expand All @@ -25,7 +25,7 @@
)
)

#' @rdname DataType
#' @rdname data-type
#' @export
struct <- function(...){
xp <- struct_(.fields(list(...)))
Expand Down
2 changes: 1 addition & 1 deletion r/R/Table.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R
#'
#' @title class arrow::Table
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/array.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::Array
#'
Expand Down
28 changes: 28 additions & 0 deletions r/R/arrow-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,31 @@ arrow_available <- function() {
option_use_threads <- function() {
!is_false(getOption("arrow.use_threads"))
}

#' @include enums.R
`arrow::Object` <- R6Class("arrow::Object",
public = list(
initialize = function(xp) self$set_pointer(xp),

pointer = function() self$`.:xp:.`,
`.:xp:.` = NULL,
set_pointer = function(xp){
self$`.:xp:.` <- xp
},
print = function(...){
cat(class(self)[[1]], "\n")
if (!is.null(self$ToString)){
cat(self$ToString(), "\n")
}
invisible(self)
}
)
)

shared_ptr <- function(class, xp) {
if (!shared_ptr_is_null(xp)) class$new(xp)
}

unique_ptr <- function(class, xp) {
if (!unique_ptr_is_null(xp)) class$new(xp)
}
2 changes: 1 addition & 1 deletion r/R/buffer.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R
#' @include enums.R

#' @title class arrow::Buffer
Expand Down
2 changes: 1 addition & 1 deletion r/R/compression.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# under the License.

#' @include enums.R
#' @include R6.R
#' @include arrow-package.R
#' @include io.R

`arrow::util::Codec` <- R6Class("arrow::util::Codec", inherit = `arrow::Object`)
Expand Down
2 changes: 1 addition & 1 deletion r/R/csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ read_tsv_arrow <- function(file,
eval.parent(mc)
}

#' @include R6.R
#' @include arrow-package.R

`arrow::csv::TableReader` <- R6Class("arrow::csv::TableReader", inherit = `arrow::Object`,
public = list(
Expand Down
8 changes: 4 additions & 4 deletions r/R/dictionary.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include type.R

#' @title class arrow::DictionaryType
#'
Expand All @@ -40,14 +40,14 @@
)
)

#' dictionary type factory
#' Create a dictionary type
#'
#' @param index_type index type, e.g. [int32()]
#' @param value_type value type, probably [utf8()]
#' @param ordered Is this an ordered dictionary ?
#'
#' @return a [arrow::DictionaryType][arrow__DictionaryType]
#'
#' @return An [arrow::DictionaryType][arrow__DictionaryType]
#' @seealso [Other Arrow data types][data-type]
#' @export
dictionary <- function(index_type, value_type, ordered = FALSE) {
assert_that(
Expand Down
16 changes: 9 additions & 7 deletions r/R/enums.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ enum <- function(class, ..., .list = list(...)){
)
}

#' @rdname DataType
#' Arrow enums
#' @name enums
#' @export
#' @keywords internal
TimeUnit <- enum("arrow::TimeUnit::type",
SECOND = 0L, MILLI = 1L, MICRO = 2L, NANO = 3L
)

#' @rdname DataType
#' @rdname enums
#' @export
DateUnit <- enum("arrow::DateUnit", DAY = 0L, MILLI = 1L)

#' @rdname DataType
#' @rdname enums
#' @export
Type <- enum("arrow::Type::type",
"NA" = 0L, BOOL = 1L, UINT8 = 2L, INT8 = 3L, UINT16 = 4L, INT16 = 5L,
Expand All @@ -48,7 +50,7 @@ Type <- enum("arrow::Type::type",
UNION = 25L, DICTIONARY = 26L, MAP = 27L
)

#' @rdname DataType
#' @rdname enums
#' @export
StatusCode <- enum("arrow::StatusCode",
OK = 0L, OutOfMemory = 1L, KeyError = 2L, TypeError = 3L,
Expand All @@ -59,19 +61,19 @@ StatusCode <- enum("arrow::StatusCode",
PlasmaStoreFull = 22L, PlasmaObjectAlreadySealed = 23L
)

#' @rdname DataType
#' @rdname enums
#' @export
FileMode <- enum("arrow::io::FileMode",
READ = 0L, WRITE = 1L, READWRITE = 2L
)

#' @rdname DataType
#' @rdname enums
#' @export
MessageType <- enum("arrow::ipc::Message::Type",
NONE = 0L, SCHEMA = 1L, DICTIONARY_BATCH = 2L, RECORD_BATCH = 3L, TENSOR = 4L
)

#' @rdname DataType
#' @rdname enums
#' @export
CompressionType <- enum("arrow::Compression::type",
UNCOMPRESSED = 0L, SNAPPY = 1L, GZIP = 2L, BROTLI = 3L, ZSTD = 4L, LZ4 = 5L, LZO = 6L, BZ2 = 7L
Expand Down
2 changes: 1 addition & 1 deletion r/R/feather.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

`arrow::ipc::feather::TableWriter` <- R6Class("arrow::ipc::feather::TableWriter", inherit = `arrow::Object`,
public = list(
Expand Down
2 changes: 1 addition & 1 deletion r/R/io.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R
#' @include enums.R
#' @include buffer.R

Expand Down
4 changes: 2 additions & 2 deletions r/R/json.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @include R6.R
#' @include arrow-package.R
#'
#' @title class arrow::json::TableReader
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/memory_pool.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R
#'
#' @title class arrow::MemoryPool
#'
Expand Down
2 changes: 1 addition & 1 deletion r/R/message.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.

#' @include R6.R
#' @include arrow-package.R

#' @title class arrow::ipc::Message
#'
Expand Down
Loading