From 717cfc71e96aed147c8fef53b6be55b25f4e717e Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Thu, 24 Sep 2020 13:56:10 +0200 Subject: [PATCH 01/43] call_function() internally unbox to the right R6 class --- r/R/array.R | 12 +++--------- r/R/chunked-array.R | 6 +++--- r/R/compute.R | 8 ++++---- r/R/expression.R | 5 ++--- r/R/record-batch.R | 4 ++-- r/R/table.R | 4 ++-- r/src/arrow_cpp11.h | 30 ++++++++++++++++++++++++++++++ r/src/compute.cpp | 10 +++++----- r/src/symbols.cpp | 2 ++ 9 files changed, 53 insertions(+), 28 deletions(-) diff --git a/r/R/array.R b/r/R/array.R index 8c9a29b6680..4ec89780611 100644 --- a/r/R/array.R +++ b/r/R/array.R @@ -131,20 +131,14 @@ Array <- R6Class("Array", if (is.integer(i)) { i <- Array$create(i) } - # ARROW-9001: autoboxing in call_function - result <- call_function("take", self, i) - if (inherits(i, "ChunkedArray")) { - return(shared_ptr(ChunkedArray, result)) - } else { - Array$create(result) - } + call_function("take", self, i) }, Filter = function(i, keep_na = TRUE) { if (is.logical(i)) { i <- Array$create(i) } assert_is(i, "Array") - Array$create(call_function("filter", self, i, options = list(keep_na = keep_na))) + call_function("filter", self, i, options = list(keep_na = keep_na)) }, RangeEquals = function(other, start_idx, end_idx, other_start_idx = 0L) { assert_is(other, "Array") @@ -270,7 +264,7 @@ FixedSizeListArray <- R6Class("FixedSizeListArray", inherit = Array, length.Array <- function(x) x$length() #' @export -is.na.Array <- function(x) shared_ptr(Array, call_function("is_null", x)) +is.na.Array <- function(x) call_function("is_null", x) #' @export as.vector.Array <- function(x, mode) x$as_vector() diff --git a/r/R/chunked-array.R b/r/R/chunked-array.R index d2475eb9a76..d3b6c94aeb6 100644 --- a/r/R/chunked-array.R +++ b/r/R/chunked-array.R @@ -75,13 +75,13 @@ ChunkedArray <- R6Class("ChunkedArray", inherit = ArrowObject, if (is.integer(i)) { i <- Array$create(i) } - shared_ptr(ChunkedArray, call_function("take", self, i)) + call_function("take", self, i) }, Filter = function(i, keep_na = TRUE) { if (is.logical(i)) { i <- Array$create(i) } - shared_ptr(ChunkedArray, call_function("filter", self, i, options = list(keep_na = keep_na))) + call_function("filter", self, i, options = list(keep_na = keep_na)) }, cast = function(target_type, safe = TRUE, options = cast_options(safe)) { assert_is(options, "CastOptions") @@ -128,7 +128,7 @@ length.ChunkedArray <- function(x) x$length() as.vector.ChunkedArray <- function(x, mode) x$as_vector() #' @export -is.na.ChunkedArray <- function(x) shared_ptr(ChunkedArray, call_function("is_null", x)) +is.na.ChunkedArray <- function(x) call_function("is_null", x) #' @export `[.ChunkedArray` <- filter_rows diff --git a/r/R/compute.R b/r/R/compute.R index 691d59e3666..649bffcba2a 100644 --- a/r/R/compute.R +++ b/r/R/compute.R @@ -76,7 +76,7 @@ scalar_aggregate <- function(FUN, ..., na.rm = FALSE) { return(Scalar$create(NA_real_)) } - Scalar$create(call_function(FUN, a, options = list(na.rm = na.rm))) + call_function(FUN, a, options = list(na.rm = na.rm)) } collect_arrays_from_dots <- function(dots) { @@ -100,7 +100,7 @@ collect_arrays_from_dots <- function(dots) { #' @export unique.Array <- function(x, incomparables = FALSE, ...) { - Array$create(call_function("unique", x)) + call_function("unique", x) } #' @export @@ -127,7 +127,7 @@ match_arrow.Array <- function(x, table, ...) { if (!inherits(table, c("Array", "ChunkedArray"))) { table <- Array$create(table) } - Array$create(call_function("index_in_meta_binary", x, table)) + call_function("index_in_meta_binary", x, table) } #' @export @@ -135,7 +135,7 @@ match_arrow.ChunkedArray <- function(x, table, ...) { if (!inherits(table, c("Array", "ChunkedArray"))) { table <- Array$create(table) } - shared_ptr(ChunkedArray, call_function("index_in_meta_binary", x, table)) + call_function("index_in_meta_binary", x, table) } CastOptions <- R6Class("CastOptions", inherit = ArrowObject) diff --git a/r/R/expression.R b/r/R/expression.R index 092c7caed80..27b5e55c15a 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -124,8 +124,7 @@ eval_array_expression <- function(x) { a } }) - ptr <- call_function(x$fun, args = x$args, options = x$options %||% empty_named_list()) - shared_ptr(get(x$result_class), ptr) + call_function(x$fun, args = x$args, options = x$options %||% empty_named_list()) } #' @export @@ -248,7 +247,7 @@ make_expression <- function(operator, e1, e2) { # In doesn't take Scalar, it takes Array return(Expression$in_(e1, e2)) } - + # Handle unary functions before touching e2 if (operator == "is.na") { return(is.na(e1)) diff --git a/r/R/record-batch.R b/r/R/record-batch.R index 1b5fcbba24e..0e7349a171b 100644 --- a/r/R/record-batch.R +++ b/r/R/record-batch.R @@ -103,14 +103,14 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, i <- Array$create(i) } assert_is(i, "Array") - shared_ptr(RecordBatch, call_function("take", self, i)) + call_function("take", self, i) }, Filter = function(i, keep_na = TRUE) { if (is.logical(i)) { i <- Array$create(i) } assert_that(is.Array(i, "bool")) - shared_ptr(RecordBatch, call_function("filter", self, i, options = list(keep_na = keep_na))) + call_function("filter", self, i, options = list(keep_na = keep_na)) }, serialize = function() ipc___SerializeRecordBatch__Raw(self), ToString = function() ToString_tabular(self), diff --git a/r/R/table.R b/r/R/table.R index 6c87a3c3318..e8ec6e2a037 100644 --- a/r/R/table.R +++ b/r/R/table.R @@ -131,13 +131,13 @@ Table <- R6Class("Table", inherit = ArrowObject, if (is.integer(i)) { i <- Array$create(i) } - shared_ptr(Table, call_function("take", self, i)) + call_function("take", self, i) }, Filter = function(i, keep_na = TRUE) { if (is.logical(i)) { i <- Array$create(i) } - shared_ptr(Table, call_function("filter", self, i, options = list(keep_na = keep_na))) + call_function("filter", self, i, options = list(keep_na = keep_na)) }, Equals = function(other, check_metadata = FALSE, ...) { diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 859b0491cd0..5c4579e6d7f 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -130,6 +130,8 @@ struct symbols { static SEXP byte_width; static SEXP list_size; static SEXP arrow_attributes; + static SEXP new_; + static SEXP create; }; struct data { @@ -323,4 +325,32 @@ enable_if_enum as_sexp(E e) { return as_sexp(static_cast(e)); } +template +SEXP R6_make(SEXP symbol, SEXP fun_symbol, const std::shared_ptr& x) { + if (x == nullptr) { + return R_NilValue; + } + cpp11::external_pointer> xp(new std::shared_ptr(x)); + + // make call: $new() + SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, symbol, fun_symbol)); + SEXP call2 = PROTECT(Rf_lang2(call, xp)); + + // and then eval: + SEXP r6 = PROTECT(Rf_eval(call2, arrow::r::ns::arrow)); + + UNPROTECT(3); + return r6; +} + +template +SEXP R6_new(SEXP symbol, const std::shared_ptr& x) { + return R6_make(symbol, arrow::r::symbols::new_, x); +} + +template +SEXP R6_create(SEXP symbol, const std::shared_ptr& x) { + return R6_make(symbol, arrow::r::symbols::create, x); +} + } // namespace cpp11 diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 3c288c93455..f54cd27a558 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -129,19 +129,19 @@ arrow::Datum as_cpp(SEXP x) { SEXP from_datum(arrow::Datum datum) { switch (datum.kind()) { case arrow::Datum::SCALAR: - return cpp11::as_sexp(datum.scalar()); + return cpp11::R6_create(Rf_install("Scalar"), datum.scalar()); case arrow::Datum::ARRAY: - return cpp11::as_sexp(datum.make_array()); + return cpp11::R6_create(Rf_install("Array"), datum.make_array()); case arrow::Datum::CHUNKED_ARRAY: - return cpp11::as_sexp(datum.chunked_array()); + return cpp11::R6_new(Rf_install("ChunkedArray"), datum.chunked_array()); case arrow::Datum::RECORD_BATCH: - return cpp11::as_sexp(datum.record_batch()); + return cpp11::R6_new(Rf_install("RecordBatch"), datum.record_batch()); case arrow::Datum::TABLE: - return cpp11::as_sexp(datum.table()); + return cpp11::R6_new(Rf_install("Table"), datum.table()); default: break; diff --git a/r/src/symbols.cpp b/r/src/symbols.cpp index abb9cd49576..256f9e7acce 100644 --- a/r/src/symbols.cpp +++ b/r/src/symbols.cpp @@ -31,6 +31,8 @@ SEXP symbols::ptype = Rf_install("ptype"); SEXP symbols::byte_width = Rf_install("byte_width"); SEXP symbols::list_size = Rf_install("list_size"); SEXP symbols::arrow_attributes = Rf_install("arrow_attributes"); +SEXP symbols::new_ = Rf_install("new"); +SEXP symbols::create = Rf_install("create"); // persistently protect `x` and return it SEXP precious(SEXP x) { From eb92a97edb132642950ab5c861c599243b3c2456 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Thu, 24 Sep 2020 14:35:22 +0200 Subject: [PATCH 02/43] no need for result_class at all actually --- r/R/expression.R | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/r/R/expression.R b/r/R/expression.R index 27b5e55c15a..ed6543371ad 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -20,14 +20,12 @@ array_expression <- function(FUN, ..., args = list(...), - options = empty_named_list(), - result_class = .guess_result_class(args[[1]])) { + options = empty_named_list()) { structure( list( fun = FUN, args = args, - options = options, - result_class = result_class + options = options ), class = "array_expression" ) @@ -36,7 +34,7 @@ array_expression <- function(FUN, #' @export Ops.Array <- function(e1, e2) { if (.Generic %in% names(.array_function_map)) { - expr <- build_array_expression(.Generic, e1, e2, result_class = "Array") + expr <- build_array_expression(.Generic, e1, e2) eval_array_expression(expr) } else { stop("Unsupported operation on Array: ", .Generic, call. = FALSE) @@ -46,7 +44,7 @@ Ops.Array <- function(e1, e2) { #' @export Ops.ChunkedArray <- function(e1, e2) { if (.Generic %in% names(.array_function_map)) { - expr <- build_array_expression(.Generic, e1, e2, result_class = "ChunkedArray") + expr <- build_array_expression(.Generic, e1, e2) eval_array_expression(expr) } else { stop("Unsupported operation on ChunkedArray: ", .Generic, call. = FALSE) @@ -56,9 +54,9 @@ Ops.ChunkedArray <- function(e1, e2) { #' @export Ops.array_expression <- function(e1, e2) { if (.Generic == "!") { - build_array_expression(.Generic, e1, result_class = e1$result_class) + build_array_expression(.Generic, e1) } else { - build_array_expression(.Generic, e1, e2, result_class = e1$result_class) + build_array_expression(.Generic, e1, e2) } } @@ -105,17 +103,6 @@ build_array_expression <- function(.Generic, e1, e2, ...) { .array_function_map <- c(.unary_function_map, .binary_function_map) -.guess_result_class <- function(arg) { - # HACK HACK HACK delete this when call_function returns an ArrowObject itself - if (inherits(arg, "ArrowObject")) { - return(class(arg)[1]) - } else if (inherits(arg, "array_expression")) { - return(arg$result_class) - } else { - stop("Not implemented") - } -} - eval_array_expression <- function(x) { x$args <- lapply(x$args, function (a) { if (inherits(a, "array_expression")) { From 60faf2368eddd85011ccf3b36e99897925b4f099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Fran=C3=A7ois?= Date: Fri, 25 Sep 2020 08:21:16 +0200 Subject: [PATCH 03/43] Update r/src/arrow_cpp11.h Co-authored-by: Benjamin Kietzman --- r/src/arrow_cpp11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 5c4579e6d7f..ab76b88fca5 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -332,7 +332,7 @@ SEXP R6_make(SEXP symbol, SEXP fun_symbol, const std::shared_ptr& x) { } cpp11::external_pointer> xp(new std::shared_ptr(x)); - // make call: $new() + // make call: $() SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, symbol, fun_symbol)); SEXP call2 = PROTECT(Rf_lang2(call, xp)); From 1bcb72d138c21156e4788339a6d48644582b1cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Fran=C3=A7ois?= Date: Fri, 25 Sep 2020 08:38:40 +0200 Subject: [PATCH 04/43] Update r/src/arrow_cpp11.h Co-authored-by: Benjamin Kietzman --- r/src/arrow_cpp11.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index ab76b88fca5..96ce9754d10 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -344,13 +344,13 @@ SEXP R6_make(SEXP symbol, SEXP fun_symbol, const std::shared_ptr& x) { } template -SEXP R6_new(SEXP symbol, const std::shared_ptr& x) { - return R6_make(symbol, arrow::r::symbols::new_, x); +SEXP R6_new(SEXP symbol, T x) { + return R6_make(symbol, arrow::r::symbols::new_, std::move(x)); } template -SEXP R6_create(SEXP symbol, const std::shared_ptr& x) { - return R6_make(symbol, arrow::r::symbols::create, x); +SEXP R6_create(SEXP symbol, T x) { + return R6_make(symbol, arrow::r::symbols::create, std::move(x)); } } // namespace cpp11 From d08c54d5ce273df84336e0da35858bdf7643ca3f Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 25 Sep 2020 08:58:48 +0200 Subject: [PATCH 05/43] match_arrow.ChunkedArray() is the same as match_arrow.Array() --- r/R/compute.R | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/r/R/compute.R b/r/R/compute.R index 649bffcba2a..a0ef3334d85 100644 --- a/r/R/compute.R +++ b/r/R/compute.R @@ -131,12 +131,7 @@ match_arrow.Array <- function(x, table, ...) { } #' @export -match_arrow.ChunkedArray <- function(x, table, ...) { - if (!inherits(table, c("Array", "ChunkedArray"))) { - table <- Array$create(table) - } - call_function("index_in_meta_binary", x, table) -} +match_arrow.ChunkedArray <- match_arrow.Array CastOptions <- R6Class("CastOptions", inherit = ArrowObject) From 9b43ba3a36de892417037a66c37fb7b74b3aa97f Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 25 Sep 2020 11:53:39 +0200 Subject: [PATCH 06/43] Ops.ChunkedArray <- Ops.Array --- r/R/expression.R | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/r/R/expression.R b/r/R/expression.R index ed6543371ad..c6a07baefdd 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -37,19 +37,12 @@ Ops.Array <- function(e1, e2) { expr <- build_array_expression(.Generic, e1, e2) eval_array_expression(expr) } else { - stop("Unsupported operation on Array: ", .Generic, call. = FALSE) + stop(glue::glue("Unsupported operation on {class(e1)[1L]} : "), .Generic, call. = FALSE) } } #' @export -Ops.ChunkedArray <- function(e1, e2) { - if (.Generic %in% names(.array_function_map)) { - expr <- build_array_expression(.Generic, e1, e2) - eval_array_expression(expr) - } else { - stop("Unsupported operation on ChunkedArray: ", .Generic, call. = FALSE) - } -} +Ops.ChunkedArray <- Ops.Array #' @export Ops.array_expression <- function(e1, e2) { From bec386e0a96fe477e85f75a83b32fbeba036aac8 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 25 Sep 2020 16:56:26 +0200 Subject: [PATCH 07/43] started to skip using shared_ptr() R function by making the R6 object internally --- r/R/arrowExports.R | 8 ++--- r/R/buffer.R | 2 +- r/R/chunked-array.R | 10 +++--- r/R/compression.R | 4 +-- r/R/compute.R | 4 +-- r/R/csv.R | 15 ++++---- r/R/dataset-factory.R | 4 +-- r/R/dataset-partition.R | 16 +++------ r/R/dataset-scan.R | 6 ++-- r/R/dataset.R | 4 +-- r/R/expression.R | 16 ++++----- r/R/feather.R | 4 +-- r/R/field.R | 2 +- r/R/io.R | 10 +++--- r/R/json.R | 2 +- r/R/list.R | 6 ++-- r/R/memory-pool.R | 2 +- r/R/message.R | 10 +++--- r/R/parquet.R | 46 +++++++++--------------- r/R/python.R | 3 +- r/R/record-batch-reader.R | 16 ++++----- r/R/record-batch.R | 22 ++++++------ r/R/schema.R | 18 +++++----- r/R/struct.R | 2 +- r/R/table.R | 24 ++++++------- r/R/type.R | 12 +++++-- r/src/arrowExports.cpp | 28 +++++++-------- r/src/arrow_exports.h | 74 +++++++++++++++++++++++++++++++++++++++ r/src/dataset.cpp | 4 +-- r/src/datatype.cpp | 6 ++-- 30 files changed, 220 insertions(+), 160 deletions(-) diff --git a/r/R/arrowExports.R b/r/R/arrowExports.R index cf83d695a67..5f0c617dfe4 100644 --- a/r/R/arrowExports.R +++ b/r/R/arrowExports.R @@ -644,12 +644,12 @@ DataType__Equals <- function(lhs, rhs){ .Call(`_arrow_DataType__Equals` , lhs, rhs) } -DataType__num_children <- function(type){ - .Call(`_arrow_DataType__num_children` , type) +DataType__num_fields <- function(type){ + .Call(`_arrow_DataType__num_fields` , type) } -DataType__children_pointer <- function(type){ - .Call(`_arrow_DataType__children_pointer` , type) +DataType__fields <- function(type){ + .Call(`_arrow_DataType__fields` , type) } DataType__id <- function(type){ diff --git a/r/R/buffer.R b/r/R/buffer.R index 7829e231cf5..db61ed36d78 100644 --- a/r/R/buffer.R +++ b/r/R/buffer.R @@ -55,7 +55,7 @@ Buffer$create <- function(x) { if (inherits(x, "Buffer")) { x } else if (inherits(x, c("raw", "numeric", "integer", "complex"))) { - shared_ptr(Buffer, r___RBuffer__initialize(x)) + r___RBuffer__initialize(x) } else if (inherits(x, "BufferOutputStream")) { x$finish() } else { diff --git a/r/R/chunked-array.R b/r/R/chunked-array.R index d3b6c94aeb6..f136c111553 100644 --- a/r/R/chunked-array.R +++ b/r/R/chunked-array.R @@ -63,9 +63,9 @@ ChunkedArray <- R6Class("ChunkedArray", inherit = ArrowObject, as_vector = function() ChunkedArray__as_vector(self), Slice = function(offset, length = NULL){ if (is.null(length)) { - shared_ptr(ChunkedArray, ChunkedArray__Slice1(self, offset)) + ChunkedArray__Slice1(self, offset) } else { - shared_ptr(ChunkedArray, ChunkedArray__Slice2(self, offset, length)) + ChunkedArray__Slice2(self, offset, length) } }, Take = function(i) { @@ -85,10 +85,10 @@ ChunkedArray <- R6Class("ChunkedArray", inherit = ArrowObject, }, cast = function(target_type, safe = TRUE, options = cast_options(safe)) { assert_is(options, "CastOptions") - shared_ptr(ChunkedArray, ChunkedArray__cast(self, as_type(target_type), options)) + ChunkedArray__cast(self, as_type(target_type), options) }, View = function(type) { - shared_ptr(ChunkedArray, ChunkedArray__View(self, as_type(type))) + ChunkedArray__View(self, as_type(type)) }, Validate = function() { ChunkedArray__Validate(self) @@ -112,7 +112,7 @@ ChunkedArray$create <- function(..., type = NULL) { if (!is.null(type)) { type <- as_type(type) } - shared_ptr(ChunkedArray, ChunkedArray__from_list(list2(...), type)) + ChunkedArray__from_list(list2(...), type) } #' @param \dots Vectors to coerce diff --git a/r/R/compression.R b/r/R/compression.R index 2318f1b841b..5151b2dc12d 100644 --- a/r/R/compression.R +++ b/r/R/compression.R @@ -46,9 +46,9 @@ Codec <- R6Class("Codec", inherit = ArrowObject, ) Codec$create <- function(type = "gzip", compression_level = NA) { if (is.string(type)) { - type <- shared_ptr(Codec, util___Codec__Create( + type <- util___Codec__Create( compression_from_name(type), compression_level - )) + ) } assert_is(type, "Codec") type diff --git a/r/R/compute.R b/r/R/compute.R index a0ef3334d85..2c067c238ab 100644 --- a/r/R/compute.R +++ b/r/R/compute.R @@ -147,7 +147,5 @@ cast_options <- function(safe = TRUE, allow_int_overflow = !safe, allow_time_truncate = !safe, allow_float_truncate = !safe) { - shared_ptr(CastOptions, - compute___CastOptions__initialize(allow_int_overflow, allow_time_truncate, allow_float_truncate) - ) + compute___CastOptions__initialize(allow_int_overflow, allow_time_truncate, allow_float_truncate) } diff --git a/r/R/csv.R b/r/R/csv.R index 24a0f11312f..48220182626 100644 --- a/r/R/csv.R +++ b/r/R/csv.R @@ -289,7 +289,7 @@ read_tsv_arrow <- function(file, #' @export CsvTableReader <- R6Class("CsvTableReader", inherit = ArrowObject, public = list( - Read = function() shared_ptr(Table, csv___TableReader__Read(self)) + Read = function() csv___TableReader__Read(self) ) ) CsvTableReader$create <- function(file, @@ -400,8 +400,7 @@ CsvReadOptions$create <- function(use_threads = option_use_threads(), skip_rows = 0L, column_names = character(0), autogenerate_column_names = FALSE) { - - shared_ptr(CsvReadOptions, csv___ReadOptions__initialize( + csv___ReadOptions__initialize( list( use_threads = use_threads, block_size = block_size, @@ -409,7 +408,7 @@ CsvReadOptions$create <- function(use_threads = option_use_threads(), column_names = column_names, autogenerate_column_names = autogenerate_column_names ) - )) + ) } readr_to_csv_read_options <- function(skip, col_names, col_types) { @@ -439,7 +438,7 @@ CsvParseOptions$create <- function(delimiter = ",", newlines_in_values = FALSE, ignore_empty_lines = TRUE) { - shared_ptr(CsvParseOptions, csv___ParseOptions__initialize( + csv___ParseOptions__initialize( list( delimiter = delimiter, quoting = quoting, @@ -450,7 +449,7 @@ CsvParseOptions$create <- function(delimiter = ",", newlines_in_values = newlines_in_values, ignore_empty_lines = ignore_empty_lines ) - )) + ) } readr_to_csv_parse_options <- function(delim = ",", @@ -516,7 +515,7 @@ CsvConvertOptions$create <- function(check_utf8 = TRUE, )) } - shared_ptr(CsvConvertOptions, csv___ConvertOptions__initialize( + csv___ConvertOptions__initialize( list( check_utf8 = check_utf8, null_values = null_values, @@ -530,7 +529,7 @@ CsvConvertOptions$create <- function(check_utf8 = TRUE, include_missing_columns = include_missing_columns, timestamp_parsers = timestamp_parsers ) - )) + ) } readr_to_csv_convert_options <- function(na, diff --git a/r/R/dataset-factory.R b/r/R/dataset-factory.R index 8b3439c419d..e62f271473c 100644 --- a/r/R/dataset-factory.R +++ b/r/R/dataset-factory.R @@ -32,7 +32,7 @@ DatasetFactory <- R6Class("DatasetFactory", inherit = ArrowObject, shared_ptr(Dataset, ptr)$..dispatch() }, Inspect = function(unify_schemas = FALSE) { - shared_ptr(Schema, dataset___DatasetFactory__Inspect(self, unify_schemas)) + dataset___DatasetFactory__Inspect(self, unify_schemas) } ) ) @@ -42,7 +42,7 @@ DatasetFactory$create <- function(x, partitioning = NULL, ...) { if (is_list_of(x, "DatasetFactory")) { - return(shared_ptr(DatasetFactory, dataset___UnionDatasetFactory__Make(x))) + return(dataset___UnionDatasetFactory__Make(x)) } path_and_fs <- get_path_and_filesystem(x, filesystem) diff --git a/r/R/dataset-partition.R b/r/R/dataset-partition.R index be47406a6d1..700a57c69a0 100644 --- a/r/R/dataset-partition.R +++ b/r/R/dataset-partition.R @@ -55,18 +55,14 @@ Partitioning <- R6Class("Partitioning", inherit = ArrowObject) #' @rdname Partitioning #' @export DirectoryPartitioning <- R6Class("DirectoryPartitioning", inherit = Partitioning) -DirectoryPartitioning$create <- function(schema) { - shared_ptr(DirectoryPartitioning, dataset___DirectoryPartitioning(schema)) -} +DirectoryPartitioning$create <- dataset___DirectoryPartitioning #' @usage NULL #' @format NULL #' @rdname Partitioning #' @export HivePartitioning <- R6Class("HivePartitioning", inherit = Partitioning) -HivePartitioning$create <- function(schema) { - shared_ptr(HivePartitioning, dataset___HivePartitioning(schema)) -} +HivePartitioning$create <- dataset___HivePartitioning #' Construct Hive partitioning #' @@ -99,15 +95,11 @@ PartitioningFactory <- R6Class("PartitioningFactory", inherit = ArrowObject) #' @rdname Partitioning #' @export DirectoryPartitioningFactory <- R6Class("DirectoryPartitioningFactory ", inherit = PartitioningFactory) -DirectoryPartitioningFactory$create <- function(x) { - shared_ptr(DirectoryPartitioningFactory, dataset___DirectoryPartitioning__MakeFactory(x)) -} +DirectoryPartitioningFactory$create <- dataset___DirectoryPartitioning__MakeFactory #' @usage NULL #' @format NULL #' @rdname Partitioning #' @export HivePartitioningFactory <- R6Class("HivePartitioningFactory", inherit = PartitioningFactory) -HivePartitioningFactory$create <- function() { - shared_ptr(HivePartitioningFactory, dataset___HivePartitioning__MakeFactory()) -} +HivePartitioningFactory$create <- dataset___HivePartitioning__MakeFactory diff --git a/r/R/dataset-scan.R b/r/R/dataset-scan.R index e9017825782..fd4ac90d33e 100644 --- a/r/R/dataset-scan.R +++ b/r/R/dataset-scan.R @@ -55,7 +55,7 @@ #' @export Scanner <- R6Class("Scanner", inherit = ArrowObject, public = list( - ToTable = function() shared_ptr(Table, dataset___Scanner__ToTable(self)), + ToTable = function() dataset___Scanner__ToTable(self), Scan = function() map(dataset___Scanner__Scan(self), shared_ptr, class = ScanTask) ), active = list( @@ -103,7 +103,7 @@ names.Scanner <- function(x) names(x$schema) ScanTask <- R6Class("ScanTask", inherit = ArrowObject, public = list( - Execute = function() map(dataset___ScanTask__get_batches(self), shared_ptr, class = RecordBatch) + Execute = function() dataset___ScanTask__get_batches(self) ) ) @@ -172,7 +172,7 @@ ScannerBuilder <- R6Class("ScannerBuilder", inherit = ArrowObject, Finish = function() unique_ptr(Scanner, dataset___ScannerBuilder__Finish(self)) ), active = list( - schema = function() shared_ptr(Schema, dataset___ScannerBuilder__schema(self)) + schema = function() dataset___ScannerBuilder__schema(self) ) ) diff --git a/r/R/dataset.R b/r/R/dataset.R index 7b1d6609295..19f69d7a4d6 100644 --- a/r/R/dataset.R +++ b/r/R/dataset.R @@ -164,7 +164,7 @@ Dataset <- R6Class("Dataset", inherit = ArrowObject, active = list( schema = function(schema) { if (missing(schema)) { - shared_ptr(Schema, dataset___Dataset__schema(self)) + dataset___Dataset__schema(self) } else { assert_is(schema, "Schema") invisible(shared_ptr(Dataset, dataset___Dataset__ReplaceSchema(self, schema))) @@ -274,7 +274,7 @@ c.Dataset <- function(...) Dataset$create(list(...)) head.Dataset <- function(x, n = 6L, ...) { assert_that(n > 0) # For now scanner <- Scanner$create(ensure_group_vars(x)) - shared_ptr(Table, dataset___Scanner__head(scanner, n)) + dataset___Scanner__head(scanner, n) } #' @export diff --git a/r/R/expression.R b/r/R/expression.R index c6a07baefdd..3d2cbd6e987 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -177,17 +177,17 @@ Expression <- R6Class("Expression", inherit = ArrowObject, Expression$field_ref <- function(name) { assert_is(name, "character") assert_that(length(name) == 1) - shared_ptr(Expression, dataset___expr__field_ref(name)) + dataset___expr__field_ref(name) } Expression$scalar <- function(x) { - shared_ptr(Expression, dataset___expr__scalar(Scalar$create(x))) + dataset___expr__scalar(Scalar$create(x)) } Expression$compare <- function(OP, e1, e2) { comp_func <- comparison_function_map[[OP]] if (is.null(comp_func)) { stop(OP, " is not a supported comparison function", call. = FALSE) } - shared_ptr(Expression, comp_func(e1, e2)) + comp_func(e1, e2) } comparison_function_map <- list( @@ -199,19 +199,19 @@ comparison_function_map <- list( "<=" = dataset___expr__less_equal ) Expression$in_ <- function(x, set) { - shared_ptr(Expression, dataset___expr__in(x, Array$create(set))) + dataset___expr__in(x, Array$create(set)) } Expression$and <- function(e1, e2) { - shared_ptr(Expression, dataset___expr__and(e1, e2)) + dataset___expr__and(e1, e2) } Expression$or <- function(e1, e2) { - shared_ptr(Expression, dataset___expr__or(e1, e2)) + dataset___expr__or(e1, e2) } Expression$not <- function(e1) { - shared_ptr(Expression, dataset___expr__not(e1)) + dataset___expr__not(e1) } Expression$is_valid <- function(e1) { - shared_ptr(Expression, dataset___expr__is_valid(e1)) + dataset___expr__is_valid(e1) } #' @export diff --git a/r/R/feather.R b/r/R/feather.R index 52f8b59ece6..6d29b7d0b89 100644 --- a/r/R/feather.R +++ b/r/R/feather.R @@ -192,7 +192,7 @@ read_feather <- function(file, col_select = NULL, as_data_frame = TRUE, ...) { FeatherReader <- R6Class("FeatherReader", inherit = ArrowObject, public = list( Read = function(columns) { - shared_ptr(Table, ipc___feather___Reader__Read(self, columns)) + ipc___feather___Reader__Read(self, columns) } ), active = list( @@ -207,5 +207,5 @@ names.FeatherReader <- function(x) x$column_names FeatherReader$create <- function(file, mmap = TRUE, ...) { assert_is(file, "RandomAccessFile") - shared_ptr(FeatherReader, ipc___feather___Reader__Open(file)) + ipc___feather___Reader__Open(file) } diff --git a/r/R/field.R b/r/R/field.R index 4053a9fa401..52abbade312 100644 --- a/r/R/field.R +++ b/r/R/field.R @@ -57,7 +57,7 @@ Field$create <- function(name, type, metadata) { assert_that(inherits(name, "character"), length(name) == 1L) type <- as_type(type, name) assert_that(missing(metadata), msg = "metadata= is currently ignored") - shared_ptr(Field, Field__initialize(enc2utf8(name), type, TRUE)) + Field__initialize(enc2utf8(name), type, TRUE) } #' @param name field name diff --git a/r/R/io.R b/r/R/io.R index b4dbbeb6a5f..2a6e672e3bf 100644 --- a/r/R/io.R +++ b/r/R/io.R @@ -78,7 +78,7 @@ FileOutputStream$create <- function(path) { BufferOutputStream <- R6Class("BufferOutputStream", inherit = OutputStream, public = list( capacity = function() io___BufferOutputStream__capacity(self), - finish = function() shared_ptr(Buffer, io___BufferOutputStream__Finish(self)), + finish = function() io___BufferOutputStream__Finish(self), write = function(bytes) io___BufferOutputStream__Write(self, bytes), tell = function() io___BufferOutputStream__Tell(self) ) @@ -92,7 +92,7 @@ BufferOutputStream$create <- function(initial_capacity = 0L) { Readable <- R6Class("Readable", inherit = ArrowObject, public = list( - Read = function(nbytes) shared_ptr(Buffer, io___Readable__Read(self, nbytes)) + Read = function(nbytes) io___Readable__Read(self, nbytes) ) ) @@ -148,9 +148,9 @@ RandomAccessFile <- R6Class("RandomAccessFile", inherit = InputStream, Read = function(nbytes = NULL) { if (is.null(nbytes)) { - shared_ptr(Buffer, io___RandomAccessFile__Read0(self)) + io___RandomAccessFile__Read0(self) } else { - shared_ptr(Buffer, io___Readable__Read(self, nbytes)) + io___Readable__Read(self, nbytes) } }, @@ -158,7 +158,7 @@ RandomAccessFile <- R6Class("RandomAccessFile", inherit = InputStream, if (is.null(nbytes)) { nbytes <- self$GetSize() - position } - shared_ptr(Buffer, io___RandomAccessFile__ReadAt(self, position, nbytes)) + io___RandomAccessFile__ReadAt(self, position, nbytes) } ) ) diff --git a/r/R/json.R b/r/R/json.R index 1cc39fa42d0..d5597fe2a23 100644 --- a/r/R/json.R +++ b/r/R/json.R @@ -64,7 +64,7 @@ read_json_arrow <- function(file, #' @export JsonTableReader <- R6Class("JsonTableReader", inherit = ArrowObject, public = list( - Read = function() shared_ptr(Table, json___TableReader__Read(self)) + Read = function() json___TableReader__Read(self) ) ) JsonTableReader$create <- function(file, diff --git a/r/R/list.R b/r/R/list.R index f91fc3b1fdb..b40d26a8a77 100644 --- a/r/R/list.R +++ b/r/R/list.R @@ -20,7 +20,7 @@ ListType <- R6Class("ListType", inherit = NestedType, active = list( - value_field = function() shared_ptr(Field, ListType__value_field(self)), + value_field = function() ListType__value_field(self), value_type = function() DataType$create(ListType__value_type(self)) ) ) @@ -32,7 +32,7 @@ list_of <- function(type) shared_ptr(ListType, list__(type)) LargeListType <- R6Class("LargeListType", inherit = NestedType, active = list( - value_field = function() shared_ptr(Field, LargeListType__value_field(self)), + value_field = function() LargeListType__value_field(self), value_type = function() DataType$create(LargeListType__value_type(self)) ) ) @@ -46,7 +46,7 @@ large_list_of <- function(type) shared_ptr(LargeListType, large_list__(type)) FixedSizeListType <- R6Class("FixedSizeListType", inherit = NestedType, active = list( - value_field = function() shared_ptr(Field, FixedSizeListType__value_field(self)), + value_field = function() FixedSizeListType__value_field(self), value_type = function() DataType$create(FixedSizeListType__value_type(self)), list_size = function() FixedSizeListType__list_size(self) ) diff --git a/r/R/memory-pool.R b/r/R/memory-pool.R index dfd3a48cb72..547294bb3be 100644 --- a/r/R/memory-pool.R +++ b/r/R/memory-pool.R @@ -48,5 +48,5 @@ MemoryPool <- R6Class("MemoryPool", #' @export #' @keywords internal default_memory_pool <- function() { - shared_ptr(MemoryPool, MemoryPool__default()) + MemoryPool__default() } diff --git a/r/R/message.R b/r/R/message.R index 1cab45915e7..6a374a2b24f 100644 --- a/r/R/message.R +++ b/r/R/message.R @@ -39,8 +39,8 @@ Message <- R6Class("Message", inherit = ArrowObject, ), active = list( type = function() ipc___Message__type(self), - metadata = function() shared_ptr(Buffer, ipc___Message__metadata(self)), - body = function() shared_ptr(Buffer, ipc___Message__body(self)) + metadata = function() ipc___Message__metadata(self), + body = function() ipc___Message__body(self) ) ) @@ -59,7 +59,7 @@ Message <- R6Class("Message", inherit = ArrowObject, #' @export MessageReader <- R6Class("MessageReader", inherit = ArrowObject, public = list( - ReadNextMessage = function() shared_ptr(Message, ipc___MessageReader__ReadNextMessage(self)) + ReadNextMessage = function() ipc___MessageReader__ReadNextMessage(self) ) ) @@ -67,7 +67,7 @@ MessageReader$create <- function(stream) { if (!inherits(stream, "InputStream")) { stream <- BufferReader$create(stream) } - shared_ptr(MessageReader, ipc___MessageReader__Open(stream)) + ipc___MessageReader__Open(stream) } #' Read a Message from a stream @@ -86,7 +86,7 @@ read_message.default <- function(stream) { #' @export read_message.InputStream <- function(stream) { - shared_ptr(Message, ipc___ReadMessage(stream) ) + ipc___ReadMessage(stream) } #' @export diff --git a/r/R/parquet.R b/r/R/parquet.R index 1bc67427b48..1c1fd4ceec2 100644 --- a/r/R/parquet.R +++ b/r/R/parquet.R @@ -212,13 +212,10 @@ ParquetArrowWriterProperties$create <- function(use_deprecated_int96_timestamps c("ms" = TimeUnit$MILLI, "us" = TimeUnit$MICRO) ) } - shared_ptr( - ParquetArrowWriterProperties, - parquet___ArrowWriterProperties___create( - use_deprecated_int96_timestamps = isTRUE(use_deprecated_int96_timestamps), - timestamp_unit = timestamp_unit, - allow_truncated_timestamps = isTRUE(allow_truncated_timestamps) - ) + parquet___ArrowWriterProperties___create( + use_deprecated_int96_timestamps = isTRUE(use_deprecated_int96_timestamps), + timestamp_unit = timestamp_unit, + allow_truncated_timestamps = isTRUE(allow_truncated_timestamps) ) } @@ -348,10 +345,7 @@ ParquetWriterProperties$create <- function(table, write_statistics = NULL, data_page_size = NULL, ...) { - builder <- shared_ptr( - ParquetWriterPropertiesBuilder, - parquet___WriterProperties___Builder__create() - ) + builder <- parquet___WriterProperties___Builder__create() if (!is.null(version)) { builder$set_version(version) } @@ -370,7 +364,7 @@ ParquetWriterProperties$create <- function(table, if (!is.null(data_page_size)) { builder$set_data_page_size(data_page_size) } - shared_ptr(ParquetWriterProperties, parquet___WriterProperties___Builder__build(builder)) + parquet___WriterProperties___Builder__build(builder) } #' @title ParquetFileWriter class @@ -412,10 +406,7 @@ ParquetFileWriter$create <- function(schema, properties = ParquetWriterProperties$create(), arrow_properties = ParquetArrowWriterProperties$create()) { assert_is(sink, "OutputStream") - shared_ptr( - ParquetFileWriter, - parquet___arrow___ParquetFileWriter__Open(schema, sink, properties, arrow_properties) - ) + parquet___arrow___ParquetFileWriter__Open(schema, sink, properties, arrow_properties) } @@ -484,36 +475,36 @@ ParquetFileReader <- R6Class("ParquetFileReader", public = list( ReadTable = function(column_indices = NULL) { if (is.null(column_indices)) { - shared_ptr(Table, parquet___arrow___FileReader__ReadTable1(self)) + parquet___arrow___FileReader__ReadTable1(self) } else { column_indices <- vec_cast(column_indices, integer()) - shared_ptr(Table, parquet___arrow___FileReader__ReadTable2(self, column_indices)) + parquet___arrow___FileReader__ReadTable2(self, column_indices) } }, ReadRowGroup = function(i, column_indices = NULL) { i <- vec_cast(i, integer()) if (is.null(column_indices)) { - shared_ptr(Table, parquet___arrow___FileReader__ReadRowGroup1(self, i)) + parquet___arrow___FileReader__ReadRowGroup1(self, i) } else { column_indices <- vec_cast(column_indices, integer()) - shared_ptr(Table, parquet___arrow___FileReader__ReadRowGroup2(self, i, column_indices)) + parquet___arrow___FileReader__ReadRowGroup2(self, i, column_indices) } }, ReadRowGroups = function(row_groups, column_indices = NULL) { row_groups <- vec_cast(row_groups, integer()) if (is.null(column_indices)) { - shared_ptr(Table, parquet___arrow___FileReader__ReadRowGroups1(self, row_groups)) + parquet___arrow___FileReader__ReadRowGroups1(self, row_groups) } else { column_indices <- vec_cast(column_indices, integer()) - shared_ptr(Table, parquet___arrow___FileReader__ReadRowGroups2(self, row_groups, column_indices)) + parquet___arrow___FileReader__ReadRowGroups2(self, row_groups, column_indices) } }, ReadColumn = function(i) { i <- vec_cast(i, integer()) - shared_ptr(ChunkedArray, parquet___arrow___FileReader__ReadColumn(self, i)) + parquet___arrow___FileReader__ReadColumn(self, i) }, GetSchema = function() { - shared_ptr(Schema, parquet___arrow___FileReader__GetSchema(self)) + parquet___arrow___FileReader__GetSchema(self) } ) ) @@ -525,7 +516,7 @@ ParquetFileReader$create <- function(file, file <- make_readable_file(file, mmap) assert_is(props, "ParquetReaderProperties") - shared_ptr(ParquetFileReader, parquet___arrow___FileReader__OpenFile(file, props)) + parquet___arrow___FileReader__OpenFile(file, props) } #' @title ParquetReaderProperties class @@ -573,8 +564,5 @@ ParquetReaderProperties <- R6Class("ParquetReaderProperties", ) ParquetReaderProperties$create <- function(use_threads = option_use_threads()) { - shared_ptr( - ParquetReaderProperties, - parquet___arrow___ArrowReaderProperties__Make(isTRUE(use_threads)) - ) + parquet___arrow___ArrowReaderProperties__Make(isTRUE(use_threads)) } diff --git a/r/R/python.R b/r/R/python.R index 7e29730a352..f348316e87e 100644 --- a/r/R/python.R +++ b/r/R/python.R @@ -53,7 +53,8 @@ py_to_r.pyarrow.lib.RecordBatch <- function(x, ...) { }) x$`_export_to_c`(array_ptr, schema_ptr) - shared_ptr(RecordBatch, ImportRecordBatch(array_ptr, schema_ptr)) + + ImportRecordBatch(array_ptr, schema_ptr) } r_to_py.RecordBatch <- function(x, convert = FALSE) { diff --git a/r/R/record-batch-reader.R b/r/R/record-batch-reader.R index 85ce839d0ce..53f9995b47d 100644 --- a/r/R/record-batch-reader.R +++ b/r/R/record-batch-reader.R @@ -95,11 +95,11 @@ RecordBatchReader <- R6Class("RecordBatchReader", inherit = ArrowObject, public = list( read_next_batch = function() { - shared_ptr(RecordBatch, RecordBatchReader__ReadNext(self)) + RecordBatchReader__ReadNext(self) } ), active = list( - schema = function() shared_ptr(Schema, RecordBatchReader__schema(self)) + schema = function() RecordBatchReader__schema(self) ) ) @@ -109,8 +109,8 @@ RecordBatchReader <- R6Class("RecordBatchReader", inherit = ArrowObject, #' @export RecordBatchStreamReader <- R6Class("RecordBatchStreamReader", inherit = RecordBatchReader, public = list( - batches = function() map(ipc___RecordBatchStreamReader__batches(self), shared_ptr, class = RecordBatch), - read_table = function() shared_ptr(Table, Table__from_RecordBatchStreamReader(self)) + batches = function() ipc___RecordBatchStreamReader__batches(self), + read_table = function() Table__from_RecordBatchStreamReader(self) ) ) RecordBatchStreamReader$create <- function(stream) { @@ -131,16 +131,16 @@ RecordBatchFileReader <- R6Class("RecordBatchFileReader", inherit = ArrowObject, # Why doesn't this inherit from RecordBatchReader? public = list( get_batch = function(i) { - shared_ptr(RecordBatch, ipc___RecordBatchFileReader__ReadRecordBatch(self, i)) + ipc___RecordBatchFileReader__ReadRecordBatch(self, i) }, batches = function() { - map(ipc___RecordBatchFileReader__batches(self), shared_ptr, class = RecordBatch) + ipc___RecordBatchFileReader__batches(self) }, - read_table = function() shared_ptr(Table, Table__from_RecordBatchFileReader(self)) + read_table = function() Table__from_RecordBatchFileReader(self) ), active = list( num_record_batches = function() ipc___RecordBatchFileReader__num_record_batches(self), - schema = function() shared_ptr(Schema, ipc___RecordBatchFileReader__schema(self)) + schema = function() ipc___RecordBatchFileReader__schema(self) ) ) RecordBatchFileReader$create <- function(file) { diff --git a/r/R/record-batch.R b/r/R/record-batch.R index 0e7349a171b..6967b1db8d2 100644 --- a/r/R/record-batch.R +++ b/r/R/record-batch.R @@ -83,16 +83,16 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, shared_ptr(Array, RecordBatch__GetColumnByName(self, name)) }, SelectColumns = function(indices) { - shared_ptr(RecordBatch, RecordBatch__SelectColumns(self, indices)) + RecordBatch__SelectColumns(self, indices) }, RemoveColumn = function(i){ - shared_ptr(RecordBatch, RecordBatch__RemoveColumn(self, i)) + RecordBatch__RemoveColumn(self, i) }, Slice = function(offset, length = NULL) { if (is.null(length)) { - shared_ptr(RecordBatch, RecordBatch__Slice1(self, offset)) + RecordBatch__Slice1(self, offset) } else { - shared_ptr(RecordBatch, RecordBatch__Slice2(self, offset, length)) + RecordBatch__Slice2(self, offset, length) } }, Take = function(i) { @@ -119,14 +119,15 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, assert_is(target_schema, "Schema") assert_is(options, "CastOptions") assert_that(identical(self$schema$names, target_schema$names), msg = "incompatible schemas") - shared_ptr(RecordBatch, RecordBatch__cast(self, target_schema, options)) + + RecordBatch__cast(self, target_schema, options) } ), active = list( num_columns = function() RecordBatch__num_columns(self), num_rows = function() RecordBatch__num_rows(self), - schema = function() shared_ptr(Schema, RecordBatch__schema(self)), + schema = function() RecordBatch__schema(self), metadata = function(new) { if (missing(new)) { # Get the metadata (from the schema) @@ -137,7 +138,7 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, out <- RecordBatch__ReplaceSchemaMetadata(self, new) # ReplaceSchemaMetadata returns a new object but we're modifying in place, # so swap in that new C++ object pointer into our R6 object - self$set_pointer(out) + self$set_pointer(out$pointer()) self } }, @@ -156,8 +157,9 @@ RecordBatch$create <- function(..., schema = NULL) { names(arrays) <- rep_len("", length(arrays)) } stopifnot(length(arrays) > 0) + # TODO: should this also assert that they're all Arrays? - shared_ptr(RecordBatch, RecordBatch__from_arrays(schema, arrays)) + RecordBatch__from_arrays(schema, arrays) } RecordBatch$from_message <- function(obj, schema) { @@ -168,9 +170,9 @@ RecordBatch$from_message <- function(obj, schema) { on.exit(obj$close()) } if (inherits(obj, "InputStream")) { - shared_ptr(RecordBatch, ipc___ReadRecordBatch__InputStream__Schema(obj, schema)) + ipc___ReadRecordBatch__InputStream__Schema(obj, schema) } else { - shared_ptr(RecordBatch, ipc___ReadRecordBatch__Message__Schema(obj, schema)) + ipc___ReadRecordBatch__Message__Schema(obj, schema) } } diff --git a/r/R/schema.R b/r/R/schema.R index 4bba8b87f47..9a0ad85acac 100644 --- a/r/R/schema.R +++ b/r/R/schema.R @@ -71,12 +71,12 @@ Schema <- R6Class("Schema", } fields }, - field = function(i) shared_ptr(Field, Schema__field(self, i)), - GetFieldByName = function(x) shared_ptr(Field, Schema__GetFieldByName(self, x)), + field = function(i) Schema__field(self, i), + GetFieldByName = function(x) Schema__GetFieldByName(self, x), serialize = function() Schema__serialize(self), WithMetadata = function(metadata = NULL) { metadata <- prepare_key_value_metadata(metadata) - shared_ptr(Schema, Schema__WithMetadata(self, metadata)) + Schema__WithMetadata(self, metadata) }, Equals = function(other, check_metadata = FALSE, ...) { inherits(other, "Schema") && Schema__Equals(self, other, isTRUE(check_metadata)) @@ -87,7 +87,7 @@ Schema <- R6Class("Schema", Schema__field_names(self) }, num_fields = function() Schema__num_fields(self), - fields = function() map(Schema__fields(self), shared_ptr, class = Field), + fields = function() Schema__fields(self), HasMetadata = function() Schema__HasMetadata(self), metadata = function(new_metadata) { if (missing(new_metadata)) { @@ -103,7 +103,7 @@ Schema <- R6Class("Schema", } ) ) -Schema$create <- function(...) shared_ptr(Schema, schema_(.fields(list2(...)))) +Schema$create <- function(...) schema_(.fields(list2(...))) prepare_key_value_metadata <- function(metadata) { # key-value-metadata must be a named character vector; @@ -169,7 +169,7 @@ length.Schema <- function(x) x$num_fields call. = FALSE ) } - shared_ptr(Schema, schema_(fields)) + schema_(fields) } #' @export @@ -193,13 +193,13 @@ as.list.Schema <- function(x, ...) x$fields #' @export read_schema <- function(stream, ...) { if (inherits(stream, "Message")) { - return(shared_ptr(Schema, ipc___ReadSchema_Message(stream))) + return(ipc___ReadSchema_Message(stream)) } else { if (!inherits(stream, "InputStream")) { stream <- BufferReader$create(stream) on.exit(stream$close()) } - return(shared_ptr(Schema, ipc___ReadSchema_InputStream(stream))) + return(ipc___ReadSchema_InputStream(stream)) } } @@ -216,7 +216,7 @@ read_schema <- function(stream, ...) { #' unify_schemas(a, z) #' } unify_schemas <- function(..., schemas = list(...)) { - shared_ptr(Schema, arrow__UnifySchemas(schemas)) + arrow__UnifySchemas(schemas) } #' @export diff --git a/r/R/struct.R b/r/R/struct.R index feda966f56d..0e871a8780d 100644 --- a/r/R/struct.R +++ b/r/R/struct.R @@ -20,7 +20,7 @@ StructType <- R6Class("StructType", inherit = NestedType, public = list( - GetFieldByName = function(name) shared_ptr(Field, StructType__GetFieldByName(self, name)), + GetFieldByName = function(name) StructType__GetFieldByName(self, name), GetFieldIndex = function(name) StructType__GetFieldIndex(self, name) ) ) diff --git a/r/R/table.R b/r/R/table.R index e8ec6e2a037..cf25e898e62 100644 --- a/r/R/table.R +++ b/r/R/table.R @@ -93,15 +93,15 @@ Table <- R6Class("Table", inherit = ArrowObject, public = list( column = function(i) { - shared_ptr(ChunkedArray, Table__column(self, i)) + Table__column(self, i) }, ColumnNames = function() Table__ColumnNames(self), GetColumnByName = function(name) { assert_is(name, "character") assert_that(length(name) == 1) - shared_ptr(ChunkedArray, Table__GetColumnByName(self, name)) + Table__GetColumnByName(self, name) }, - field = function(i) shared_ptr(Field, Table__field(self, i)), + field = function(i) Table__field(self, i), serialize = function(output_stream, ...) write_table(self, output_stream, ...), ToString = function() ToString_tabular(self), @@ -110,18 +110,18 @@ Table <- R6Class("Table", inherit = ArrowObject, assert_is(target_schema, "Schema") assert_is(options, "CastOptions") assert_that(identical(self$schema$names, target_schema$names), msg = "incompatible schemas") - shared_ptr(Table, Table__cast(self, target_schema, options)) + Table__cast(self, target_schema, options) }, SelectColumns = function(indices) { - shared_ptr(Table, Table__SelectColumns(self, indices)) + Table__SelectColumns(self, indices) }, Slice = function(offset, length = NULL) { if (is.null(length)) { - shared_ptr(Table, Table__Slice1(self, offset)) + Table__Slice1(self, offset) } else { - shared_ptr(Table, Table__Slice2(self, offset, length)) + Table__Slice2(self, offset, length) } }, Take = function(i) { @@ -156,7 +156,7 @@ Table <- R6Class("Table", inherit = ArrowObject, active = list( num_columns = function() Table__num_columns(self), num_rows = function() Table__num_rows(self), - schema = function() shared_ptr(Schema, Table__schema(self)), + schema = function() Table__schema(self), metadata = function(new) { if (missing(new)) { # Get the metadata (from the schema) @@ -167,11 +167,11 @@ Table <- R6Class("Table", inherit = ArrowObject, out <- Table__ReplaceSchemaMetadata(self, new) # ReplaceSchemaMetadata returns a new object but we're modifying in place, # so swap in that new C++ object pointer into our R6 object - self$set_pointer(out) + self$set_pointer(out$pointer()) self } }, - columns = function() map(Table__columns(self), shared_ptr, class = ChunkedArray) + columns = function() Table__columns(self) ) ) @@ -218,9 +218,9 @@ Table$create <- function(..., schema = NULL) { } stopifnot(length(dots) > 0) if (all_record_batches(dots)) { - shared_ptr(Table, Table__from_record_batches(dots, schema)) + Table__from_record_batches(dots, schema) } else { - shared_ptr(Table, Table__from_dots(dots, schema)) + Table__from_dots(dots, schema) } } diff --git a/r/R/type.R b/r/R/type.R index 921786bfd21..f6a497ba758 100644 --- a/r/R/type.R +++ b/r/R/type.R @@ -37,13 +37,19 @@ DataType <- R6Class("DataType", Equals = function(other, ...) { inherits(other, "DataType") && DataType__Equals(self, other) }, + num_fields = function() { + DataType__num_fields(self) + }, num_children = function() { - DataType__num_children(self) + DataType__num_fields(self) }, children = function() { - map(DataType__children_pointer(self), shared_ptr, class = Field) + # TODO: this is deprecated + DataType__fields(self) + }, + fields = function() { + DataType__fields(self) }, - ..dispatch = function() { switch(names(Type)[self$id + 1], "NA" = null(), diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index cadfc8c0745..add7b9b6178 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -1763,7 +1763,7 @@ extern "C" SEXP _arrow_dataset___CsvFileFormat__Make(SEXP parse_options_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___DirectoryPartitioning(const std::shared_ptr& schm); +std::shared_ptr dataset___DirectoryPartitioning(const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___DirectoryPartitioning(SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schm(schm_sexp); @@ -1793,7 +1793,7 @@ extern "C" SEXP _arrow_dataset___DirectoryPartitioning__MakeFactory(SEXP field_n // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___HivePartitioning(const std::shared_ptr& schm); +std::shared_ptr dataset___HivePartitioning(const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___HivePartitioning(SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schm(schm_sexp); @@ -2497,31 +2497,31 @@ extern "C" SEXP _arrow_DataType__Equals(SEXP lhs_sexp, SEXP rhs_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -int DataType__num_children(const std::shared_ptr& type); -extern "C" SEXP _arrow_DataType__num_children(SEXP type_sexp){ +int DataType__num_fields(const std::shared_ptr& type); +extern "C" SEXP _arrow_DataType__num_fields(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); - return cpp11::as_sexp(DataType__num_children(type)); + return cpp11::as_sexp(DataType__num_fields(type)); END_CPP11 } #else -extern "C" SEXP _arrow_DataType__num_children(SEXP type_sexp){ - Rf_error("Cannot call DataType__num_children(). Please use arrow::install_arrow() to install required runtime libraries. "); +extern "C" SEXP _arrow_DataType__num_fields(SEXP type_sexp){ + Rf_error("Cannot call DataType__num_fields(). Please use arrow::install_arrow() to install required runtime libraries. "); } #endif // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -cpp11::writable::list DataType__children_pointer(const std::shared_ptr& type); -extern "C" SEXP _arrow_DataType__children_pointer(SEXP type_sexp){ +std::vector> DataType__fields(const std::shared_ptr& type); +extern "C" SEXP _arrow_DataType__fields(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); - return cpp11::as_sexp(DataType__children_pointer(type)); + return cpp11::as_sexp(DataType__fields(type)); END_CPP11 } #else -extern "C" SEXP _arrow_DataType__children_pointer(SEXP type_sexp){ - Rf_error("Cannot call DataType__children_pointer(). Please use arrow::install_arrow() to install required runtime libraries. "); +extern "C" SEXP _arrow_DataType__fields(SEXP type_sexp){ + Rf_error("Cannot call DataType__fields(). Please use arrow::install_arrow() to install required runtime libraries. "); } #endif @@ -6489,8 +6489,8 @@ static const R_CallMethodDef CallEntries[] = { { "_arrow_DataType__ToString", (DL_FUNC) &_arrow_DataType__ToString, 1}, { "_arrow_DataType__name", (DL_FUNC) &_arrow_DataType__name, 1}, { "_arrow_DataType__Equals", (DL_FUNC) &_arrow_DataType__Equals, 2}, - { "_arrow_DataType__num_children", (DL_FUNC) &_arrow_DataType__num_children, 1}, - { "_arrow_DataType__children_pointer", (DL_FUNC) &_arrow_DataType__children_pointer, 1}, + { "_arrow_DataType__num_fields", (DL_FUNC) &_arrow_DataType__num_fields, 1}, + { "_arrow_DataType__fields", (DL_FUNC) &_arrow_DataType__fields, 1}, { "_arrow_DataType__id", (DL_FUNC) &_arrow_DataType__id, 1}, { "_arrow_ListType__ToString", (DL_FUNC) &_arrow_ListType__ToString, 1}, { "_arrow_FixedWidthType__bit_width", (DL_FUNC) &_arrow_FixedWidthType__bit_width, 1}, diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index c4cc0ff6ede..8752ae81c63 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -22,6 +22,7 @@ #include "./arrow_cpp11.h" #if defined(ARROW_R_WITH_ARROW) +#include #include #include #include @@ -84,4 +85,77 @@ class FileWriter; } // namespace arrow } // namespace parquet +namespace cpp11 { + +template +const char* get_r6_class_name(); + +inline SEXP xp_to_r6(SEXP xp, SEXP r6_class) { + // make call: $new() + SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_)); + SEXP call2 = PROTECT(Rf_lang2(call, xp)); + + // and then eval in arrow:: + SEXP r6 = PROTECT(Rf_eval(call2, arrow::r::ns::arrow)); + + UNPROTECT(3); + return r6; +} + +template +inline SEXP shared_ptr_to_r6(const std::shared_ptr& x) { + if (x == nullptr) return R_NilValue; + cpp11::external_pointer> xp(new std::shared_ptr(x)); + SEXP r6_class = Rf_install(get_r6_class_name()); + return xp_to_r6(xp, r6_class); +} + +#define R6_HANDLE(TYPE, NAME) \ + template <> \ + const char* get_r6_class_name() { \ + return NAME; \ + } \ + template <> \ + SEXP as_sexp(const std::shared_ptr& ptr) { \ + return shared_ptr_to_r6(ptr); \ + } + +R6_HANDLE(arrow::RecordBatch, "RecordBatch") +R6_HANDLE(arrow::Table, "Table") +R6_HANDLE(arrow::Schema, "Schema") +R6_HANDLE(arrow::Buffer, "Buffer") +R6_HANDLE(arrow::MemoryPool, "MemoryPool") +R6_HANDLE(arrow::Field, "Field") +R6_HANDLE(arrow::ChunkedArray, "ChunkedArray") + +R6_HANDLE(arrow::dataset::DirectoryPartitioning, "DirectoryPartitioning") +R6_HANDLE(arrow::dataset::HivePartitioning, "HivePartitioning") +R6_HANDLE(arrow::dataset::PartitioningFactory, "PartitioningFactory") +R6_HANDLE(arrow::dataset::DatasetFactory, "DatasetFactory") + +R6_HANDLE(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder") +R6_HANDLE(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties") +R6_HANDLE(parquet::WriterProperties, "ParquetWriterProperties") +R6_HANDLE(parquet::arrow::FileWriter, "ParquetFileWriter") +R6_HANDLE(parquet::arrow::FileReader, "ParquetFileReader") +R6_HANDLE(parquet::ArrowReaderProperties, "ParquetReaderProperties") + +R6_HANDLE(arrow::ipc::feather::Reader, "FeatherReader") + +R6_HANDLE(arrow::csv::TableReader, "CsvTableReader") +R6_HANDLE(arrow::csv::ReadOptions, "CsvReadOptions") +R6_HANDLE(arrow::csv::ParseOptions, "CsvParseOptions") +R6_HANDLE(arrow::csv::ConvertOptions, "CsvConvertOptions") + +R6_HANDLE(arrow::dataset::Expression, "Expression") + +R6_HANDLE(arrow::compute::CastOptions, "CastOptions") + +R6_HANDLE(arrow::util::Codec, "Codec") + +R6_HANDLE(arrow::ipc::Message, "Message") +R6_HANDLE(arrow::ipc::MessageReader, "MessageReader") + +} // namespace cpp11 + #endif diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 4327b80f187..e7aff86e96a 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -244,7 +244,7 @@ std::shared_ptr dataset___CsvFileFormat__Make( // DirectoryPartitioning, HivePartitioning // [[arrow::export]] -std::shared_ptr dataset___DirectoryPartitioning( +std::shared_ptr dataset___DirectoryPartitioning( const std::shared_ptr& schm) { return std::make_shared(schm); } @@ -256,7 +256,7 @@ std::shared_ptr dataset___DirectoryPartitioning__MakeFa } // [[arrow::export]] -std::shared_ptr dataset___HivePartitioning( +std::shared_ptr dataset___HivePartitioning( const std::shared_ptr& schm) { return std::make_shared(schm); } diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index 81d2bd40dd7..eb5ec7e6231 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -196,14 +196,14 @@ bool DataType__Equals(const std::shared_ptr& lhs, } // [[arrow::export]] -int DataType__num_children(const std::shared_ptr& type) { +int DataType__num_fields(const std::shared_ptr& type) { return type->num_fields(); } // [[arrow::export]] -cpp11::writable::list DataType__children_pointer( +std::vector> DataType__fields( const std::shared_ptr& type) { - return arrow::r::to_r_list(type->fields()); + return type->fields(); } // [[arrow::export]] From 888daf95078ff94ac273cad679660079c00f77aa Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 25 Sep 2020 19:20:36 +0200 Subject: [PATCH 08/43] forward declare classes instead of include api.h --- r/src/arrow_exports.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index 8752ae81c63..6af55f8a2c0 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -22,7 +22,6 @@ #include "./arrow_cpp11.h" #if defined(ARROW_R_WITH_ARROW) -#include #include #include #include @@ -85,6 +84,15 @@ class FileWriter; } // namespace arrow } // namespace parquet +namespace arrow { +namespace dataset { + +class DirectoryPartitioning; +class HivePartitioning; + +} +} + namespace cpp11 { template From 3e0f50195d4c2e7f20714d4aa7576b88b6bbead8 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 6 Oct 2020 10:20:50 +0200 Subject: [PATCH 09/43] simplify R6_HANDLE macro --- r/src/arrow_exports.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index 6af55f8a2c0..a78c1111967 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -95,9 +95,6 @@ class HivePartitioning; namespace cpp11 { -template -const char* get_r6_class_name(); - inline SEXP xp_to_r6(SEXP xp, SEXP r6_class) { // make call: $new() SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_)); @@ -111,21 +108,17 @@ inline SEXP xp_to_r6(SEXP xp, SEXP r6_class) { } template -inline SEXP shared_ptr_to_r6(const std::shared_ptr& x) { +inline SEXP shared_ptr_to_r6(const std::shared_ptr& x, const std::string& r_class_name) { if (x == nullptr) return R_NilValue; cpp11::external_pointer> xp(new std::shared_ptr(x)); - SEXP r6_class = Rf_install(get_r6_class_name()); + SEXP r6_class = Rf_install(r_class_name.c_str()); return xp_to_r6(xp, r6_class); } #define R6_HANDLE(TYPE, NAME) \ - template <> \ - const char* get_r6_class_name() { \ - return NAME; \ - } \ template <> \ SEXP as_sexp(const std::shared_ptr& ptr) { \ - return shared_ptr_to_r6(ptr); \ + return shared_ptr_to_r6(ptr, NAME); \ } R6_HANDLE(arrow::RecordBatch, "RecordBatch") From bea74bad0decd03853cef1da6f684c9d6525cd18 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 6 Oct 2020 11:57:57 +0200 Subject: [PATCH 10/43] rebase --- r/R/csv.R | 5 +---- r/R/dataset-factory.R | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/r/R/csv.R b/r/R/csv.R index 48220182626..df49c88b49c 100644 --- a/r/R/csv.R +++ b/r/R/csv.R @@ -298,10 +298,7 @@ CsvTableReader$create <- function(file, convert_options = CsvConvertOptions$create(), ...) { assert_is(file, "InputStream") - shared_ptr( - CsvTableReader, - csv___TableReader__Make(file, read_options, parse_options, convert_options) - ) + csv___TableReader__Make(file, read_options, parse_options, convert_options) } #' @title File reader options diff --git a/r/R/dataset-factory.R b/r/R/dataset-factory.R index e62f271473c..088f8def449 100644 --- a/r/R/dataset-factory.R +++ b/r/R/dataset-factory.R @@ -143,5 +143,5 @@ FileSystemDatasetFactory$create <- function(filesystem, ) } - shared_ptr(FileSystemDatasetFactory, ptr) + ptr } From 351c199a468c0f76d383a1b02ce89875ee85e990 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Wed, 7 Oct 2020 17:50:22 +0200 Subject: [PATCH 11/43] using experimental cpp11::r6 --- r/R/array.R | 49 ++---- r/R/arrowExports.R | 4 +- r/R/compression.R | 4 +- r/R/dataset-factory.R | 5 +- r/R/dataset-format.R | 31 ++-- r/R/dataset.R | 22 +-- r/R/dictionary.R | 2 +- r/R/filesystem.R | 39 ++--- r/R/io.R | 12 +- r/R/json.R | 9 +- r/R/record-batch-reader.R | 4 +- r/R/record-batch-writer.R | 24 ++- r/R/record-batch.R | 4 +- r/R/scalar.R | 29 +--- r/src/array.cpp | 76 ++++---- r/src/array_from_vector.cpp | 16 +- r/src/arrowExports.cpp | 336 ++++++++++++++++++------------------ r/src/arrow_cpp11.h | 47 ++--- r/src/arrow_exports.h | 70 +------- r/src/arrow_types.h | 8 +- r/src/buffer.cpp | 13 +- r/src/chunkedarray.cpp | 25 ++- r/src/compression.cpp | 22 +-- r/src/compute.cpp | 66 +++---- r/src/csv.cpp | 28 ++- r/src/dataset.cpp | 180 +++++++++++-------- r/src/datatype.cpp | 30 ++-- r/src/expression.cpp | 82 ++++----- r/src/feather.cpp | 9 +- r/src/field.cpp | 8 +- r/src/filesystem.cpp | 60 +++---- r/src/io.cpp | 59 +++---- r/src/json.cpp | 21 ++- r/src/memorypool.cpp | 5 +- r/src/message.cpp | 45 +++-- r/src/parquet.cpp | 68 ++++---- r/src/py-to-r.cpp | 13 +- r/src/recordbatch.cpp | 57 +++--- r/src/recordbatchreader.cpp | 40 ++--- r/src/recordbatchwriter.cpp | 12 +- r/src/scalar.cpp | 35 ++-- r/src/schema.cpp | 26 ++- r/src/table.cpp | 51 +++--- 43 files changed, 831 insertions(+), 915 deletions(-) diff --git a/r/R/array.R b/r/R/array.R index 4ec89780611..f4fb946acd4 100644 --- a/r/R/array.R +++ b/r/R/array.R @@ -85,22 +85,6 @@ Array <- R6Class("Array", inherit = ArrowObject, public = list( - ..dispatch = function() { - type_id <- self$type_id() - if (type_id == Type$DICTIONARY){ - shared_ptr(DictionaryArray, self$pointer()) - } else if (type_id == Type$STRUCT) { - shared_ptr(StructArray, self$pointer()) - } else if (type_id == Type$LIST) { - shared_ptr(ListArray, self$pointer()) - } else if (type_id == Type$LARGE_LIST){ - shared_ptr(LargeListArray, self$pointer()) - } else if (type_id == Type$FIXED_SIZE_LIST){ - shared_ptr(FixedSizeListArray, self$pointer()) - } else { - self - } - }, IsNull = function(i) Array__IsNull(self, i), IsValid = function(i) Array__IsValid(self, i), length = function() Array__length(self), @@ -111,7 +95,7 @@ Array <- R6Class("Array", ApproxEquals = function(other) { inherits(other, "Array") && Array__ApproxEquals(self, other) }, - data = function() shared_ptr(ArrayData, Array__data(self)), + data = function() Array__data(self), as_vector = function() Array__as_vector(self), ToString = function() { typ <- paste0("<", self$type$ToString(), ">") @@ -119,9 +103,9 @@ Array <- R6Class("Array", }, Slice = function(offset, length = NULL) { if (is.null(length)) { - Array$create(Array__Slice1(self, offset)) + Array__Slice1(self, offset) } else { - Array$create(Array__Slice2(self, offset, length)) + Array__Slice2(self, offset, length) } }, Take = function(i) { @@ -160,13 +144,10 @@ Array <- R6Class("Array", ) ) Array$create <- function(x, type = NULL) { - if (!inherits(x, "externalptr")) { - if (!is.null(type)) { - type <- as_type(type) - } - x <- Array__from_vector(x, type) + if (!is.null(type)) { + type <- as_type(type) } - shared_ptr(Array, x)$..dispatch() + Array__from_vector(x, type) } #' @rdname array @@ -175,8 +156,8 @@ Array$create <- function(x, type = NULL) { #' @export DictionaryArray <- R6Class("DictionaryArray", inherit = Array, public = list( - indices = function() Array$create(DictionaryArray__indices(self)), - dictionary = function() Array$create(DictionaryArray__dictionary(self)) + indices = function() DictionaryArray__indices(self), + dictionary = function() DictionaryArray__dictionary(self) ), active = list( ordered = function() self$type$ordered @@ -197,7 +178,7 @@ DictionaryArray$create <- function(x, dict = NULL) { dict <- Array$create(dict) } type <- DictionaryType$create(x$type, dict$type) - shared_ptr(DictionaryArray, DictionaryArray__FromArrays(type, x, dict)) + DictionaryArray__FromArrays(type, x, dict) } #' @rdname array @@ -206,9 +187,9 @@ DictionaryArray$create <- function(x, dict = NULL) { #' @export StructArray <- R6Class("StructArray", inherit = Array, public = list( - field = function(i) Array$create(StructArray__field(self, i)), - GetFieldByName = function(name) Array$create(StructArray__GetFieldByName(self, name)), - Flatten = function() map(StructArray__Flatten(self), ~ Array$create(.x)) + field = function(i) StructArray__field(self, i), + GetFieldByName = function(name) StructArray__GetFieldByName(self, name), + Flatten = function() StructArray__Flatten(self) ) ) @@ -218,7 +199,7 @@ StructArray <- R6Class("StructArray", inherit = Array, #' @export ListArray <- R6Class("ListArray", inherit = Array, public = list( - values = function() Array$create(ListArray__values(self)), + values = function() ListArray__values(self), value_length = function(i) ListArray__value_length(self, i), value_offset = function(i) ListArray__value_offset(self, i), raw_value_offsets = function() ListArray__raw_value_offsets(self) @@ -234,7 +215,7 @@ ListArray <- R6Class("ListArray", inherit = Array, #' @export LargeListArray <- R6Class("LargeListArray", inherit = Array, public = list( - values = function() Array$create(LargeListArray__values(self)), + values = function() LargeListArray__values(self), value_length = function(i) LargeListArray__value_length(self, i), value_offset = function(i) LargeListArray__value_offset(self, i), raw_value_offsets = function() LargeListArray__raw_value_offsets(self) @@ -250,7 +231,7 @@ LargeListArray <- R6Class("LargeListArray", inherit = Array, #' @export FixedSizeListArray <- R6Class("FixedSizeListArray", inherit = Array, public = list( - values = function() Array$create(FixedSizeListArray__values(self)), + values = function() FixedSizeListArray__values(self), value_length = function(i) FixedSizeListArray__value_length(self, i), value_offset = function(i) FixedSizeListArray__value_offset(self, i) ), diff --git a/r/R/arrowExports.R b/r/R/arrowExports.R index 5f0c617dfe4..a48d7e6a5cb 100644 --- a/r/R/arrowExports.R +++ b/r/R/arrowExports.R @@ -420,8 +420,8 @@ dataset___FileFormat__DefaultWriteOptions <- function(fmt){ .Call(`_arrow_dataset___FileFormat__DefaultWriteOptions` , fmt) } -dataset___ParquetFileFormat__Make <- function(use_buffered_stream, buffer_size, dict_columns){ - .Call(`_arrow_dataset___ParquetFileFormat__Make` , use_buffered_stream, buffer_size, dict_columns) +dataset___ParquetFileFormat__MakeRead <- function(use_buffered_stream, buffer_size, dict_columns){ + .Call(`_arrow_dataset___ParquetFileFormat__MakeRead` , use_buffered_stream, buffer_size, dict_columns) } dataset___FileWriteOptions__type_name <- function(options){ diff --git a/r/R/compression.R b/r/R/compression.R index 5151b2dc12d..ebd4c54cd82 100644 --- a/r/R/compression.R +++ b/r/R/compression.R @@ -103,7 +103,7 @@ CompressedOutputStream$create <- function(stream, codec = "gzip", compression_le stream <- FileOutputStream$create(stream) } assert_is(stream, "OutputStream") - shared_ptr(CompressedOutputStream, io___CompressedOutputStream__Make(codec, stream)) + io___CompressedOutputStream__Make(codec, stream) } #' @rdname compression @@ -117,5 +117,5 @@ CompressedInputStream$create <- function(stream, codec = "gzip", compression_lev stream <- ReadableFile$create(stream) } assert_is(stream, "InputStream") - shared_ptr(CompressedInputStream, io___CompressedInputStream__Make(codec, stream)) + io___CompressedInputStream__Make(codec, stream) } diff --git a/r/R/dataset-factory.R b/r/R/dataset-factory.R index 088f8def449..c289cf0c8a6 100644 --- a/r/R/dataset-factory.R +++ b/r/R/dataset-factory.R @@ -25,11 +25,10 @@ DatasetFactory <- R6Class("DatasetFactory", inherit = ArrowObject, public = list( Finish = function(schema = NULL, unify_schemas = FALSE) { if (is.null(schema)) { - ptr <- dataset___DatasetFactory__Finish1(self, unify_schemas) + dataset___DatasetFactory__Finish1(self, unify_schemas) } else { - ptr <- dataset___DatasetFactory__Finish2(self, schema) + dataset___DatasetFactory__Finish2(self, schema) } - shared_ptr(Dataset, ptr)$..dispatch() }, Inspect = function(unify_schemas = FALSE) { dataset___DatasetFactory__Inspect(self, unify_schemas) diff --git a/r/R/dataset-format.R b/r/R/dataset-format.R index 8300e415e2c..20e2e970d6c 100644 --- a/r/R/dataset-format.R +++ b/r/R/dataset-format.R @@ -49,20 +49,6 @@ #' @name FileFormat #' @export FileFormat <- R6Class("FileFormat", inherit = ArrowObject, - public = list( - ..dispatch = function() { - type <- self$type - if (type == "parquet") { - shared_ptr(ParquetFileFormat, self$pointer()) - } else if (type == "ipc") { - shared_ptr(IpcFileFormat, self$pointer()) - } else if (type == "csv") { - shared_ptr(CsvFileFormat, self$pointer()) - } else { - self - } - } - ), active = list( # @description # Return the `FileFormat`'s type @@ -78,7 +64,7 @@ FileFormat$create <- function(format, ...) { } else if (format == "parquet") { ParquetFileFormat$create(...) } else if (format %in% c("ipc", "arrow", "feather")) { # These are aliases for the same thing - shared_ptr(IpcFileFormat, dataset___IpcFileFormat__Make()) + dataset___IpcFileFormat__Make() } else { stop("Unsupported file format: ", format, call. = FALSE) } @@ -98,9 +84,16 @@ as.character.FileFormat <- function(x, ...) { ParquetFileFormat <- R6Class("ParquetFileFormat", inherit = FileFormat) ParquetFileFormat$create <- function(use_buffered_stream = FALSE, buffer_size = 8196, - dict_columns = character(0)) { - shared_ptr(ParquetFileFormat, dataset___ParquetFileFormat__Make( - use_buffered_stream, buffer_size, dict_columns)) + dict_columns = character(0), + writer_properties = NULL, + arrow_writer_properties = NULL) { + if (is.null(writer_properties) && is.null(arrow_writer_properties)) { + dataset___ParquetFileFormat__MakeRead(use_buffered_stream, buffer_size, dict_columns) + } else { + writer_properties = writer_properties %||% ParquetWriterProperties$create() + arrow_writer_properties = arrow_writer_properties %||% ParquetArrowWriterProperties$create() + dataset___ParquetFileFormat__MakeWrite(writer_properties, arrow_writer_properties) + } } #' @usage NULL @@ -115,7 +108,7 @@ IpcFileFormat <- R6Class("IpcFileFormat", inherit = FileFormat) #' @export CsvFileFormat <- R6Class("CsvFileFormat", inherit = FileFormat) CsvFileFormat$create <- function(..., opts = csv_file_format_parse_options(...)) { - shared_ptr(CsvFileFormat, dataset___CsvFileFormat__Make(opts)) + dataset___CsvFileFormat__Make(opts) } csv_file_format_parse_options <- function(...) { diff --git a/r/R/dataset.R b/r/R/dataset.R index 19f69d7a4d6..f8d9338d872 100644 --- a/r/R/dataset.R +++ b/r/R/dataset.R @@ -79,7 +79,7 @@ open_dataset <- function(sources, x$schema <- schema x }) - return(shared_ptr(UnionDataset, dataset___UnionDataset__create(sources, schema))) + return(dataset___UnionDataset__create(sources, schema)) } factory <- DatasetFactory$create(sources, partitioning = partitioning, ...) # Default is _not_ to inspect/unify schemas @@ -145,16 +145,6 @@ open_dataset <- function(sources, #' @seealso [open_dataset()] for a simple interface to creating a `Dataset` Dataset <- R6Class("Dataset", inherit = ArrowObject, public = list( - ..dispatch = function() { - type <- self$type - if (type == "union") { - shared_ptr(UnionDataset, self$pointer()) - } else if (type == "filesystem") { - shared_ptr(FileSystemDataset, self$pointer()) - } else { - self - } - }, # @description # Start a new scan of the data # @return A [ScannerBuilder] @@ -167,7 +157,7 @@ Dataset <- R6Class("Dataset", inherit = ArrowObject, dataset___Dataset__schema(self) } else { assert_is(schema, "Schema") - invisible(shared_ptr(Dataset, dataset___Dataset__ReplaceSchema(self, schema))) + invisible(dataset___Dataset__ReplaceSchema(self, schema)) } }, metadata = function() self$schema$metadata, @@ -212,12 +202,12 @@ FileSystemDataset <- R6Class("FileSystemDataset", inherit = Dataset, # @description # Return the format of files in this `Dataset` format = function() { - shared_ptr(FileFormat, dataset___FileSystemDataset__format(self))$..dispatch() + dataset___FileSystemDataset__format(self) }, # @description # Return the filesystem of files in this `Dataset` filesystem = function() { - shared_ptr(FileSystem, dataset___FileSystemDataset__filesystem(self))$..dispatch() + dataset___FileSystemDataset__filesystem(self) }, num_rows = function() { if (inherits(self$format, "ParquetFileFormat")) { @@ -244,7 +234,7 @@ UnionDataset <- R6Class("UnionDataset", inherit = Dataset, # @description # Return the UnionDataset's child `Dataset`s children = function() { - map(dataset___UnionDataset__children(self), ~shared_ptr(Dataset, .)$..dispatch()) + dataset___UnionDataset__children(self) } ) ) @@ -257,7 +247,7 @@ InMemoryDataset$create <- function(x) { if (!inherits(x, "Table")) { x <- Table$create(x) } - shared_ptr(InMemoryDataset, dataset___InMemoryDataset__create(x)) + dataset___InMemoryDataset__create(x) } diff --git a/r/R/dictionary.R b/r/R/dictionary.R index 6273ffc2c87..46fc1049e6a 100644 --- a/r/R/dictionary.R +++ b/r/R/dictionary.R @@ -48,7 +48,7 @@ DictionaryType$create <- function(index_type = int32(), ordered = FALSE) { assert_is(index_type, "DataType") assert_is(value_type, "DataType") - shared_ptr(DictionaryType, DictionaryType__initialize(index_type, value_type, ordered)) + DictionaryType__initialize(index_type, value_type, ordered) } #' Create a dictionary type diff --git a/r/R/filesystem.R b/r/R/filesystem.R index f8b32b8b312..af2432d3e47 100644 --- a/r/R/filesystem.R +++ b/r/R/filesystem.R @@ -108,10 +108,7 @@ FileSelector <- R6Class("FileSelector", ) FileSelector$create <- function(base_dir, allow_not_found = FALSE, recursive = FALSE) { - shared_ptr( - FileSelector, - fs___FileSelector__create(clean_path_rel(base_dir), allow_not_found, recursive) - ) + fs___FileSelector__create(clean_path_rel(base_dir), allow_not_found, recursive) } #' @title FileSystem classes @@ -203,18 +200,6 @@ FileSelector$create <- function(base_dir, allow_not_found = FALSE, recursive = F #' @export FileSystem <- R6Class("FileSystem", inherit = ArrowObject, public = list( - ..dispatch = function() { - type_name <- self$type_name - if (type_name == "local") { - shared_ptr(LocalFileSystem, self$pointer()) - } else if (type_name == "s3") { - shared_ptr(S3FileSystem, self$pointer()) - } else if (type_name == "subtree") { - shared_ptr(SubTreeFileSystem, self$pointer()) - } else { - self - } - }, GetFileInfo = function(x) { if (inherits(x, "FileSelector")) { map( @@ -262,16 +247,16 @@ FileSystem <- R6Class("FileSystem", inherit = ArrowObject, }, OpenInputStream = function(path) { - shared_ptr(InputStream, fs___FileSystem__OpenInputStream(self, clean_path_rel(path))) + fs___FileSystem__OpenInputStream(self, clean_path_rel(path)) }, OpenInputFile = function(path) { - shared_ptr(RandomAccessFile, fs___FileSystem__OpenInputFile(self, clean_path_rel(path))) + fs___FileSystem__OpenInputFile(self, clean_path_rel(path)) }, OpenOutputStream = function(path) { - shared_ptr(OutputStream, fs___FileSystem__OpenOutputStream(self, clean_path_rel(path))) + fs___FileSystem__OpenOutputStream(self, clean_path_rel(path)) }, OpenAppendStream = function(path) { - shared_ptr(OutputStream, fs___FileSystem__OpenAppendStream(self, clean_path_rel(path))) + fs___FileSystem__OpenAppendStream(self, clean_path_rel(path)) }, # Friendlier R user interface @@ -285,6 +270,7 @@ FileSystem <- R6Class("FileSystem", inherit = ArrowObject, # TODO: see fs package for glob/regexp filtering # TODO: verbose method that shows other attributes as df # TODO: print methods for FileInfo, SubTreeFileSystem, S3FileSystem + fs___FileSystem__OpenAppendStream(self, clean_path_rel(path)) } ), active = list( @@ -293,9 +279,7 @@ FileSystem <- R6Class("FileSystem", inherit = ArrowObject, ) FileSystem$from_uri <- function(uri) { assert_that(is.string(uri)) - out <- fs___FileSystemFromUri(uri) - out$fs <- shared_ptr(FileSystem, out$fs)$..dispatch() - out + fs___FileSystemFromUri(uri) } get_path_and_filesystem <- function(x, filesystem = NULL) { @@ -326,7 +310,7 @@ is_url <- function(x) is.string(x) && grepl("://", x) #' @export LocalFileSystem <- R6Class("LocalFileSystem", inherit = FileSystem) LocalFileSystem$create <- function() { - shared_ptr(LocalFileSystem, fs___LocalFileSystem__create()) + fs___LocalFileSystem__create() } #' @usage NULL @@ -369,7 +353,7 @@ S3FileSystem$create <- function(anonymous = FALSE, ...) { } } args <- c(modifyList(default_s3_options, args), anonymous = anonymous) - shared_ptr(S3FileSystem, exec(fs___S3FileSystem__create, !!!args)) + exec(fs___S3FileSystem__create, !!!args) } default_s3_options <- list( @@ -436,10 +420,7 @@ SubTreeFileSystem <- R6Class("SubTreeFileSystem", inherit = FileSystem, ) SubTreeFileSystem$create <- function(base_path, base_fs = NULL) { fs_and_path <- get_path_and_filesystem(base_path, base_fs) - shared_ptr( - SubTreeFileSystem, - fs___SubTreeFileSystem__create(fs_and_path$path, fs_and_path$fs) - ) + fs___SubTreeFileSystem__create(fs_and_path$path, fs_and_path$fs) } #' @export diff --git a/r/R/io.R b/r/R/io.R index 2a6e672e3bf..5f015ce3b06 100644 --- a/r/R/io.R +++ b/r/R/io.R @@ -68,7 +68,7 @@ OutputStream <- R6Class("OutputStream", inherit = Writable, #' @export FileOutputStream <- R6Class("FileOutputStream", inherit = OutputStream) FileOutputStream$create <- function(path) { - shared_ptr(FileOutputStream, io___FileOutputStream__Open(clean_path_abs(path))) + io___FileOutputStream__Open(clean_path_abs(path)) } #' @usage NULL @@ -84,7 +84,7 @@ BufferOutputStream <- R6Class("BufferOutputStream", inherit = OutputStream, ) ) BufferOutputStream$create <- function(initial_capacity = 0L) { - shared_ptr(BufferOutputStream, io___BufferOutputStream__Create(initial_capacity)) + io___BufferOutputStream__Create(initial_capacity) } # InputStream ------------------------------------------------------------- @@ -179,7 +179,7 @@ MemoryMappedFile <- R6Class("MemoryMappedFile", inherit = RandomAccessFile, #' @export ReadableFile <- R6Class("ReadableFile", inherit = RandomAccessFile) ReadableFile$create <- function(path) { - shared_ptr(ReadableFile, io___ReadableFile__Open(clean_path_abs(path))) + io___ReadableFile__Open(clean_path_abs(path)) } #' @usage NULL @@ -189,7 +189,7 @@ ReadableFile$create <- function(path) { BufferReader <- R6Class("BufferReader", inherit = RandomAccessFile) BufferReader$create <- function(x) { x <- buffer(x) - shared_ptr(BufferReader, io___BufferReader__initialize(x)) + io___BufferReader__initialize(x) } #' Create a new read/write memory mapped file of a given size @@ -202,7 +202,7 @@ BufferReader$create <- function(x) { #' @export mmap_create <- function(path, size) { path <- clean_path_abs(path) - shared_ptr(MemoryMappedFile, io___MemoryMappedFile__Create(path, size)) + io___MemoryMappedFile__Create(path, size) } #' Open a memory mapped file @@ -214,7 +214,7 @@ mmap_create <- function(path, size) { mmap_open <- function(path, mode = c("read", "write", "readwrite")) { mode <- match(match.arg(mode), c("read", "write", "readwrite")) - 1L path <- clean_path_abs(path) - shared_ptr(MemoryMappedFile, io___MemoryMappedFile__Open(path, mode)) + io___MemoryMappedFile__Open(path, mode) } #' Handle a range of possible input sources diff --git a/r/R/json.R b/r/R/json.R index d5597fe2a23..7e1ac589dc3 100644 --- a/r/R/json.R +++ b/r/R/json.R @@ -72,10 +72,7 @@ JsonTableReader$create <- function(file, parse_options = JsonParseOptions$create(), ...) { assert_is(file, "InputStream") - shared_ptr( - JsonTableReader, - json___TableReader__Make(file, read_options, parse_options) - ) + json___TableReader__Make(file, read_options, parse_options) } #' @rdname CsvReadOptions @@ -85,7 +82,7 @@ JsonTableReader$create <- function(file, #' @export JsonReadOptions <- R6Class("JsonReadOptions", inherit = ArrowObject) JsonReadOptions$create <- function(use_threads = option_use_threads(), block_size = 1048576L) { - shared_ptr(JsonReadOptions, json___ReadOptions__initialize(use_threads, block_size)) + json___ReadOptions__initialize(use_threads, block_size) } #' @rdname CsvReadOptions @@ -95,5 +92,5 @@ JsonReadOptions$create <- function(use_threads = option_use_threads(), block_siz #' @export JsonParseOptions <- R6Class("JsonParseOptions", inherit = ArrowObject) JsonParseOptions$create <- function(newlines_in_values = FALSE) { - shared_ptr(JsonParseOptions, json___ParseOptions__initialize(newlines_in_values)) + json___ParseOptions__initialize(newlines_in_values) } diff --git a/r/R/record-batch-reader.R b/r/R/record-batch-reader.R index 53f9995b47d..f80df74537d 100644 --- a/r/R/record-batch-reader.R +++ b/r/R/record-batch-reader.R @@ -120,7 +120,7 @@ RecordBatchStreamReader$create <- function(stream) { stream <- BufferReader$create(stream) } assert_is(stream, "InputStream") - shared_ptr(RecordBatchStreamReader, ipc___RecordBatchStreamReader__Open(stream)) + ipc___RecordBatchStreamReader__Open(stream) } #' @rdname RecordBatchReader @@ -150,5 +150,5 @@ RecordBatchFileReader$create <- function(file) { file <- BufferReader$create(file) } assert_is(file, "InputStream") - shared_ptr(RecordBatchFileReader, ipc___RecordBatchFileReader__Open(file)) + ipc___RecordBatchFileReader__Open(file) } diff --git a/r/R/record-batch-writer.R b/r/R/record-batch-writer.R index 8b51603110d..60e87c951dd 100644 --- a/r/R/record-batch-writer.R +++ b/r/R/record-batch-writer.R @@ -133,13 +133,11 @@ RecordBatchStreamWriter$create <- function(sink, assert_is(sink, "OutputStream") assert_is(schema, "Schema") - shared_ptr(RecordBatchStreamWriter, - ipc___RecordBatchStreamWriter__Open( - sink, - schema, - get_ipc_use_legacy_format(use_legacy_format), - get_ipc_metadata_version(metadata_version) - ) + ipc___RecordBatchStreamWriter__Open( + sink, + schema, + get_ipc_use_legacy_format(use_legacy_format), + get_ipc_metadata_version(metadata_version) ) } @@ -162,13 +160,11 @@ RecordBatchFileWriter$create <- function(sink, assert_is(sink, "OutputStream") assert_is(schema, "Schema") - shared_ptr(RecordBatchFileWriter, - ipc___RecordBatchFileWriter__Open( - sink, - schema, - get_ipc_use_legacy_format(use_legacy_format), - get_ipc_metadata_version(metadata_version) - ) + ipc___RecordBatchFileWriter__Open( + sink, + schema, + get_ipc_use_legacy_format(use_legacy_format), + get_ipc_metadata_version(metadata_version) ) } diff --git a/r/R/record-batch.R b/r/R/record-batch.R index 6967b1db8d2..5c87b6c6d8c 100644 --- a/r/R/record-batch.R +++ b/r/R/record-batch.R @@ -72,7 +72,7 @@ #' @name RecordBatch RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, public = list( - column = function(i) shared_ptr(Array, RecordBatch__column(self, i)), + column = function(i) RecordBatch__column(self, i), column_name = function(i) RecordBatch__column_name(self, i), names = function() RecordBatch__names(self), Equals = function(other, check_metadata = FALSE, ...) { @@ -80,7 +80,7 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, }, GetColumnByName = function(name) { assert_that(is.string(name)) - shared_ptr(Array, RecordBatch__GetColumnByName(self, name)) + RecordBatch__GetColumnByName(self, name) }, SelectColumns = function(indices) { RecordBatch__SelectColumns(self, indices) diff --git a/r/R/scalar.R b/r/R/scalar.R index f387fb13a48..871e19e0571 100644 --- a/r/R/scalar.R +++ b/r/R/scalar.R @@ -31,17 +31,9 @@ Scalar <- R6Class("Scalar", inherit = ArrowObject, # TODO: document the methods public = list( - ..dispatch = function() { - type_id <- self$type$id - if (type_id == Type$STRUCT) { - shared_ptr(StructScalar, self$pointer()) - } else { - self - } - }, ToString = function() Scalar__ToString(self), cast = function(target_type) { - Scalar$create(Scalar__CastTo(self, as_type(target_type))) + Scalar__CastTo(self, as_type(target_type)) }, as_vector = function() Scalar__as_vector(self) ), @@ -52,16 +44,13 @@ Scalar <- R6Class("Scalar", ) ) Scalar$create <- function(x, type = NULL) { - if (!inherits(x, "externalptr")) { - if (is.null(x)) { - x <- vctrs::unspecified(1) - } else if (length(x) != 1 && !is.data.frame(x)) { - # Wrap in a list type - x <- list(x) - } - x <- Array__GetScalar(Array$create(x, type = type), 0) + if (is.null(x)) { + x <- vctrs::unspecified(1) + } else if (length(x) != 1 && !is.data.frame(x)) { + # Wrap in a list type + x <- list(x) } - shared_ptr(Scalar, x)$..dispatch() + Array__GetScalar(Array$create(x, type = type), 0) } #' @rdname array @@ -71,8 +60,8 @@ Scalar$create <- function(x, type = NULL) { StructScalar <- R6Class("StructScalar", inherit = Scalar, public = list( - field = function(i) Scalar$create(StructScalar__field(self, i)), - GetFieldByName = function(name) Scalar$create(StructScalar__GetFieldByName(self, name)) + field = function(i) StructScalar__field(self, i), + GetFieldByName = function(name) StructScalar__GetFieldByName(self, name) ) ) diff --git a/r/src/array.cpp b/r/src/array.cpp index 844ac2a704d..e715781095e 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -22,6 +22,29 @@ #include #include +namespace cpp11 { +R6 r6_Array(const std::shared_ptr& array) { + using arrow::Type; + + auto type = array->type_id(); + switch (type) { + case Type::DICTIONARY: + return cpp11::r6(array, "DictionaryArray"); + case Type::STRUCT: + return cpp11::r6(array, "StructArray"); + case Type::LIST: + return cpp11::r6(array, "ListArray"); + case Type::LARGE_LIST: + return cpp11::r6(array, "LargeListArray"); + case Type::FIXED_SIZE_LIST: + return cpp11::r6(array, "FixedSizeListArray"); + + default: + return cpp11::r6(array, "Array"); + } +} +} // namespace cpp11 + void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) { if (offset == NA_INTEGER) { cpp11::stop("Slice 'offset' cannot be NA"); @@ -47,18 +70,17 @@ void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) { } // [[arrow::export]] -std::shared_ptr Array__Slice1(const std::shared_ptr& array, - R_xlen_t offset) { +R6 Array__Slice1(const std::shared_ptr& array, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, array->length()); - return array->Slice(offset); + return cpp11::r6_Array(array->Slice(offset)); } // [[arrow::export]] -std::shared_ptr Array__Slice2(const std::shared_ptr& array, - R_xlen_t offset, R_xlen_t length) { +R6 Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, + R_xlen_t length) { arrow::r::validate_slice_offset(offset, array->length()); arrow::r::validate_slice_length(length, array->length() - offset); - return array->Slice(offset, length); + return cpp11::r6_Array(array->Slice(offset, length)); } void arrow::r::validate_index(int i, int len) { @@ -119,9 +141,8 @@ bool Array__ApproxEquals(const std::shared_ptr& lhs, } // [[arrow::export]] -std::shared_ptr Array__data( - const std::shared_ptr& array) { - return array->data(); +R6 Array__data(const std::shared_ptr& array) { + return cpp11::r6(array->data(), "ArrayData"); } // [[arrow::export]] @@ -141,9 +162,9 @@ bool Array__RangeEquals(const std::shared_ptr& self, } // [[arrow::export]] -std::shared_ptr Array__View(const std::shared_ptr& array, - const std::shared_ptr& type) { - return ValueOrStop(array->View(type)); +R6 Array__View(const std::shared_ptr& array, + const std::shared_ptr& type) { + return cpp11::r6_Array(ValueOrStop(array->View(type))); } // [[arrow::export]] @@ -152,27 +173,24 @@ void Array__Validate(const std::shared_ptr& array) { } // [[arrow::export]] -std::shared_ptr DictionaryArray__indices( - const std::shared_ptr& array) { - return array->indices(); +R6 DictionaryArray__indices(const std::shared_ptr& array) { + return cpp11::r6_Array(array->indices()); } // [[arrow::export]] -std::shared_ptr DictionaryArray__dictionary( - const std::shared_ptr& array) { - return array->dictionary(); +R6 DictionaryArray__dictionary(const std::shared_ptr& array) { + return cpp11::r6_Array(array->dictionary()); } // [[arrow::export]] -std::shared_ptr StructArray__field( - const std::shared_ptr& array, int i) { - return array->field(i); +R6 StructArray__field(const std::shared_ptr& array, int i) { + return cpp11::r6_Array(array->field(i)); } // [[arrow::export]] -std::shared_ptr StructArray__GetFieldByName( - const std::shared_ptr& array, const std::string& name) { - return array->GetFieldByName(name); +R6 StructArray__GetFieldByName(const std::shared_ptr& array, + const std::string& name) { + return cpp11::r6_Array(array->GetFieldByName(name)); } // [[arrow::export]] @@ -194,15 +212,13 @@ std::shared_ptr LargeListArray__value_type( } // [[arrow::export]] -std::shared_ptr ListArray__values( - const std::shared_ptr& array) { - return array->values(); +R6 ListArray__values(const std::shared_ptr& array) { + return cpp11::r6_Array(array->values()); } // [[arrow::export]] -std::shared_ptr LargeListArray__values( - const std::shared_ptr& array) { - return array->values(); +R6 LargeListArray__values(const std::shared_ptr& array) { + return cpp11::r6_Array(array->values()); } // [[arrow::export]] diff --git a/r/src/array_from_vector.cpp b/r/src/array_from_vector.cpp index c2d22868535..dacf9272bc8 100644 --- a/r/src/array_from_vector.cpp +++ b/r/src/array_from_vector.cpp @@ -1548,8 +1548,7 @@ std::shared_ptr Array__from_vector(SEXP x, SEXP s_type) { } // [[arrow::export]] -std::shared_ptr ChunkedArray__from_list(cpp11::list chunks, - SEXP s_type) { +R6 ChunkedArray__from_list(cpp11::list chunks, SEXP s_type) { std::vector> vec; // the type might be NULL, in which case we need to infer it from the data @@ -1585,15 +1584,16 @@ std::shared_ptr ChunkedArray__from_list(cpp11::list chunks, } } - return std::make_shared(std::move(vec)); + auto array = std::make_shared(std::move(vec)); + return cpp11::r6(array, "ChunkedArray"); } // [[arrow::export]] -std::shared_ptr DictionaryArray__FromArrays( - const std::shared_ptr& type, - const std::shared_ptr& indices, - const std::shared_ptr& dict) { - return ValueOrStop(arrow::DictionaryArray::FromArrays(type, indices, dict)); +R6 DictionaryArray__FromArrays(const std::shared_ptr& type, + const std::shared_ptr& indices, + const std::shared_ptr& dict) { + auto array = ValueOrStop(arrow::DictionaryArray::FromArrays(type, indices, dict)); + return cpp11::r6(array, "DictionaryArray"); } #endif diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index add7b9b6178..a91873c95c2 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -6,7 +6,7 @@ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__Slice1(const std::shared_ptr& array, R_xlen_t offset); +R6 Array__Slice1(const std::shared_ptr& array, R_xlen_t offset); extern "C" SEXP _arrow_Array__Slice1(SEXP array_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -22,7 +22,7 @@ extern "C" SEXP _arrow_Array__Slice1(SEXP array_sexp, SEXP offset_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, R_xlen_t length); +R6 Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_Array__Slice2(SEXP array_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -193,7 +193,7 @@ extern "C" SEXP _arrow_Array__ApproxEquals(SEXP lhs_sexp, SEXP rhs_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__data(const std::shared_ptr& array); +R6 Array__data(const std::shared_ptr& array); extern "C" SEXP _arrow_Array__data(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -227,7 +227,7 @@ extern "C" SEXP _arrow_Array__RangeEquals(SEXP self_sexp, SEXP other_sexp, SEXP // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__View(const std::shared_ptr& array, const std::shared_ptr& type); +R6 Array__View(const std::shared_ptr& array, const std::shared_ptr& type); extern "C" SEXP _arrow_Array__View(SEXP array_sexp, SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -259,7 +259,7 @@ extern "C" SEXP _arrow_Array__Validate(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr DictionaryArray__indices(const std::shared_ptr& array); +R6 DictionaryArray__indices(const std::shared_ptr& array); extern "C" SEXP _arrow_DictionaryArray__indices(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -274,7 +274,7 @@ extern "C" SEXP _arrow_DictionaryArray__indices(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr DictionaryArray__dictionary(const std::shared_ptr& array); +R6 DictionaryArray__dictionary(const std::shared_ptr& array); extern "C" SEXP _arrow_DictionaryArray__dictionary(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -289,7 +289,7 @@ extern "C" SEXP _arrow_DictionaryArray__dictionary(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr StructArray__field(const std::shared_ptr& array, int i); +R6 StructArray__field(const std::shared_ptr& array, int i); extern "C" SEXP _arrow_StructArray__field(SEXP array_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -305,7 +305,7 @@ extern "C" SEXP _arrow_StructArray__field(SEXP array_sexp, SEXP i_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr StructArray__GetFieldByName(const std::shared_ptr& array, const std::string& name); +R6 StructArray__GetFieldByName(const std::shared_ptr& array, const std::string& name); extern "C" SEXP _arrow_StructArray__GetFieldByName(SEXP array_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -366,7 +366,7 @@ extern "C" SEXP _arrow_LargeListArray__value_type(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ListArray__values(const std::shared_ptr& array); +R6 ListArray__values(const std::shared_ptr& array); extern "C" SEXP _arrow_ListArray__values(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -381,7 +381,7 @@ extern "C" SEXP _arrow_ListArray__values(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr LargeListArray__values(const std::shared_ptr& array); +R6 LargeListArray__values(const std::shared_ptr& array); extern "C" SEXP _arrow_LargeListArray__values(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -553,7 +553,7 @@ extern "C" SEXP _arrow_Array__from_vector(SEXP x_sexp, SEXP s_type_sexp){ // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__from_list(cpp11::list chunks, SEXP s_type); +R6 ChunkedArray__from_list(cpp11::list chunks, SEXP s_type); extern "C" SEXP _arrow_ChunkedArray__from_list(SEXP chunks_sexp, SEXP s_type_sexp){ BEGIN_CPP11 arrow::r::Input::type chunks(chunks_sexp); @@ -569,7 +569,7 @@ extern "C" SEXP _arrow_ChunkedArray__from_list(SEXP chunks_sexp, SEXP s_type_sex // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr DictionaryArray__FromArrays(const std::shared_ptr& type, const std::shared_ptr& indices, const std::shared_ptr& dict); +R6 DictionaryArray__FromArrays(const std::shared_ptr& type, const std::shared_ptr& indices, const std::shared_ptr& dict); extern "C" SEXP _arrow_DictionaryArray__FromArrays(SEXP type_sexp, SEXP indices_sexp, SEXP dict_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -784,7 +784,7 @@ extern "C" SEXP _arrow_Buffer__size(SEXP buffer_sexp){ // buffer.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr r___RBuffer__initialize(SEXP x); +R6 r___RBuffer__initialize(SEXP x); extern "C" SEXP _arrow_r___RBuffer__initialize(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -875,7 +875,7 @@ extern "C" SEXP _arrow_ChunkedArray__num_chunks(SEXP chunked_array_sexp){ // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i); +R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i); extern "C" SEXP _arrow_ChunkedArray__chunk(SEXP chunked_array_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -921,7 +921,7 @@ extern "C" SEXP _arrow_ChunkedArray__type(SEXP chunked_array_sexp){ // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__Slice1(const std::shared_ptr& chunked_array, R_xlen_t offset); +R6 ChunkedArray__Slice1(const std::shared_ptr& chunked_array, R_xlen_t offset); extern "C" SEXP _arrow_ChunkedArray__Slice1(SEXP chunked_array_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -937,7 +937,7 @@ extern "C" SEXP _arrow_ChunkedArray__Slice1(SEXP chunked_array_sexp, SEXP offset // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__Slice2(const std::shared_ptr& chunked_array, R_xlen_t offset, R_xlen_t length); +R6 ChunkedArray__Slice2(const std::shared_ptr& chunked_array, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_ChunkedArray__Slice2(SEXP chunked_array_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -954,7 +954,7 @@ extern "C" SEXP _arrow_ChunkedArray__Slice2(SEXP chunked_array_sexp, SEXP offset // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__View(const std::shared_ptr& array, const std::shared_ptr& type); +R6 ChunkedArray__View(const std::shared_ptr& array, const std::shared_ptr& type); extern "C" SEXP _arrow_ChunkedArray__View(SEXP array_sexp, SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -1017,7 +1017,7 @@ extern "C" SEXP _arrow_ChunkedArray__ToString(SEXP x_sexp){ // compression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level); +R6 util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level); extern "C" SEXP _arrow_util___Codec__Create(SEXP codec_sexp, SEXP compression_level_sexp){ BEGIN_CPP11 arrow::r::Input::type codec(codec_sexp); @@ -1063,7 +1063,7 @@ extern "C" SEXP _arrow_util___Codec__IsAvailable(SEXP codec_sexp){ // compression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___CompressedOutputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); +R6 io___CompressedOutputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); extern "C" SEXP _arrow_io___CompressedOutputStream__Make(SEXP codec_sexp, SEXP raw_sexp){ BEGIN_CPP11 arrow::r::Input&>::type codec(codec_sexp); @@ -1079,7 +1079,7 @@ extern "C" SEXP _arrow_io___CompressedOutputStream__Make(SEXP codec_sexp, SEXP r // compression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___CompressedInputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); +R6 io___CompressedInputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); extern "C" SEXP _arrow_io___CompressedInputStream__Make(SEXP codec_sexp, SEXP raw_sexp){ BEGIN_CPP11 arrow::r::Input&>::type codec(codec_sexp); @@ -1095,7 +1095,7 @@ extern "C" SEXP _arrow_io___CompressedInputStream__Make(SEXP codec_sexp, SEXP ra // compute.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_truncate, bool allow_float_truncate); +R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_truncate, bool allow_float_truncate); extern "C" SEXP _arrow_compute___CastOptions__initialize(SEXP allow_int_overflow_sexp, SEXP allow_time_truncate_sexp, SEXP allow_float_truncate_sexp){ BEGIN_CPP11 arrow::r::Input::type allow_int_overflow(allow_int_overflow_sexp); @@ -1112,7 +1112,7 @@ extern "C" SEXP _arrow_compute___CastOptions__initialize(SEXP allow_int_overflow // compute.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__cast(const std::shared_ptr& array, const std::shared_ptr& target_type, const std::shared_ptr& options); +R6 Array__cast(const std::shared_ptr& array, const std::shared_ptr& target_type, const std::shared_ptr& options); extern "C" SEXP _arrow_Array__cast(SEXP array_sexp, SEXP target_type_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -1129,7 +1129,7 @@ extern "C" SEXP _arrow_Array__cast(SEXP array_sexp, SEXP target_type_sexp, SEXP // compute.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__cast(const std::shared_ptr& chunked_array, const std::shared_ptr& target_type, const std::shared_ptr& options); +R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, const std::shared_ptr& target_type, const std::shared_ptr& options); extern "C" SEXP _arrow_ChunkedArray__cast(SEXP chunked_array_sexp, SEXP target_type_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -1146,7 +1146,7 @@ extern "C" SEXP _arrow_ChunkedArray__cast(SEXP chunked_array_sexp, SEXP target_t // compute.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__cast(const std::shared_ptr& batch, const std::shared_ptr& schema, const std::shared_ptr& options); +R6 RecordBatch__cast(const std::shared_ptr& batch, const std::shared_ptr& schema, const std::shared_ptr& options); extern "C" SEXP _arrow_RecordBatch__cast(SEXP batch_sexp, SEXP schema_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -1163,7 +1163,7 @@ extern "C" SEXP _arrow_RecordBatch__cast(SEXP batch_sexp, SEXP schema_sexp, SEXP // compute.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__cast(const std::shared_ptr& table, const std::shared_ptr& schema, const std::shared_ptr& options); +R6 Table__cast(const std::shared_ptr& table, const std::shared_ptr& schema, const std::shared_ptr& options); extern "C" SEXP _arrow_Table__cast(SEXP table_sexp, SEXP schema_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -1197,7 +1197,7 @@ extern "C" SEXP _arrow_compute__CallFunction(SEXP func_name_sexp, SEXP args_sexp // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr csv___ReadOptions__initialize(cpp11::list options); +R6 csv___ReadOptions__initialize(cpp11::list options); extern "C" SEXP _arrow_csv___ReadOptions__initialize(SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input::type options(options_sexp); @@ -1212,7 +1212,7 @@ extern "C" SEXP _arrow_csv___ReadOptions__initialize(SEXP options_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr csv___ParseOptions__initialize(cpp11::list options); +R6 csv___ParseOptions__initialize(cpp11::list options); extern "C" SEXP _arrow_csv___ParseOptions__initialize(SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input::type options(options_sexp); @@ -1242,7 +1242,7 @@ extern "C" SEXP _arrow_csv___ReadOptions__column_names(SEXP options_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr csv___ConvertOptions__initialize(cpp11::list options); +R6 csv___ConvertOptions__initialize(cpp11::list options); extern "C" SEXP _arrow_csv___ConvertOptions__initialize(SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input::type options(options_sexp); @@ -1257,7 +1257,7 @@ extern "C" SEXP _arrow_csv___ConvertOptions__initialize(SEXP options_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr csv___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options); +R6 csv___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options); extern "C" SEXP _arrow_csv___TableReader__Make(SEXP input_sexp, SEXP read_options_sexp, SEXP parse_options_sexp, SEXP convert_options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type input(input_sexp); @@ -1275,7 +1275,7 @@ extern "C" SEXP _arrow_csv___TableReader__Make(SEXP input_sexp, SEXP read_option // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr csv___TableReader__Read(const std::shared_ptr& table_reader); +R6 csv___TableReader__Read(const std::shared_ptr& table_reader); extern "C" SEXP _arrow_csv___TableReader__Read(SEXP table_reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table_reader(table_reader_sexp); @@ -1349,7 +1349,7 @@ extern "C" SEXP _arrow_TimestampParser__MakeISO8601(){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___Dataset__NewScan(const std::shared_ptr& ds); +R6 dataset___Dataset__NewScan(const std::shared_ptr& ds); extern "C" SEXP _arrow_dataset___Dataset__NewScan(SEXP ds_sexp){ BEGIN_CPP11 arrow::r::Input&>::type ds(ds_sexp); @@ -1364,7 +1364,7 @@ extern "C" SEXP _arrow_dataset___Dataset__NewScan(SEXP ds_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___Dataset__schema(const std::shared_ptr& dataset); +R6 dataset___Dataset__schema(const std::shared_ptr& dataset); extern "C" SEXP _arrow_dataset___Dataset__schema(SEXP dataset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1394,7 +1394,7 @@ extern "C" SEXP _arrow_dataset___Dataset__type_name(SEXP dataset_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, const std::shared_ptr& schm); +R6 dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___Dataset__ReplaceSchema(SEXP dataset_sexp, SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1410,7 +1410,7 @@ extern "C" SEXP _arrow_dataset___Dataset__ReplaceSchema(SEXP dataset_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___UnionDataset__create(const ds::DatasetVector& datasets, const std::shared_ptr& schm); +R6 dataset___UnionDataset__create(const ds::DatasetVector& datasets, const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___UnionDataset__create(SEXP datasets_sexp, SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input::type datasets(datasets_sexp); @@ -1426,7 +1426,7 @@ extern "C" SEXP _arrow_dataset___UnionDataset__create(SEXP datasets_sexp, SEXP s // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___InMemoryDataset__create(const std::shared_ptr& table); +R6 dataset___InMemoryDataset__create(const std::shared_ptr& table); extern "C" SEXP _arrow_dataset___InMemoryDataset__create(SEXP table_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -1456,7 +1456,7 @@ extern "C" SEXP _arrow_dataset___UnionDataset__children(SEXP ds_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDataset__format(const std::shared_ptr& dataset); +R6 dataset___FileSystemDataset__format(const std::shared_ptr& dataset); extern "C" SEXP _arrow_dataset___FileSystemDataset__format(SEXP dataset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1471,7 +1471,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDataset__format(SEXP dataset_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDataset__filesystem(const std::shared_ptr& dataset); +R6 dataset___FileSystemDataset__filesystem(const std::shared_ptr& dataset); extern "C" SEXP _arrow_dataset___FileSystemDataset__filesystem(SEXP dataset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1501,7 +1501,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDataset__files(SEXP dataset_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___DatasetFactory__Finish1(const std::shared_ptr& factory, bool unify_schemas); +R6 dataset___DatasetFactory__Finish1(const std::shared_ptr& factory, bool unify_schemas); extern "C" SEXP _arrow_dataset___DatasetFactory__Finish1(SEXP factory_sexp, SEXP unify_schemas_sexp){ BEGIN_CPP11 arrow::r::Input&>::type factory(factory_sexp); @@ -1517,7 +1517,7 @@ extern "C" SEXP _arrow_dataset___DatasetFactory__Finish1(SEXP factory_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, const std::shared_ptr& schema); +R6 dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, const std::shared_ptr& schema); extern "C" SEXP _arrow_dataset___DatasetFactory__Finish2(SEXP factory_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type factory(factory_sexp); @@ -1533,7 +1533,7 @@ extern "C" SEXP _arrow_dataset___DatasetFactory__Finish2(SEXP factory_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___DatasetFactory__Inspect(const std::shared_ptr& factory, bool unify_schemas); +R6 dataset___DatasetFactory__Inspect(const std::shared_ptr& factory, bool unify_schemas); extern "C" SEXP _arrow_dataset___DatasetFactory__Inspect(SEXP factory_sexp, SEXP unify_schemas_sexp){ BEGIN_CPP11 arrow::r::Input&>::type factory(factory_sexp); @@ -1549,7 +1549,7 @@ extern "C" SEXP _arrow_dataset___DatasetFactory__Inspect(SEXP factory_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___UnionDatasetFactory__Make(const std::vector>& children); +R6 dataset___UnionDatasetFactory__Make(const std::vector>& children); extern "C" SEXP _arrow_dataset___UnionDatasetFactory__Make(SEXP children_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type children(children_sexp); @@ -1564,7 +1564,7 @@ extern "C" SEXP _arrow_dataset___UnionDatasetFactory__Make(SEXP children_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDatasetFactory__Make2(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& partitioning); +R6 dataset___FileSystemDatasetFactory__Make2(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& partitioning); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make2(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp, SEXP partitioning_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1582,7 +1582,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make2(SEXP fs_sexp, S // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDatasetFactory__Make1(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format); +R6 dataset___FileSystemDatasetFactory__Make1(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make1(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1599,7 +1599,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make1(SEXP fs_sexp, S // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDatasetFactory__Make3(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& factory); +R6 dataset___FileSystemDatasetFactory__Make3(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& factory); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make3(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp, SEXP factory_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1632,7 +1632,7 @@ extern "C" SEXP _arrow_dataset___FileFormat__type_name(SEXP format_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt); +R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt); extern "C" SEXP _arrow_dataset___FileFormat__DefaultWriteOptions(SEXP fmt_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fmt(fmt_sexp); @@ -1647,18 +1647,18 @@ extern "C" SEXP _arrow_dataset___FileFormat__DefaultWriteOptions(SEXP fmt_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___ParquetFileFormat__Make(bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns); -extern "C" SEXP _arrow_dataset___ParquetFileFormat__Make(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ +R6 dataset___ParquetFileFormat__MakeRead(bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns); +extern "C" SEXP _arrow_dataset___ParquetFileFormat__MakeRead(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ BEGIN_CPP11 arrow::r::Input::type use_buffered_stream(use_buffered_stream_sexp); arrow::r::Input::type buffer_size(buffer_size_sexp); arrow::r::Input::type dict_columns(dict_columns_sexp); - return cpp11::as_sexp(dataset___ParquetFileFormat__Make(use_buffered_stream, buffer_size, dict_columns)); + return cpp11::as_sexp(dataset___ParquetFileFormat__MakeRead(use_buffered_stream, buffer_size, dict_columns)); END_CPP11 } #else -extern "C" SEXP _arrow_dataset___ParquetFileFormat__Make(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ - Rf_error("Cannot call dataset___ParquetFileFormat__Make(). Please use arrow::install_arrow() to install required runtime libraries. "); +extern "C" SEXP _arrow_dataset___ParquetFileFormat__MakeRead(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ + Rf_error("Cannot call dataset___ParquetFileFormat__MakeRead(). Please use arrow::install_arrow() to install required runtime libraries. "); } #endif @@ -1734,7 +1734,7 @@ extern "C" SEXP _arrow_dataset___IpcFileWriteOptions__update1(SEXP ipc_options_s // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___IpcFileFormat__Make(); +R6 dataset___IpcFileFormat__Make(); extern "C" SEXP _arrow_dataset___IpcFileFormat__Make(){ BEGIN_CPP11 return cpp11::as_sexp(dataset___IpcFileFormat__Make()); @@ -1748,7 +1748,7 @@ extern "C" SEXP _arrow_dataset___IpcFileFormat__Make(){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___CsvFileFormat__Make(const std::shared_ptr& parse_options); +R6 dataset___CsvFileFormat__Make(const std::shared_ptr& parse_options); extern "C" SEXP _arrow_dataset___CsvFileFormat__Make(SEXP parse_options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type parse_options(parse_options_sexp); @@ -1763,7 +1763,7 @@ extern "C" SEXP _arrow_dataset___CsvFileFormat__Make(SEXP parse_options_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___DirectoryPartitioning(const std::shared_ptr& schm); +R6 dataset___DirectoryPartitioning(const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___DirectoryPartitioning(SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schm(schm_sexp); @@ -1778,7 +1778,7 @@ extern "C" SEXP _arrow_dataset___DirectoryPartitioning(SEXP schm_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___DirectoryPartitioning__MakeFactory(const std::vector& field_names); +R6 dataset___DirectoryPartitioning__MakeFactory(const std::vector& field_names); extern "C" SEXP _arrow_dataset___DirectoryPartitioning__MakeFactory(SEXP field_names_sexp){ BEGIN_CPP11 arrow::r::Input&>::type field_names(field_names_sexp); @@ -1793,7 +1793,7 @@ extern "C" SEXP _arrow_dataset___DirectoryPartitioning__MakeFactory(SEXP field_n // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___HivePartitioning(const std::shared_ptr& schm); +R6 dataset___HivePartitioning(const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___HivePartitioning(SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schm(schm_sexp); @@ -1808,7 +1808,7 @@ extern "C" SEXP _arrow_dataset___HivePartitioning(SEXP schm_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___HivePartitioning__MakeFactory(); +R6 dataset___HivePartitioning__MakeFactory(); extern "C" SEXP _arrow_dataset___HivePartitioning__MakeFactory(){ BEGIN_CPP11 return cpp11::as_sexp(dataset___HivePartitioning__MakeFactory()); @@ -1890,7 +1890,7 @@ extern "C" SEXP _arrow_dataset___ScannerBuilder__BatchSize(SEXP sb_sexp, SEXP ba // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___ScannerBuilder__schema(const std::shared_ptr& sb); +R6 dataset___ScannerBuilder__schema(const std::shared_ptr& sb); extern "C" SEXP _arrow_dataset___ScannerBuilder__schema(SEXP sb_sexp){ BEGIN_CPP11 arrow::r::Input&>::type sb(sb_sexp); @@ -1905,7 +1905,7 @@ extern "C" SEXP _arrow_dataset___ScannerBuilder__schema(SEXP sb_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___ScannerBuilder__Finish(const std::shared_ptr& sb); +R6 dataset___ScannerBuilder__Finish(const std::shared_ptr& sb); extern "C" SEXP _arrow_dataset___ScannerBuilder__Finish(SEXP sb_sexp){ BEGIN_CPP11 arrow::r::Input&>::type sb(sb_sexp); @@ -1920,7 +1920,7 @@ extern "C" SEXP _arrow_dataset___ScannerBuilder__Finish(SEXP sb_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___Scanner__ToTable(const std::shared_ptr& scanner); +R6 dataset___Scanner__ToTable(const std::shared_ptr& scanner); extern "C" SEXP _arrow_dataset___Scanner__ToTable(SEXP scanner_sexp){ BEGIN_CPP11 arrow::r::Input&>::type scanner(scanner_sexp); @@ -1935,7 +1935,7 @@ extern "C" SEXP _arrow_dataset___Scanner__ToTable(SEXP scanner_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___Scanner__head(const std::shared_ptr& scanner, int n); +R6 dataset___Scanner__head(const std::shared_ptr& scanner, int n); extern "C" SEXP _arrow_dataset___Scanner__head(SEXP scanner_sexp, SEXP n_sexp){ BEGIN_CPP11 arrow::r::Input&>::type scanner(scanner_sexp); @@ -2662,7 +2662,7 @@ extern "C" SEXP _arrow_TimestampType__unit(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr DictionaryType__initialize(const std::shared_ptr& index_type, const std::shared_ptr& value_type, bool ordered); +R6 DictionaryType__initialize(const std::shared_ptr& index_type, const std::shared_ptr& value_type, bool ordered); extern "C" SEXP _arrow_DictionaryType__initialize(SEXP index_type_sexp, SEXP value_type_sexp, SEXP ordered_sexp){ BEGIN_CPP11 arrow::r::Input&>::type index_type(index_type_sexp); @@ -2739,7 +2739,7 @@ extern "C" SEXP _arrow_DictionaryType__ordered(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr StructType__GetFieldByName(const std::shared_ptr& type, const std::string& name); +R6 StructType__GetFieldByName(const std::shared_ptr& type, const std::string& name); extern "C" SEXP _arrow_StructType__GetFieldByName(SEXP type_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2771,7 +2771,7 @@ extern "C" SEXP _arrow_StructType__GetFieldIndex(SEXP type_sexp, SEXP name_sexp) // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ListType__value_field(const std::shared_ptr& type); +R6 ListType__value_field(const std::shared_ptr& type); extern "C" SEXP _arrow_ListType__value_field(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2801,7 +2801,7 @@ extern "C" SEXP _arrow_ListType__value_type(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr LargeListType__value_field(const std::shared_ptr& type); +R6 LargeListType__value_field(const std::shared_ptr& type); extern "C" SEXP _arrow_LargeListType__value_field(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2831,7 +2831,7 @@ extern "C" SEXP _arrow_LargeListType__value_type(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr FixedSizeListType__value_field(const std::shared_ptr& type); +R6 FixedSizeListType__value_field(const std::shared_ptr& type); extern "C" SEXP _arrow_FixedSizeListType__value_field(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2876,7 +2876,7 @@ extern "C" SEXP _arrow_FixedSizeListType__list_size(SEXP type_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__field_ref(std::string name); +R6 dataset___expr__field_ref(std::string name); extern "C" SEXP _arrow_dataset___expr__field_ref(SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input::type name(name_sexp); @@ -2891,7 +2891,7 @@ extern "C" SEXP _arrow_dataset___expr__field_ref(SEXP name_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2907,7 +2907,7 @@ extern "C" SEXP _arrow_dataset___expr__equal(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__not_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__not_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__not_equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2923,7 +2923,7 @@ extern "C" SEXP _arrow_dataset___expr__not_equal(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__greater(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__greater(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__greater(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2939,7 +2939,7 @@ extern "C" SEXP _arrow_dataset___expr__greater(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__greater_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__greater_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__greater_equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2955,7 +2955,7 @@ extern "C" SEXP _arrow_dataset___expr__greater_equal(SEXP lhs_sexp, SEXP rhs_sex // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__less(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__less(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__less(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2971,7 +2971,7 @@ extern "C" SEXP _arrow_dataset___expr__less(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__less_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__less_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__less_equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2987,7 +2987,7 @@ extern "C" SEXP _arrow_dataset___expr__less_equal(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__in(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__in(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__in(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3003,7 +3003,7 @@ extern "C" SEXP _arrow_dataset___expr__in(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__and(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__and(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__and(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3019,7 +3019,7 @@ extern "C" SEXP _arrow_dataset___expr__and(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__or(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +R6 dataset___expr__or(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__or(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3035,7 +3035,7 @@ extern "C" SEXP _arrow_dataset___expr__or(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__not(const std::shared_ptr& lhs); +R6 dataset___expr__not(const std::shared_ptr& lhs); extern "C" SEXP _arrow_dataset___expr__not(SEXP lhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3050,7 +3050,7 @@ extern "C" SEXP _arrow_dataset___expr__not(SEXP lhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__is_valid(const std::shared_ptr& lhs); +R6 dataset___expr__is_valid(const std::shared_ptr& lhs); extern "C" SEXP _arrow_dataset___expr__is_valid(SEXP lhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3065,7 +3065,7 @@ extern "C" SEXP _arrow_dataset___expr__is_valid(SEXP lhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___expr__scalar(const std::shared_ptr& x); +R6 dataset___expr__scalar(const std::shared_ptr& x); extern "C" SEXP _arrow_dataset___expr__scalar(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3131,7 +3131,7 @@ extern "C" SEXP _arrow_ipc___feather___Reader__version(SEXP reader_sexp){ // feather.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___feather___Reader__Read(const std::shared_ptr& reader, SEXP columns); +R6 ipc___feather___Reader__Read(const std::shared_ptr& reader, SEXP columns); extern "C" SEXP _arrow_ipc___feather___Reader__Read(SEXP reader_sexp, SEXP columns_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -3147,7 +3147,7 @@ extern "C" SEXP _arrow_ipc___feather___Reader__Read(SEXP reader_sexp, SEXP colum // feather.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___feather___Reader__Open(const std::shared_ptr& stream); +R6 ipc___feather___Reader__Open(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___feather___Reader__Open(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -3177,7 +3177,7 @@ extern "C" SEXP _arrow_ipc___feather___Reader__column_names(SEXP reader_sexp){ // field.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Field__initialize(const std::string& name, const std::shared_ptr& field, bool nullable); +R6 Field__initialize(const std::string& name, const std::shared_ptr& field, bool nullable); extern "C" SEXP _arrow_Field__initialize(SEXP name_sexp, SEXP field_sexp, SEXP nullable_sexp){ BEGIN_CPP11 arrow::r::Input::type name(name_sexp); @@ -3473,7 +3473,7 @@ extern "C" SEXP _arrow_fs___FileSelector__recursive(SEXP selector_sexp){ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, bool recursive); +R6 fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, bool recursive); extern "C" SEXP _arrow_fs___FileSelector__create(SEXP base_dir_sexp, SEXP allow_not_found_sexp, SEXP recursive_sexp){ BEGIN_CPP11 arrow::r::Input::type base_dir(base_dir_sexp); @@ -3644,7 +3644,7 @@ extern "C" SEXP _arrow_fs___FileSystem__CopyFile(SEXP file_system_sexp, SEXP src // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, const std::string& path); +R6 fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenInputStream(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3660,7 +3660,7 @@ extern "C" SEXP _arrow_fs___FileSystem__OpenInputStream(SEXP file_system_sexp, S // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, const std::string& path); +R6 fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenInputFile(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3676,7 +3676,7 @@ extern "C" SEXP _arrow_fs___FileSystem__OpenInputFile(SEXP file_system_sexp, SEX // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, const std::string& path); +R6 fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenOutputStream(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3692,7 +3692,7 @@ extern "C" SEXP _arrow_fs___FileSystem__OpenOutputStream(SEXP file_system_sexp, // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, const std::string& path); +R6 fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenAppendStream(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3723,7 +3723,7 @@ extern "C" SEXP _arrow_fs___FileSystem__type_name(SEXP file_system_sexp){ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___LocalFileSystem__create(); +R6 fs___LocalFileSystem__create(); extern "C" SEXP _arrow_fs___LocalFileSystem__create(){ BEGIN_CPP11 return cpp11::as_sexp(fs___LocalFileSystem__create()); @@ -3737,7 +3737,7 @@ extern "C" SEXP _arrow_fs___LocalFileSystem__create(){ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___SubTreeFileSystem__create(const std::string& base_path, const std::shared_ptr& base_fs); +R6 fs___SubTreeFileSystem__create(const std::string& base_path, const std::shared_ptr& base_fs); extern "C" SEXP _arrow_fs___SubTreeFileSystem__create(SEXP base_path_sexp, SEXP base_fs_sexp){ BEGIN_CPP11 arrow::r::Input::type base_path(base_path_sexp); @@ -3819,7 +3819,7 @@ extern "C" SEXP _arrow_fs___CopyFiles(SEXP source_fs_sexp, SEXP source_sel_sexp, // filesystem.cpp #if defined(ARROW_R_WITH_S3) -std::shared_ptr fs___S3FileSystem__create(bool anonymous, std::string access_key, std::string secret_key, std::string session_token, std::string role_arn, std::string session_name, std::string external_id, int load_frequency, std::string region, std::string endpoint_override, std::string scheme, bool background_writes); +R6 fs___S3FileSystem__create(bool anonymous, std::string access_key, std::string secret_key, std::string session_token, std::string role_arn, std::string session_name, std::string external_id, int load_frequency, std::string region, std::string endpoint_override, std::string scheme, bool background_writes); extern "C" SEXP _arrow_fs___S3FileSystem__create(SEXP anonymous_sexp, SEXP access_key_sexp, SEXP secret_key_sexp, SEXP session_token_sexp, SEXP role_arn_sexp, SEXP session_name_sexp, SEXP external_id_sexp, SEXP load_frequency_sexp, SEXP region_sexp, SEXP endpoint_override_sexp, SEXP scheme_sexp, SEXP background_writes_sexp){ BEGIN_CPP11 arrow::r::Input::type anonymous(anonymous_sexp); @@ -3860,7 +3860,7 @@ extern "C" SEXP _arrow_fs___S3FileSystem__region(SEXP fs_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___Readable__Read(const std::shared_ptr& x, int64_t nbytes); +R6 io___Readable__Read(const std::shared_ptr& x, int64_t nbytes); extern "C" SEXP _arrow_io___Readable__Read(SEXP x_sexp, SEXP nbytes_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3970,7 +3970,7 @@ extern "C" SEXP _arrow_io___RandomAccessFile__Tell(SEXP x_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___RandomAccessFile__Read0(const std::shared_ptr& x); +R6 io___RandomAccessFile__Read0(const std::shared_ptr& x); extern "C" SEXP _arrow_io___RandomAccessFile__Read0(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3985,7 +3985,7 @@ extern "C" SEXP _arrow_io___RandomAccessFile__Read0(SEXP x_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___RandomAccessFile__ReadAt(const std::shared_ptr& x, int64_t position, int64_t nbytes); +R6 io___RandomAccessFile__ReadAt(const std::shared_ptr& x, int64_t position, int64_t nbytes); extern "C" SEXP _arrow_io___RandomAccessFile__ReadAt(SEXP x_sexp, SEXP position_sexp, SEXP nbytes_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -4002,7 +4002,7 @@ extern "C" SEXP _arrow_io___RandomAccessFile__ReadAt(SEXP x_sexp, SEXP position_ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___MemoryMappedFile__Create(const std::string& path, int64_t size); +R6 io___MemoryMappedFile__Create(const std::string& path, int64_t size); extern "C" SEXP _arrow_io___MemoryMappedFile__Create(SEXP path_sexp, SEXP size_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4018,7 +4018,7 @@ extern "C" SEXP _arrow_io___MemoryMappedFile__Create(SEXP path_sexp, SEXP size_s // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode); +R6 io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode); extern "C" SEXP _arrow_io___MemoryMappedFile__Open(SEXP path_sexp, SEXP mode_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4051,7 +4051,7 @@ extern "C" SEXP _arrow_io___MemoryMappedFile__Resize(SEXP x_sexp, SEXP size_sexp // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___ReadableFile__Open(const std::string& path); +R6 io___ReadableFile__Open(const std::string& path); extern "C" SEXP _arrow_io___ReadableFile__Open(SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4066,7 +4066,7 @@ extern "C" SEXP _arrow_io___ReadableFile__Open(SEXP path_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___BufferReader__initialize(const std::shared_ptr& buffer); +R6 io___BufferReader__initialize(const std::shared_ptr& buffer); extern "C" SEXP _arrow_io___BufferReader__initialize(SEXP buffer_sexp){ BEGIN_CPP11 arrow::r::Input&>::type buffer(buffer_sexp); @@ -4113,7 +4113,7 @@ extern "C" SEXP _arrow_io___OutputStream__Tell(SEXP stream_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___FileOutputStream__Open(const std::string& path); +R6 io___FileOutputStream__Open(const std::string& path); extern "C" SEXP _arrow_io___FileOutputStream__Open(SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4128,7 +4128,7 @@ extern "C" SEXP _arrow_io___FileOutputStream__Open(SEXP path_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___BufferOutputStream__Create(int64_t initial_capacity); +R6 io___BufferOutputStream__Create(int64_t initial_capacity); extern "C" SEXP _arrow_io___BufferOutputStream__Create(SEXP initial_capacity_sexp){ BEGIN_CPP11 arrow::r::Input::type initial_capacity(initial_capacity_sexp); @@ -4158,7 +4158,7 @@ extern "C" SEXP _arrow_io___BufferOutputStream__capacity(SEXP stream_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr io___BufferOutputStream__Finish(const std::shared_ptr& stream); +R6 io___BufferOutputStream__Finish(const std::shared_ptr& stream); extern "C" SEXP _arrow_io___BufferOutputStream__Finish(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4205,7 +4205,7 @@ extern "C" SEXP _arrow_io___BufferOutputStream__Write(SEXP stream_sexp, SEXP byt // json.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr json___ReadOptions__initialize(bool use_threads, int block_size); +R6 json___ReadOptions__initialize(bool use_threads, int block_size); extern "C" SEXP _arrow_json___ReadOptions__initialize(SEXP use_threads_sexp, SEXP block_size_sexp){ BEGIN_CPP11 arrow::r::Input::type use_threads(use_threads_sexp); @@ -4221,7 +4221,7 @@ extern "C" SEXP _arrow_json___ReadOptions__initialize(SEXP use_threads_sexp, SEX // json.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr json___ParseOptions__initialize(bool newlines_in_values); +R6 json___ParseOptions__initialize(bool newlines_in_values); extern "C" SEXP _arrow_json___ParseOptions__initialize(SEXP newlines_in_values_sexp){ BEGIN_CPP11 arrow::r::Input::type newlines_in_values(newlines_in_values_sexp); @@ -4236,7 +4236,7 @@ extern "C" SEXP _arrow_json___ParseOptions__initialize(SEXP newlines_in_values_s // json.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr json___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options); +R6 json___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options); extern "C" SEXP _arrow_json___TableReader__Make(SEXP input_sexp, SEXP read_options_sexp, SEXP parse_options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type input(input_sexp); @@ -4253,7 +4253,7 @@ extern "C" SEXP _arrow_json___TableReader__Make(SEXP input_sexp, SEXP read_optio // json.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr json___TableReader__Read(const std::shared_ptr& table_reader); +R6 json___TableReader__Read(const std::shared_ptr& table_reader); extern "C" SEXP _arrow_json___TableReader__Read(SEXP table_reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table_reader(table_reader_sexp); @@ -4268,7 +4268,7 @@ extern "C" SEXP _arrow_json___TableReader__Read(SEXP table_reader_sexp){ // memorypool.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr MemoryPool__default(); +R6 MemoryPool__default(); extern "C" SEXP _arrow_MemoryPool__default(){ BEGIN_CPP11 return cpp11::as_sexp(MemoryPool__default()); @@ -4327,7 +4327,7 @@ extern "C" SEXP _arrow_ipc___Message__body_length(SEXP message_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___Message__metadata(const std::unique_ptr& message); +R6 ipc___Message__metadata(const std::unique_ptr& message); extern "C" SEXP _arrow_ipc___Message__metadata(SEXP message_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4342,7 +4342,7 @@ extern "C" SEXP _arrow_ipc___Message__metadata(SEXP message_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___Message__body(const std::unique_ptr& message); +R6 ipc___Message__body(const std::unique_ptr& message); extern "C" SEXP _arrow_ipc___Message__body(SEXP message_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4403,7 +4403,7 @@ extern "C" SEXP _arrow_ipc___Message__Equals(SEXP x_sexp, SEXP y_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___ReadRecordBatch__Message__Schema(const std::unique_ptr& message, const std::shared_ptr& schema); +R6 ipc___ReadRecordBatch__Message__Schema(const std::unique_ptr& message, const std::shared_ptr& schema); extern "C" SEXP _arrow_ipc___ReadRecordBatch__Message__Schema(SEXP message_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4419,7 +4419,7 @@ extern "C" SEXP _arrow_ipc___ReadRecordBatch__Message__Schema(SEXP message_sexp, // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___ReadSchema_InputStream(const std::shared_ptr& stream); +R6 ipc___ReadSchema_InputStream(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___ReadSchema_InputStream(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4434,7 +4434,7 @@ extern "C" SEXP _arrow_ipc___ReadSchema_InputStream(SEXP stream_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___ReadSchema_Message(const std::unique_ptr& message); +R6 ipc___ReadSchema_Message(const std::unique_ptr& message); extern "C" SEXP _arrow_ipc___ReadSchema_Message(SEXP message_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4449,7 +4449,7 @@ extern "C" SEXP _arrow_ipc___ReadSchema_Message(SEXP message_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___MessageReader__Open(const std::shared_ptr& stream); +R6 ipc___MessageReader__Open(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___MessageReader__Open(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4464,7 +4464,7 @@ extern "C" SEXP _arrow_ipc___MessageReader__Open(SEXP stream_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___MessageReader__ReadNextMessage(const std::unique_ptr& reader); +R6 ipc___MessageReader__ReadNextMessage(const std::unique_ptr& reader); extern "C" SEXP _arrow_ipc___MessageReader__ReadNextMessage(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4479,7 +4479,7 @@ extern "C" SEXP _arrow_ipc___MessageReader__ReadNextMessage(SEXP reader_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___ReadMessage(const std::shared_ptr& stream); +R6 ipc___ReadMessage(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___ReadMessage(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4494,7 +4494,7 @@ extern "C" SEXP _arrow_ipc___ReadMessage(SEXP stream_sexp){ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___ArrowReaderProperties__Make(bool use_threads); +R6 parquet___arrow___ArrowReaderProperties__Make(bool use_threads); extern "C" SEXP _arrow_parquet___arrow___ArrowReaderProperties__Make(SEXP use_threads_sexp){ BEGIN_CPP11 arrow::r::Input::type use_threads(use_threads_sexp); @@ -4576,7 +4576,7 @@ extern "C" SEXP _arrow_parquet___arrow___ArrowReaderProperties__set_read_diction // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__OpenFile(const std::shared_ptr& file, const std::shared_ptr& props); +R6 parquet___arrow___FileReader__OpenFile(const std::shared_ptr& file, const std::shared_ptr& props); extern "C" SEXP _arrow_parquet___arrow___FileReader__OpenFile(SEXP file_sexp, SEXP props_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file(file_sexp); @@ -4592,7 +4592,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__OpenFile(SEXP file_sexp, SE // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadTable1(const std::shared_ptr& reader); +R6 parquet___arrow___FileReader__ReadTable1(const std::shared_ptr& reader); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable1(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4607,7 +4607,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable1(SEXP reader_sexp // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadTable2(const std::shared_ptr& reader, const std::vector& column_indices); +R6 parquet___arrow___FileReader__ReadTable2(const std::shared_ptr& reader, const std::vector& column_indices); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable2(SEXP reader_sexp, SEXP column_indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4623,7 +4623,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable2(SEXP reader_sexp // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadRowGroup1(const std::shared_ptr& reader, int i); +R6 parquet___arrow___FileReader__ReadRowGroup1(const std::shared_ptr& reader, int i); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup1(SEXP reader_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4639,7 +4639,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup1(SEXP reader_s // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadRowGroup2(const std::shared_ptr& reader, int i, const std::vector& column_indices); +R6 parquet___arrow___FileReader__ReadRowGroup2(const std::shared_ptr& reader, int i, const std::vector& column_indices); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup2(SEXP reader_sexp, SEXP i_sexp, SEXP column_indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4656,7 +4656,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup2(SEXP reader_s // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadRowGroups1(const std::shared_ptr& reader, const std::vector& row_groups); +R6 parquet___arrow___FileReader__ReadRowGroups1(const std::shared_ptr& reader, const std::vector& row_groups); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroups1(SEXP reader_sexp, SEXP row_groups_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4672,7 +4672,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroups1(SEXP reader_ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadRowGroups2(const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices); +R6 parquet___arrow___FileReader__ReadRowGroups2(const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroups2(SEXP reader_sexp, SEXP row_groups_sexp, SEXP column_indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4734,7 +4734,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__num_row_groups(SEXP reader_ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__ReadColumn(const std::shared_ptr& reader, int i); +R6 parquet___arrow___FileReader__ReadColumn(const std::shared_ptr& reader, int i); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadColumn(SEXP reader_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4750,7 +4750,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadColumn(SEXP reader_sexp // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, int timestamp_unit); +R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, int timestamp_unit); extern "C" SEXP _arrow_parquet___ArrowWriterProperties___create(SEXP allow_truncated_timestamps_sexp, SEXP use_deprecated_int96_timestamps_sexp, SEXP timestamp_unit_sexp){ BEGIN_CPP11 arrow::r::Input::type allow_truncated_timestamps(allow_truncated_timestamps_sexp); @@ -4767,7 +4767,7 @@ extern "C" SEXP _arrow_parquet___ArrowWriterProperties___create(SEXP allow_trunc // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___WriterProperties___Builder__create(); +R6 parquet___WriterProperties___Builder__create(); extern "C" SEXP _arrow_parquet___WriterProperties___Builder__create(){ BEGIN_CPP11 return cpp11::as_sexp(parquet___WriterProperties___Builder__create()); @@ -4887,7 +4887,7 @@ extern "C" SEXP _arrow_parquet___ArrowWriterProperties___Builder__data_page_size // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___WriterProperties___Builder__build(const std::shared_ptr& builder); +R6 parquet___WriterProperties___Builder__build(const std::shared_ptr& builder); extern "C" SEXP _arrow_parquet___WriterProperties___Builder__build(SEXP builder_sexp){ BEGIN_CPP11 arrow::r::Input&>::type builder(builder_sexp); @@ -4902,7 +4902,7 @@ extern "C" SEXP _arrow_parquet___WriterProperties___Builder__build(SEXP builder_ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___ParquetFileWriter__Open(const std::shared_ptr& schema, const std::shared_ptr& sink, const std::shared_ptr& properties, const std::shared_ptr& arrow_properties); +R6 parquet___arrow___ParquetFileWriter__Open(const std::shared_ptr& schema, const std::shared_ptr& sink, const std::shared_ptr& properties, const std::shared_ptr& arrow_properties); extern "C" SEXP _arrow_parquet___arrow___ParquetFileWriter__Open(SEXP schema_sexp, SEXP sink_sexp, SEXP properties_sexp, SEXP arrow_properties_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schema(schema_sexp); @@ -4973,7 +4973,7 @@ extern "C" SEXP _arrow_parquet___arrow___WriteTable(SEXP table_sexp, SEXP sink_s // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr parquet___arrow___FileReader__GetSchema(const std::shared_ptr& reader); +R6 parquet___arrow___FileReader__GetSchema(const std::shared_ptr& reader); extern "C" SEXP _arrow_parquet___arrow___FileReader__GetSchema(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4988,7 +4988,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__GetSchema(SEXP reader_sexp) // py-to-r.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ImportArray(arrow::r::Pointer array, arrow::r::Pointer schema); +R6 ImportArray(arrow::r::Pointer array, arrow::r::Pointer schema); extern "C" SEXP _arrow_ImportArray(SEXP array_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input>::type array(array_sexp); @@ -5004,7 +5004,7 @@ extern "C" SEXP _arrow_ImportArray(SEXP array_sexp, SEXP schema_sexp){ // py-to-r.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ImportRecordBatch(arrow::r::Pointer array, arrow::r::Pointer schema); +R6 ImportRecordBatch(arrow::r::Pointer array, arrow::r::Pointer schema); extern "C" SEXP _arrow_ImportRecordBatch(SEXP array_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input>::type array(array_sexp); @@ -5180,7 +5180,7 @@ extern "C" SEXP _arrow_RecordBatch__num_rows(SEXP x_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__schema(const std::shared_ptr& x); +R6 RecordBatch__schema(const std::shared_ptr& x); extern "C" SEXP _arrow_RecordBatch__schema(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -5195,7 +5195,7 @@ extern "C" SEXP _arrow_RecordBatch__schema(SEXP x_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); +R6 RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); extern "C" SEXP _arrow_RecordBatch__ReplaceSchemaMetadata(SEXP x_sexp, SEXP metadata_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -5226,7 +5226,7 @@ extern "C" SEXP _arrow_RecordBatch__columns(SEXP batch_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i); +R6 RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i); extern "C" SEXP _arrow_RecordBatch__column(SEXP batch_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5242,7 +5242,7 @@ extern "C" SEXP _arrow_RecordBatch__column(SEXP batch_sexp, SEXP i_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__GetColumnByName(const std::shared_ptr& batch, const std::string& name); +R6 RecordBatch__GetColumnByName(const std::shared_ptr& batch, const std::string& name); extern "C" SEXP _arrow_RecordBatch__GetColumnByName(SEXP batch_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5258,7 +5258,7 @@ extern "C" SEXP _arrow_RecordBatch__GetColumnByName(SEXP batch_sexp, SEXP name_s // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__SelectColumns(const std::shared_ptr& batch, cpp11::integers indices); +R6 RecordBatch__SelectColumns(const std::shared_ptr& batch, cpp11::integers indices); extern "C" SEXP _arrow_RecordBatch__SelectColumns(SEXP batch_sexp, SEXP indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5291,7 +5291,7 @@ extern "C" SEXP _arrow_RecordBatch__Equals(SEXP self_sexp, SEXP other_sexp, SEXP // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__RemoveColumn(const std::shared_ptr& batch, R_xlen_t i); +R6 RecordBatch__RemoveColumn(const std::shared_ptr& batch, R_xlen_t i); extern "C" SEXP _arrow_RecordBatch__RemoveColumn(SEXP batch_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5338,7 +5338,7 @@ extern "C" SEXP _arrow_RecordBatch__names(SEXP batch_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset); +R6 RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset); extern "C" SEXP _arrow_RecordBatch__Slice1(SEXP self_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type self(self_sexp); @@ -5354,7 +5354,7 @@ extern "C" SEXP _arrow_RecordBatch__Slice1(SEXP self_sexp, SEXP offset_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t offset, R_xlen_t length); +R6 RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_RecordBatch__Slice2(SEXP self_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type self(self_sexp); @@ -5386,7 +5386,7 @@ extern "C" SEXP _arrow_ipc___SerializeRecordBatch__Raw(SEXP batch_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___ReadRecordBatch__InputStream__Schema(const std::shared_ptr& stream, const std::shared_ptr& schema); +R6 ipc___ReadRecordBatch__InputStream__Schema(const std::shared_ptr& stream, const std::shared_ptr& schema); extern "C" SEXP _arrow_ipc___ReadRecordBatch__InputStream__Schema(SEXP stream_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5402,7 +5402,7 @@ extern "C" SEXP _arrow_ipc___ReadRecordBatch__InputStream__Schema(SEXP stream_se // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst); +R6 RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst); extern "C" SEXP _arrow_RecordBatch__from_arrays(SEXP schema_sxp_sexp, SEXP lst_sexp){ BEGIN_CPP11 arrow::r::Input::type schema_sxp(schema_sxp_sexp); @@ -5418,7 +5418,7 @@ extern "C" SEXP _arrow_RecordBatch__from_arrays(SEXP schema_sxp_sexp, SEXP lst_s // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatchReader__schema(const std::shared_ptr& reader); +R6 RecordBatchReader__schema(const std::shared_ptr& reader); extern "C" SEXP _arrow_RecordBatchReader__schema(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5433,7 +5433,7 @@ extern "C" SEXP _arrow_RecordBatchReader__schema(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr RecordBatchReader__ReadNext(const std::shared_ptr& reader); +R6 RecordBatchReader__ReadNext(const std::shared_ptr& reader); extern "C" SEXP _arrow_RecordBatchReader__ReadNext(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5448,7 +5448,7 @@ extern "C" SEXP _arrow_RecordBatchReader__ReadNext(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___RecordBatchStreamReader__Open(const std::shared_ptr& stream); +R6 ipc___RecordBatchStreamReader__Open(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___RecordBatchStreamReader__Open(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5478,7 +5478,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchStreamReader__batches(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___RecordBatchFileReader__schema(const std::shared_ptr& reader); +R6 ipc___RecordBatchFileReader__schema(const std::shared_ptr& reader); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__schema(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5508,7 +5508,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__num_record_batches(SEXP read // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___RecordBatchFileReader__ReadRecordBatch(const std::shared_ptr& reader, int i); +R6 ipc___RecordBatchFileReader__ReadRecordBatch(const std::shared_ptr& reader, int i); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__ReadRecordBatch(SEXP reader_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5524,7 +5524,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__ReadRecordBatch(SEXP reader_ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___RecordBatchFileReader__Open(const std::shared_ptr& file); +SEXP ipc___RecordBatchFileReader__Open(const std::shared_ptr& file); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__Open(SEXP file_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file(file_sexp); @@ -5539,7 +5539,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__Open(SEXP file_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__from_RecordBatchFileReader(const std::shared_ptr& reader); +R6 Table__from_RecordBatchFileReader(const std::shared_ptr& reader); extern "C" SEXP _arrow_Table__from_RecordBatchFileReader(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5554,7 +5554,7 @@ extern "C" SEXP _arrow_Table__from_RecordBatchFileReader(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__from_RecordBatchStreamReader(const std::shared_ptr& reader); +R6 Table__from_RecordBatchStreamReader(const std::shared_ptr& reader); extern "C" SEXP _arrow_Table__from_RecordBatchStreamReader(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5634,7 +5634,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchWriter__Close(SEXP batch_writer_sexp){ // recordbatchwriter.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___RecordBatchFileWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); +R6 ipc___RecordBatchFileWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); extern "C" SEXP _arrow_ipc___RecordBatchFileWriter__Open(SEXP stream_sexp, SEXP schema_sexp, SEXP use_legacy_format_sexp, SEXP metadata_version_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5652,7 +5652,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileWriter__Open(SEXP stream_sexp, SEXP // recordbatchwriter.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ipc___RecordBatchStreamWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); +R6 ipc___RecordBatchStreamWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); extern "C" SEXP _arrow_ipc___RecordBatchStreamWriter__Open(SEXP stream_sexp, SEXP schema_sexp, SEXP use_legacy_format_sexp, SEXP metadata_version_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5670,7 +5670,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchStreamWriter__Open(SEXP stream_sexp, SEX // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__GetScalar(const std::shared_ptr& x, int64_t i); +R6 Array__GetScalar(const std::shared_ptr& x, int64_t i); extern "C" SEXP _arrow_Array__GetScalar(SEXP x_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -5701,7 +5701,7 @@ extern "C" SEXP _arrow_Scalar__ToString(SEXP s_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Scalar__CastTo(const std::shared_ptr& s, const std::shared_ptr& t); +R6 Scalar__CastTo(const std::shared_ptr& s, const std::shared_ptr& t); extern "C" SEXP _arrow_Scalar__CastTo(SEXP s_sexp, SEXP t_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5717,7 +5717,7 @@ extern "C" SEXP _arrow_Scalar__CastTo(SEXP s_sexp, SEXP t_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr StructScalar__field(const std::shared_ptr& s, int i); +R6 StructScalar__field(const std::shared_ptr& s, int i); extern "C" SEXP _arrow_StructScalar__field(SEXP s_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5733,7 +5733,7 @@ extern "C" SEXP _arrow_StructScalar__field(SEXP s_sexp, SEXP i_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr StructScalar__GetFieldByName(const std::shared_ptr& s, const std::string& name); +R6 StructScalar__GetFieldByName(const std::shared_ptr& s, const std::string& name); extern "C" SEXP _arrow_StructScalar__GetFieldByName(SEXP s_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5794,7 +5794,7 @@ extern "C" SEXP _arrow_Scalar__type(SEXP s_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr schema_(const std::vector>& fields); +R6 schema_(const std::vector>& fields); extern "C" SEXP _arrow_schema_(SEXP fields_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type fields(fields_sexp); @@ -5839,7 +5839,7 @@ extern "C" SEXP _arrow_Schema__num_fields(SEXP s_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Schema__field(const std::shared_ptr& s, int i); +R6 Schema__field(const std::shared_ptr& s, int i); extern "C" SEXP _arrow_Schema__field(SEXP s_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5855,7 +5855,7 @@ extern "C" SEXP _arrow_Schema__field(SEXP s_sexp, SEXP i_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Schema__GetFieldByName(const std::shared_ptr& s, std::string x); +R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x); extern "C" SEXP _arrow_Schema__GetFieldByName(SEXP s_sexp, SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5931,7 +5931,7 @@ extern "C" SEXP _arrow_Schema__metadata(SEXP schema_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Schema__WithMetadata(const std::shared_ptr& schema, cpp11::strings metadata); +R6 Schema__WithMetadata(const std::shared_ptr& schema, cpp11::strings metadata); extern "C" SEXP _arrow_Schema__WithMetadata(SEXP schema_sexp, SEXP metadata_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schema(schema_sexp); @@ -5979,7 +5979,7 @@ extern "C" SEXP _arrow_Schema__Equals(SEXP schema_sexp, SEXP other_sexp, SEXP ch // schema.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr arrow__UnifySchemas(const std::vector>& schemas); +R6 arrow__UnifySchemas(const std::vector>& schemas); extern "C" SEXP _arrow_arrow__UnifySchemas(SEXP schemas_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type schemas(schemas_sexp); @@ -6024,7 +6024,7 @@ extern "C" SEXP _arrow_Table__num_rows(SEXP x_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__schema(const std::shared_ptr& x); +R6 Table__schema(const std::shared_ptr& x); extern "C" SEXP _arrow_Table__schema(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -6039,7 +6039,7 @@ extern "C" SEXP _arrow_Table__schema(SEXP x_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); +R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); extern "C" SEXP _arrow_Table__ReplaceSchemaMetadata(SEXP x_sexp, SEXP metadata_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -6055,7 +6055,7 @@ extern "C" SEXP _arrow_Table__ReplaceSchemaMetadata(SEXP x_sexp, SEXP metadata_s // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__column(const std::shared_ptr& table, R_xlen_t i); +R6 Table__column(const std::shared_ptr& table, R_xlen_t i); extern "C" SEXP _arrow_Table__column(SEXP table_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6071,7 +6071,7 @@ extern "C" SEXP _arrow_Table__column(SEXP table_sexp, SEXP i_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__field(const std::shared_ptr& table, R_xlen_t i); +R6 Table__field(const std::shared_ptr& table, R_xlen_t i); extern "C" SEXP _arrow_Table__field(SEXP table_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6117,7 +6117,7 @@ extern "C" SEXP _arrow_Table__ColumnNames(SEXP table_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__Slice1(const std::shared_ptr& table, R_xlen_t offset); +R6 Table__Slice1(const std::shared_ptr& table, R_xlen_t offset); extern "C" SEXP _arrow_Table__Slice1(SEXP table_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6133,7 +6133,7 @@ extern "C" SEXP _arrow_Table__Slice1(SEXP table_sexp, SEXP offset_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, R_xlen_t length); +R6 Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_Table__Slice2(SEXP table_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6197,7 +6197,7 @@ extern "C" SEXP _arrow_Table__ValidateFull(SEXP table_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__GetColumnByName(const std::shared_ptr& table, const std::string& name); +R6 Table__GetColumnByName(const std::shared_ptr& table, const std::string& name); extern "C" SEXP _arrow_Table__GetColumnByName(SEXP table_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6213,7 +6213,7 @@ extern "C" SEXP _arrow_Table__GetColumnByName(SEXP table_sexp, SEXP name_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__SelectColumns(const std::shared_ptr& table, const std::vector& indices); +R6 Table__SelectColumns(const std::shared_ptr& table, const std::vector& indices); extern "C" SEXP _arrow_Table__SelectColumns(SEXP table_sexp, SEXP indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6244,7 +6244,7 @@ extern "C" SEXP _arrow_all_record_batches(SEXP lst_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__from_record_batches(const std::vector>& batches, SEXP schema_sxp); +R6 Table__from_record_batches(const std::vector>& batches, SEXP schema_sxp); extern "C" SEXP _arrow_Table__from_record_batches(SEXP batches_sexp, SEXP schema_sxp_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type batches(batches_sexp); @@ -6260,7 +6260,7 @@ extern "C" SEXP _arrow_Table__from_record_batches(SEXP batches_sexp, SEXP schema // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Table__from_dots(SEXP lst, SEXP schema_sxp); +R6 Table__from_dots(SEXP lst, SEXP schema_sxp); extern "C" SEXP _arrow_Table__from_dots(SEXP lst_sexp, SEXP schema_sxp_sexp){ BEGIN_CPP11 arrow::r::Input::type lst(lst_sexp); @@ -6433,7 +6433,7 @@ static const R_CallMethodDef CallEntries[] = { { "_arrow_dataset___FileSystemDatasetFactory__Make3", (DL_FUNC) &_arrow_dataset___FileSystemDatasetFactory__Make3, 4}, { "_arrow_dataset___FileFormat__type_name", (DL_FUNC) &_arrow_dataset___FileFormat__type_name, 1}, { "_arrow_dataset___FileFormat__DefaultWriteOptions", (DL_FUNC) &_arrow_dataset___FileFormat__DefaultWriteOptions, 1}, - { "_arrow_dataset___ParquetFileFormat__Make", (DL_FUNC) &_arrow_dataset___ParquetFileFormat__Make, 3}, + { "_arrow_dataset___ParquetFileFormat__MakeRead", (DL_FUNC) &_arrow_dataset___ParquetFileFormat__MakeRead, 3}, { "_arrow_dataset___FileWriteOptions__type_name", (DL_FUNC) &_arrow_dataset___FileWriteOptions__type_name, 1}, { "_arrow_dataset___ParquetFileWriteOptions__update", (DL_FUNC) &_arrow_dataset___ParquetFileWriteOptions__update, 3}, { "_arrow_dataset___IpcFileWriteOptions__update2", (DL_FUNC) &_arrow_dataset___IpcFileWriteOptions__update2, 4}, diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 96ce9754d10..12b1a9e6873 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -24,6 +24,8 @@ #include "./nameof.h" +using R6 = SEXP; + namespace cpp11 { template @@ -301,6 +303,23 @@ bool GetBoolOption(const std::string& name, bool default_); namespace cpp11 { +template +SEXP r6(const std::shared_ptr& x, const std::string& r_class_name) { + if (x == nullptr) return R_NilValue; + cpp11::external_pointer> xp(new std::shared_ptr(x)); + SEXP r6_class = Rf_install(r_class_name.c_str()); + + // make call: $new() + SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_)); + SEXP call2 = PROTECT(Rf_lang2(call, xp)); + + // and then eval in arrow:: + SEXP r6 = PROTECT(Rf_eval(call2, arrow::r::ns::arrow)); + + UNPROTECT(3); + return r6; +} + template using enable_if_shared_ptr = typename std::enable_if< std::is_same, T>::value, T>::type; @@ -325,32 +344,4 @@ enable_if_enum as_sexp(E e) { return as_sexp(static_cast(e)); } -template -SEXP R6_make(SEXP symbol, SEXP fun_symbol, const std::shared_ptr& x) { - if (x == nullptr) { - return R_NilValue; - } - cpp11::external_pointer> xp(new std::shared_ptr(x)); - - // make call: $() - SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, symbol, fun_symbol)); - SEXP call2 = PROTECT(Rf_lang2(call, xp)); - - // and then eval: - SEXP r6 = PROTECT(Rf_eval(call2, arrow::r::ns::arrow)); - - UNPROTECT(3); - return r6; -} - -template -SEXP R6_new(SEXP symbol, T x) { - return R6_make(symbol, arrow::r::symbols::new_, std::move(x)); -} - -template -SEXP R6_create(SEXP symbol, T x) { - return R6_make(symbol, arrow::r::symbols::create, std::move(x)); -} - } // namespace cpp11 diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index a78c1111967..904f1c86a7e 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -89,74 +89,14 @@ namespace dataset { class DirectoryPartitioning; class HivePartitioning; +class FileSystemDatasetFactory; -} -} - -namespace cpp11 { - -inline SEXP xp_to_r6(SEXP xp, SEXP r6_class) { - // make call: $new() - SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_)); - SEXP call2 = PROTECT(Rf_lang2(call, xp)); - - // and then eval in arrow:: - SEXP r6 = PROTECT(Rf_eval(call2, arrow::r::ns::arrow)); +} // namespace dataset - UNPROTECT(3); - return r6; +namespace fs { +class S3FileSystem; } -template -inline SEXP shared_ptr_to_r6(const std::shared_ptr& x, const std::string& r_class_name) { - if (x == nullptr) return R_NilValue; - cpp11::external_pointer> xp(new std::shared_ptr(x)); - SEXP r6_class = Rf_install(r_class_name.c_str()); - return xp_to_r6(xp, r6_class); -} - -#define R6_HANDLE(TYPE, NAME) \ - template <> \ - SEXP as_sexp(const std::shared_ptr& ptr) { \ - return shared_ptr_to_r6(ptr, NAME); \ - } - -R6_HANDLE(arrow::RecordBatch, "RecordBatch") -R6_HANDLE(arrow::Table, "Table") -R6_HANDLE(arrow::Schema, "Schema") -R6_HANDLE(arrow::Buffer, "Buffer") -R6_HANDLE(arrow::MemoryPool, "MemoryPool") -R6_HANDLE(arrow::Field, "Field") -R6_HANDLE(arrow::ChunkedArray, "ChunkedArray") - -R6_HANDLE(arrow::dataset::DirectoryPartitioning, "DirectoryPartitioning") -R6_HANDLE(arrow::dataset::HivePartitioning, "HivePartitioning") -R6_HANDLE(arrow::dataset::PartitioningFactory, "PartitioningFactory") -R6_HANDLE(arrow::dataset::DatasetFactory, "DatasetFactory") - -R6_HANDLE(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder") -R6_HANDLE(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties") -R6_HANDLE(parquet::WriterProperties, "ParquetWriterProperties") -R6_HANDLE(parquet::arrow::FileWriter, "ParquetFileWriter") -R6_HANDLE(parquet::arrow::FileReader, "ParquetFileReader") -R6_HANDLE(parquet::ArrowReaderProperties, "ParquetReaderProperties") - -R6_HANDLE(arrow::ipc::feather::Reader, "FeatherReader") - -R6_HANDLE(arrow::csv::TableReader, "CsvTableReader") -R6_HANDLE(arrow::csv::ReadOptions, "CsvReadOptions") -R6_HANDLE(arrow::csv::ParseOptions, "CsvParseOptions") -R6_HANDLE(arrow::csv::ConvertOptions, "CsvConvertOptions") - -R6_HANDLE(arrow::dataset::Expression, "Expression") - -R6_HANDLE(arrow::compute::CastOptions, "CastOptions") - -R6_HANDLE(arrow::util::Codec, "Codec") - -R6_HANDLE(arrow::ipc::Message, "Message") -R6_HANDLE(arrow::ipc::MessageReader, "MessageReader") - -} // namespace cpp11 +} // namespace arrow #endif diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index 4a1845a16bc..b36856c7285 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -36,7 +36,7 @@ SEXP ChunkedArray__as_vector(const std::shared_ptr& chunked_array); SEXP Array__as_vector(const std::shared_ptr& array); std::shared_ptr Array__from_vector(SEXP x, SEXP type); -std::shared_ptr RecordBatch__from_arrays(SEXP, SEXP); +R6 RecordBatch__from_arrays(SEXP, SEXP); arrow::MemoryPool* gc_memory_pool(); namespace arrow { @@ -119,4 +119,10 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, } // namespace r } // namespace arrow +namespace cpp11 { + +R6 r6_Array(const std::shared_ptr& array); + +} + #endif diff --git a/r/src/buffer.cpp b/r/src/buffer.cpp index 2814677343d..5d596d3efb5 100644 --- a/r/src/buffer.cpp +++ b/r/src/buffer.cpp @@ -40,17 +40,18 @@ int64_t Buffer__size(const std::shared_ptr& buffer) { } // [[arrow::export]] -std::shared_ptr r___RBuffer__initialize(SEXP x) { +R6 r___RBuffer__initialize(SEXP x) { switch (TYPEOF(x)) { case RAWSXP: - return std::make_shared>(x); + return cpp11::r6(std::make_shared>(x), "Buffer"); case REALSXP: - return std::make_shared>(x); + return cpp11::r6(std::make_shared>(x), "Buffer"); case INTSXP: - return std::make_shared>(x); + return cpp11::r6(std::make_shared>(x), "Buffer"); case CPLXSXP: - return std::make_shared>( - arrow::r::complexs(x)); + return cpp11::r6( + std::make_shared>(arrow::r::complexs(x)), + "Buffer"); default: break; } diff --git a/r/src/chunkedarray.cpp b/r/src/chunkedarray.cpp index f52f20ee0de..5fda0fa0ce6 100644 --- a/r/src/chunkedarray.cpp +++ b/r/src/chunkedarray.cpp @@ -37,10 +37,9 @@ int ChunkedArray__num_chunks(const std::shared_ptr& chunked } // [[arrow::export]] -std::shared_ptr ChunkedArray__chunk( - const std::shared_ptr& chunked_array, int i) { +R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i) { arrow::r::validate_index(i, chunked_array->num_chunks()); - return chunked_array->chunk(i); + return cpp11::r6_Array(chunked_array->chunk(i)); } // [[arrow::export]] @@ -56,26 +55,24 @@ std::shared_ptr ChunkedArray__type( } // [[arrow::export]] -std::shared_ptr ChunkedArray__Slice1( - const std::shared_ptr& chunked_array, R_xlen_t offset) { +R6 ChunkedArray__Slice1(const std::shared_ptr& chunked_array, + R_xlen_t offset) { arrow::r::validate_slice_offset(offset, chunked_array->length()); - return chunked_array->Slice(offset); + return cpp11::r6(chunked_array->Slice(offset), "ChunkedArray"); } // [[arrow::export]] -std::shared_ptr ChunkedArray__Slice2( - const std::shared_ptr& chunked_array, R_xlen_t offset, - R_xlen_t length) { +R6 ChunkedArray__Slice2(const std::shared_ptr& chunked_array, + R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, chunked_array->length()); arrow::r::validate_slice_length(length, chunked_array->length() - offset); - return chunked_array->Slice(offset, length); + return cpp11::r6(chunked_array->Slice(offset, length), "ChunkedArray"); } // [[arrow::export]] -std::shared_ptr ChunkedArray__View( - const std::shared_ptr& array, - const std::shared_ptr& type) { - return ValueOrStop(array->View(type)); +R6 ChunkedArray__View(const std::shared_ptr& array, + const std::shared_ptr& type) { + return cpp11::r6(ValueOrStop(array->View(type)), "ChunkedArray"); } // [[arrow::export]] diff --git a/r/src/compression.cpp b/r/src/compression.cpp index 18c63e4fd19..c35d05b1425 100644 --- a/r/src/compression.cpp +++ b/r/src/compression.cpp @@ -22,9 +22,10 @@ #include // [[arrow::export]] -std::shared_ptr util___Codec__Create(arrow::Compression::type codec, - R_xlen_t compression_level) { - return ValueOrStop(arrow::util::Codec::Create(codec, compression_level)); +R6 util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level) { + std::shared_ptr out = + ValueOrStop(arrow::util::Codec::Create(codec, compression_level)); + return cpp11::r6(out, "Codec"); } // [[arrow::export]] @@ -38,19 +39,20 @@ bool util___Codec__IsAvailable(arrow::Compression::type codec) { } // [[arrow::export]] -std::shared_ptr io___CompressedOutputStream__Make( +R6 io___CompressedOutputStream__Make( const std::shared_ptr& codec, const std::shared_ptr& raw) { - return ValueOrStop( + auto stream = ValueOrStop( arrow::io::CompressedOutputStream::Make(codec.get(), raw, gc_memory_pool())); + return cpp11::r6(stream, "CompressedOutputStream"); } // [[arrow::export]] -std::shared_ptr io___CompressedInputStream__Make( - const std::shared_ptr& codec, - const std::shared_ptr& raw) { - return ValueOrStop( - arrow::io::CompressedInputStream::Make(codec.get(), raw, gc_memory_pool())); +R6 io___CompressedInputStream__Make(const std::shared_ptr& codec, + const std::shared_ptr& raw) { + auto stream = ValueOrStop( + arrow::io::CompressedInputStream::Make(codec.get(), raw, gc_memory_pool())); + return cpp11::r6(stream, "CompressedInputStream"); } #endif diff --git a/r/src/compute.cpp b/r/src/compute.cpp index f54cd27a558..5c5884b16b2 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -29,62 +29,64 @@ arrow::compute::ExecContext* gc_context() { } // [[arrow::export]] -std::shared_ptr compute___CastOptions__initialize( - bool allow_int_overflow, bool allow_time_truncate, bool allow_float_truncate) { +R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_truncate, + bool allow_float_truncate) { auto options = std::make_shared(); options->allow_int_overflow = allow_int_overflow; options->allow_time_truncate = allow_time_truncate; options->allow_float_truncate = allow_float_truncate; - return options; + return cpp11::r6(options, "CastOptions"); } // [[arrow::export]] -std::shared_ptr Array__cast( - const std::shared_ptr& array, - const std::shared_ptr& target_type, - const std::shared_ptr& options) { - return ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); +R6 Array__cast(const std::shared_ptr& array, + const std::shared_ptr& target_type, + const std::shared_ptr& options) { + auto out = ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); + return cpp11::r6_Array(out); } // [[arrow::export]] -std::shared_ptr ChunkedArray__cast( - const std::shared_ptr& chunked_array, - const std::shared_ptr& target_type, - const std::shared_ptr& options) { +R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, + const std::shared_ptr& target_type, + const std::shared_ptr& options) { arrow::Datum value(chunked_array); - arrow::Datum out = - ValueOrStop(arrow::compute::Cast(value, target_type, *options, gc_context())); - return out.chunked_array(); + arrow::Datum out = ValueOrStop(arrow::compute::Cast(value, target_type, *options, gc_context())); + return cpp11::r6(out.chunked_array(), "ChunkedArray"); } // [[arrow::export]] -std::shared_ptr RecordBatch__cast( - const std::shared_ptr& batch, - const std::shared_ptr& schema, - const std::shared_ptr& options) { +R6 RecordBatch__cast(const std::shared_ptr& batch, + const std::shared_ptr& schema, + const std::shared_ptr& options) { auto nc = batch->num_columns(); arrow::ArrayVector columns(nc); for (int i = 0; i < nc; i++) { - columns[i] = Array__cast(batch->column(i), schema->field(i)->type(), options); + columns[i] = ValueOrStop( + arrow::compute::Cast(*batch->column(i), schema->field(i)->type(), *options)); } - return arrow::RecordBatch::Make(schema, batch->num_rows(), std::move(columns)); + auto out = arrow::RecordBatch::Make(schema, batch->num_rows(), std::move(columns)); + return cpp11::r6(out, "RecordBatch"); } // [[arrow::export]] -std::shared_ptr Table__cast( - const std::shared_ptr& table, - const std::shared_ptr& schema, - const std::shared_ptr& options) { +R6 Table__cast(const std::shared_ptr& table, + const std::shared_ptr& schema, + const std::shared_ptr& options) { auto nc = table->num_columns(); using ColumnVector = std::vector>; ColumnVector columns(nc); for (int i = 0; i < nc; i++) { - columns[i] = ChunkedArray__cast(table->column(i), schema->field(i)->type(), options); + arrow::Datum value(table->column(i)); + arrow::Datum out = + ValueOrStop(arrow::compute::Cast(value, schema->field(i)->type(), *options)); + columns[i] = out.chunked_array(); } - return arrow::Table::Make(schema, std::move(columns), table->num_rows()); + auto out = arrow::Table::Make(schema, std::move(columns), table->num_rows()); + return cpp11::r6(out, "Table"); } template @@ -129,19 +131,19 @@ arrow::Datum as_cpp(SEXP x) { SEXP from_datum(arrow::Datum datum) { switch (datum.kind()) { case arrow::Datum::SCALAR: - return cpp11::R6_create(Rf_install("Scalar"), datum.scalar()); + return cpp11::as_sexp(datum.scalar()); case arrow::Datum::ARRAY: - return cpp11::R6_create(Rf_install("Array"), datum.make_array()); + return cpp11::r6_Array(datum.make_array()); case arrow::Datum::CHUNKED_ARRAY: - return cpp11::R6_new(Rf_install("ChunkedArray"), datum.chunked_array()); + return cpp11::r6(datum.chunked_array(), "ChunkedArray"); case arrow::Datum::RECORD_BATCH: - return cpp11::R6_new(Rf_install("RecordBatch"), datum.record_batch()); + return cpp11::r6(datum.record_batch(), "RecordBatch"); case arrow::Datum::TABLE: - return cpp11::R6_new(Rf_install("Table"), datum.table()); + return cpp11::r6(datum.table(), "Table"); default: break; diff --git a/r/src/csv.cpp b/r/src/csv.cpp index 54d3abc3821..cb3fb9b5ef7 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -23,8 +23,7 @@ #include // [[arrow::export]] -std::shared_ptr csv___ReadOptions__initialize( - cpp11::list options) { +R6 csv___ReadOptions__initialize(cpp11::list options) { auto res = std::make_shared(arrow::csv::ReadOptions::Defaults()); res->use_threads = cpp11::as_cpp(options["use_threads"]); @@ -34,12 +33,11 @@ std::shared_ptr csv___ReadOptions__initialize( res->autogenerate_column_names = cpp11::as_cpp(options["autogenerate_column_names"]); - return res; + return cpp11::r6(res, "CsvReadOptions"); } // [[arrow::export]] -std::shared_ptr csv___ParseOptions__initialize( - cpp11::list options) { +R6 csv___ParseOptions__initialize(cpp11::list options) { auto res = std::make_shared(arrow::csv::ParseOptions::Defaults()); res->delimiter = cpp11::as_cpp(options["delimiter"]); @@ -49,7 +47,7 @@ std::shared_ptr csv___ParseOptions__initialize( res->escape_char = cpp11::as_cpp(options["escape_char"]); res->newlines_in_values = cpp11::as_cpp(options["newlines_in_values"]); res->ignore_empty_lines = cpp11::as_cpp(options["ignore_empty_lines"]); - return res; + return cpp11::r6(res, "CsvParseOptions"); } // [[arrow::export]] @@ -63,8 +61,7 @@ SEXP csv___ReadOptions__column_names( } // [[arrow::export]] -std::shared_ptr csv___ConvertOptions__initialize( - cpp11::list options) { +R6 csv___ConvertOptions__initialize(cpp11::list options) { auto res = std::make_shared( arrow::csv::ConvertOptions::Defaults()); res->check_utf8 = cpp11::as_cpp(options["check_utf8"]); @@ -132,23 +129,24 @@ std::shared_ptr csv___ConvertOptions__initialize( res->timestamp_parsers = timestamp_parsers; } - return res; + return cpp11::r6(res, "CsvConvertOptions"); } // [[arrow::export]] -std::shared_ptr csv___TableReader__Make( +R6 csv___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options) { - return ValueOrStop(arrow::csv::TableReader::Make(gc_memory_pool(), input, *read_options, - *parse_options, *convert_options)); + auto reader = ValueOrStop( + arrow::csv::TableReader::Make(gc_memory_pool(), input, *read_options, + *parse_options, *convert_options)); + return cpp11::r6(reader, "CsvTableReader"); } // [[arrow::export]] -std::shared_ptr csv___TableReader__Read( - const std::shared_ptr& table_reader) { - return ValueOrStop(table_reader->Read()); +R6 csv___TableReader__Read(const std::shared_ptr& table_reader) { + return cpp11::r6(ValueOrStop(table_reader->Read()), "Table"); } // [[arrow::export]] diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index e7aff86e96a..1393b4fe1c7 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -28,20 +28,63 @@ namespace ds = ::arrow::dataset; namespace fs = ::arrow::fs; +namespace cpp11 { + +R6 r6_Dataset(const std::shared_ptr& dataset) { + auto type_name = dataset->type_name(); + + if (type_name == "union") { + return cpp11::r6(dataset, "UnionDataset"); + } else if (type_name == "filesystem") { + return cpp11::r6(dataset, "FileSystemDataset"); + } else { + return cpp11::r6(dataset, "Dataset"); + } +} + +R6 r6_FileSystem(const std::shared_ptr& file_system) { + auto type_name = file_system->type_name(); + + if (type_name == "local") { + return cpp11::r6(file_system, "LocalFileSystem"); + } else if (type_name == "s3") { + return cpp11::r6(file_system, "S3FileSystem"); + } else if (type_name == "subtree") { + return cpp11::r6(file_system, "SubTreeFileSystem"); + } else { + return cpp11::r6(file_system, "FileSystem"); + } +} + +R6 r6_FileFormat(const std::shared_ptr& file_format) { + auto type_name = file_format->type_name(); + if (type_name == "parquet") { + return cpp11::r6(file_format, "ParquetFileFormat"); + } else if (type_name == "ipc") { + return cpp11::r6(file_format, "IpcFileFormat"); + } else if (type_name == "csv") { + return cpp11::r6(file_format, "CsvFileFormat"); + } else { + return cpp11::r6(file_format, "FileFormat"); + } +} + +} // namespace cpp11 + // Dataset, UnionDataset, FileSystemDataset // [[arrow::export]] -std::shared_ptr dataset___Dataset__NewScan( - const std::shared_ptr& ds) { +R6 dataset___Dataset__NewScan(const std::shared_ptr& ds) { + auto context = std::make_shared(); context->pool = gc_memory_pool(); - return ValueOrStop(ds->NewScan(std::move(context))); + auto out = ValueOrStop(ds->NewScan(std::move(context))); + return cpp11::r6(std::shared_ptr(std::move(out)), "ScannerBuilder"); } // [[arrow::export]] -std::shared_ptr dataset___Dataset__schema( - const std::shared_ptr& dataset) { - return dataset->schema(); +R6 dataset___Dataset__schema(const std::shared_ptr& dataset) { + return cpp11::r6(dataset->schema(), "Schema"); } // [[arrow::export]] @@ -50,22 +93,20 @@ std::string dataset___Dataset__type_name(const std::shared_ptr& dat } // [[arrow::export]] -std::shared_ptr dataset___Dataset__ReplaceSchema( - const std::shared_ptr& dataset, - const std::shared_ptr& schm) { - return ValueOrStop(dataset->ReplaceSchema(schm)); +R6 dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, + const std::shared_ptr& schm) { + return cpp11::r6_Dataset(ValueOrStop(dataset->ReplaceSchema(schm))); } // [[arrow::export]] -std::shared_ptr dataset___UnionDataset__create( - const ds::DatasetVector& datasets, const std::shared_ptr& schm) { - return ValueOrStop(ds::UnionDataset::Make(schm, datasets)); +R6 dataset___UnionDataset__create(const ds::DatasetVector& datasets, + const std::shared_ptr& schm) { + return cpp11::r6(ValueOrStop(ds::UnionDataset::Make(schm, datasets)), "UnionDataset"); } // [[arrow::export]] -std::shared_ptr dataset___InMemoryDataset__create( - const std::shared_ptr& table) { - return std::make_shared(table); +R6 dataset___InMemoryDataset__create(const std::shared_ptr& table) { + return cpp11::r6(std::make_shared(table), "InMemoryDataset"); } // [[arrow::export]] @@ -75,15 +116,15 @@ ds::DatasetVector dataset___UnionDataset__children( } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDataset__format( +R6 dataset___FileSystemDataset__format( const std::shared_ptr& dataset) { - return dataset->format(); + return cpp11::r6_FileFormat(dataset->format()); } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDataset__filesystem( +R6 dataset___FileSystemDataset__filesystem( const std::shared_ptr& dataset) { - return dataset->filesystem(); + return cpp11::r6_FileSystem(dataset->filesystem()); } // [[arrow::export]] @@ -95,40 +136,40 @@ std::vector dataset___FileSystemDataset__files( // DatasetFactory, UnionDatasetFactory, FileSystemDatasetFactory // [[arrow::export]] -std::shared_ptr dataset___DatasetFactory__Finish1( - const std::shared_ptr& factory, bool unify_schemas) { +R6 dataset___DatasetFactory__Finish1(const std::shared_ptr& factory, + bool unify_schemas) { ds::FinishOptions opts; if (unify_schemas) { opts.inspect_options.fragments = ds::InspectOptions::kInspectAllFragments; } - return ValueOrStop(factory->Finish(opts)); + return cpp11::r6_Dataset(ValueOrStop(factory->Finish(opts))); } // [[arrow::export]] -std::shared_ptr dataset___DatasetFactory__Finish2( - const std::shared_ptr& factory, - const std::shared_ptr& schema) { - return ValueOrStop(factory->Finish(schema)); +R6 dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, + const std::shared_ptr& schema) { + return cpp11::r6_Dataset(ValueOrStop(factory->Finish(schema))); } // [[arrow::export]] -std::shared_ptr dataset___DatasetFactory__Inspect( - const std::shared_ptr& factory, bool unify_schemas) { +R6 dataset___DatasetFactory__Inspect(const std::shared_ptr& factory, + bool unify_schemas) { ds::InspectOptions opts; if (unify_schemas) { opts.fragments = ds::InspectOptions::kInspectAllFragments; } - return ValueOrStop(factory->Inspect(opts)); + return cpp11::r6(ValueOrStop(factory->Inspect(opts)), "Schema"); } // [[arrow::export]] -std::shared_ptr dataset___UnionDatasetFactory__Make( +R6 dataset___UnionDatasetFactory__Make( const std::vector>& children) { - return ValueOrStop(ds::UnionDatasetFactory::Make(children)); + return cpp11::r6(ValueOrStop(ds::UnionDatasetFactory::Make(children)), + "DatasetFactory"); } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDatasetFactory__Make2( +R6 dataset___FileSystemDatasetFactory__Make2( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, @@ -139,11 +180,13 @@ std::shared_ptr dataset___FileSystemDatasetFactory__Make2( options.partitioning = partitioning; } - return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); + auto factory = + ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); + return cpp11::r6(factory, "FileSystemDatasetFactory"); } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDatasetFactory__Make1( +R6 dataset___FileSystemDatasetFactory__Make1( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format) { @@ -151,7 +194,7 @@ std::shared_ptr dataset___FileSystemDatasetFactory__Make1( } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDatasetFactory__Make3( +R6 dataset___FileSystemDatasetFactory__Make3( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, @@ -162,7 +205,9 @@ std::shared_ptr dataset___FileSystemDatasetFactory__Make3( options.partitioning = factory; } - return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); + auto ptr = + ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); + return cpp11::r6(ptr, "FileSystemDatasetFactory"); } // FileFormat, ParquetFileFormat, IpcFileFormat @@ -174,14 +219,14 @@ std::string dataset___FileFormat__type_name( } // [[arrow::export]] -std::shared_ptr dataset___FileFormat__DefaultWriteOptions( +R6 dataset___FileFormat__DefaultWriteOptions( const std::shared_ptr& fmt) { - return fmt->DefaultWriteOptions(); + return cpp11::r6(fmt->DefaultWriteOptions(), "FileWriteOptions"); } // [[arrow::export]] -std::shared_ptr dataset___ParquetFileFormat__Make( - bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns) { +R6 dataset___ParquetFileFormat__MakeRead(bool use_buffered_stream, int64_t buffer_size, + cpp11::strings dict_columns) { auto fmt = std::make_shared(); fmt->reader_options.use_buffered_stream = use_buffered_stream; @@ -192,7 +237,7 @@ std::shared_ptr dataset___ParquetFileFormat__Make( std::move(dict_columns_vector.begin(), dict_columns_vector.end(), std::inserter(d, d.end())); - return fmt; + return cpp11::r6(fmt, "ParquetFileFormat"); } // [[arrow::export]] @@ -229,41 +274,41 @@ void dataset___IpcFileWriteOptions__update1( } // [[arrow::export]] -std::shared_ptr dataset___IpcFileFormat__Make() { - return std::make_shared(); +R6 dataset___IpcFileFormat__Make() { + return cpp11::r6(std::make_shared(), "IpcFileFormat"); } // [[arrow::export]] -std::shared_ptr dataset___CsvFileFormat__Make( +R6 dataset___CsvFileFormat__Make( const std::shared_ptr& parse_options) { auto format = std::make_shared(); format->parse_options = *parse_options; - return format; + return cpp11::r6(format, "CsvFileFormat"); } // DirectoryPartitioning, HivePartitioning // [[arrow::export]] -std::shared_ptr dataset___DirectoryPartitioning( - const std::shared_ptr& schm) { - return std::make_shared(schm); +R6 dataset___DirectoryPartitioning(const std::shared_ptr& schm) { + return cpp11::r6(std::make_shared(schm), + "DirectoryPartitioning"); } // [[arrow::export]] -std::shared_ptr dataset___DirectoryPartitioning__MakeFactory( +R6 dataset___DirectoryPartitioning__MakeFactory( const std::vector& field_names) { - return ds::DirectoryPartitioning::MakeFactory(field_names); + return cpp11::r6(ds::DirectoryPartitioning::MakeFactory(field_names), + "DirectoryPartitioningFactory"); } // [[arrow::export]] -std::shared_ptr dataset___HivePartitioning( - const std::shared_ptr& schm) { - return std::make_shared(schm); +R6 dataset___HivePartitioning(const std::shared_ptr& schm) { + return cpp11::r6(std::make_shared(schm), "HivePartitioning"); } // [[arrow::export]] -std::shared_ptr dataset___HivePartitioning__MakeFactory() { - return ds::HivePartitioning::MakeFactory(); +R6 dataset___HivePartitioning__MakeFactory() { + return cpp11::r6(ds::HivePartitioning::MakeFactory(), "HivePartitioningFactory"); } // ScannerBuilder, Scanner @@ -296,26 +341,24 @@ void dataset___ScannerBuilder__BatchSize(const std::shared_ptr dataset___ScannerBuilder__schema( - const std::shared_ptr& sb) { - return sb->schema(); +R6 dataset___ScannerBuilder__schema(const std::shared_ptr& sb) { + return cpp11::r6(sb->schema(), "Schema"); } // [[arrow::export]] -std::shared_ptr dataset___ScannerBuilder__Finish( - const std::shared_ptr& sb) { - return ValueOrStop(sb->Finish()); +R6 dataset___ScannerBuilder__Finish(const std::shared_ptr& sb) { + auto out = ValueOrStop(sb->Finish()); + + return cpp11::r6(std::shared_ptr(std::move(out)), "Scanner"); } // [[arrow::export]] -std::shared_ptr dataset___Scanner__ToTable( - const std::shared_ptr& scanner) { - return ValueOrStop(scanner->ToTable()); +R6 dataset___Scanner__ToTable(const std::shared_ptr& scanner) { + return cpp11::r6(ValueOrStop(scanner->ToTable()), "Table"); } // [[arrow::export]] -std::shared_ptr dataset___Scanner__head( - const std::shared_ptr& scanner, int n) { +R6 dataset___Scanner__head(const std::shared_ptr& scanner, int n) { // TODO: make this a full Slice with offset > 0 std::vector> batches; std::shared_ptr current_batch; @@ -329,7 +372,8 @@ std::shared_ptr dataset___Scanner__head( } if (n < 0) break; } - return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); + auto out = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); + return cpp11::r6(out, "Table"); } // [[arrow::export]] diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index eb5ec7e6231..de1ddd25d36 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -253,10 +253,11 @@ arrow::TimeUnit::type TimestampType__unit( } // [[arrow::export]] -std::shared_ptr DictionaryType__initialize( - const std::shared_ptr& index_type, - const std::shared_ptr& value_type, bool ordered) { - return ValueOrStop(arrow::DictionaryType::Make(index_type, value_type, ordered)); +R6 DictionaryType__initialize(const std::shared_ptr& index_type, + const std::shared_ptr& value_type, + bool ordered) { + auto type = ValueOrStop(arrow::DictionaryType::Make(index_type, value_type, ordered)); + return cpp11::r6(type, "DictionaryType"); } // [[arrow::export]] @@ -282,9 +283,9 @@ bool DictionaryType__ordered(const std::shared_ptr& type) } // [[arrow::export]] -std::shared_ptr StructType__GetFieldByName( - const std::shared_ptr& type, const std::string& name) { - return type->GetFieldByName(name); +R6 StructType__GetFieldByName(const std::shared_ptr& type, + const std::string& name) { + return cpp11::r6(type->GetFieldByName(name), "Field"); } // [[arrow::export]] @@ -294,9 +295,8 @@ int StructType__GetFieldIndex(const std::shared_ptr& type, } // [[arrow::export]] -std::shared_ptr ListType__value_field( - const std::shared_ptr& type) { - return type->value_field(); +R6 ListType__value_field(const std::shared_ptr& type) { + return cpp11::r6(type->value_field(), "Field"); } // [[arrow::export]] @@ -306,9 +306,8 @@ std::shared_ptr ListType__value_type( } // [[arrow::export]] -std::shared_ptr LargeListType__value_field( - const std::shared_ptr& type) { - return type->value_field(); +R6 LargeListType__value_field(const std::shared_ptr& type) { + return cpp11::r6(type->value_field(), "Field"); } // [[arrow::export]] @@ -318,9 +317,8 @@ std::shared_ptr LargeListType__value_type( } // [[arrow::export]] -std::shared_ptr FixedSizeListType__value_field( - const std::shared_ptr& type) { - return type->value_field(); +R6 FixedSizeListType__value_field(const std::shared_ptr& type) { + return cpp11::r6(type->value_field(), "Field"); } // [[arrow::export]] diff --git a/r/src/expression.cpp b/r/src/expression.cpp index 575dddc7da7..7443589aa3c 100644 --- a/r/src/expression.cpp +++ b/r/src/expression.cpp @@ -23,89 +23,77 @@ namespace ds = ::arrow::dataset; // [[arrow::export]] -std::shared_ptr dataset___expr__field_ref(std::string name) { - return ds::field_ref(std::move(name)); +R6 dataset___expr__field_ref(std::string name) { + return cpp11::r6(ds::field_ref(std::move(name)), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__equal( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::equal(lhs, rhs); +R6 dataset___expr__equal(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::equal(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__not_equal( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::not_equal(lhs, rhs); +R6 dataset___expr__not_equal(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::not_equal(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__greater( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::greater(lhs, rhs); +R6 dataset___expr__greater(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::greater(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__greater_equal( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::greater_equal(lhs, rhs); +R6 dataset___expr__greater_equal(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::greater_equal(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__less( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::less(lhs, rhs); +R6 dataset___expr__less(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::less(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__less_equal( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::less_equal(lhs, rhs); +R6 dataset___expr__less_equal(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::less_equal(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__in( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return lhs->In(rhs).Copy(); +R6 dataset___expr__in(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(lhs->In(rhs).Copy(), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__and( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::and_(lhs, rhs); +R6 dataset___expr__and(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::and_(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__or( - const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { - return ds::or_(lhs, rhs); +R6 dataset___expr__or(const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { + return cpp11::r6(ds::or_(lhs, rhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__not( - const std::shared_ptr& lhs) { - return ds::not_(lhs); +R6 dataset___expr__not(const std::shared_ptr& lhs) { + return cpp11::r6(ds::not_(lhs), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__is_valid( - const std::shared_ptr& lhs) { - return lhs->IsValid().Copy(); +R6 dataset___expr__is_valid(const std::shared_ptr& lhs) { + return cpp11::r6(lhs->IsValid().Copy(), "Expression"); } // [[arrow::export]] -std::shared_ptr dataset___expr__scalar( - const std::shared_ptr& x) { - return ds::scalar(x); +R6 dataset___expr__scalar(const std::shared_ptr& x) { + return cpp11::r6(ds::scalar(x), "Expression"); } // [[arrow::export]] diff --git a/r/src/feather.cpp b/r/src/feather.cpp index 22bdd7acde0..0edf4708002 100644 --- a/r/src/feather.cpp +++ b/r/src/feather.cpp @@ -47,7 +47,7 @@ int ipc___feather___Reader__version( } // [[arrow::export]] -std::shared_ptr ipc___feather___Reader__Read( +R6 ipc___feather___Reader__Read( const std::shared_ptr& reader, SEXP columns) { std::shared_ptr table; @@ -69,13 +69,14 @@ std::shared_ptr ipc___feather___Reader__Read( break; } - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr ipc___feather___Reader__Open( +R6 ipc___feather___Reader__Open( const std::shared_ptr& stream) { - return ValueOrStop(arrow::ipc::feather::Reader::Open(stream)); + return cpp11::r6(ValueOrStop(arrow::ipc::feather::Reader::Open(stream)), + "FeatherReader"); } // [[arrow::export]] diff --git a/r/src/field.cpp b/r/src/field.cpp index 914d270c6f4..67469ca863b 100644 --- a/r/src/field.cpp +++ b/r/src/field.cpp @@ -21,10 +21,10 @@ #include // [[arrow::export]] -std::shared_ptr Field__initialize( - const std::string& name, const std::shared_ptr& field, - bool nullable = true) { - return arrow::field(name, field, nullable); +R6 Field__initialize(const std::string& name, + const std::shared_ptr& field, + bool nullable = true) { + return cpp11::r6(arrow::field(name, field, nullable), "Field"); } // [[arrow::export]] diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 53959804fe8..f365d3298b5 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -102,14 +102,13 @@ bool fs___FileSelector__recursive(const std::shared_ptr& selec } // [[arrow::export]] -std::shared_ptr fs___FileSelector__create(const std::string& base_dir, - bool allow_not_found, - bool recursive) { +R6 fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, + bool recursive) { auto selector = std::make_shared(); selector->base_dir = base_dir; selector->allow_not_found = allow_not_found; selector->recursive = recursive; - return selector; + return cpp11::r6(selector, "FileSelector"); } // FileSystem @@ -181,27 +180,27 @@ void fs___FileSystem__CopyFile(const std::shared_ptr& file_syste } // [[arrow::export]] -std::shared_ptr fs___FileSystem__OpenInputStream( - const std::shared_ptr& file_system, const std::string& path) { - return ValueOrStop(file_system->OpenInputStream(path)); +R6 fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, + const std::string& path) { + return cpp11::r6(ValueOrStop(file_system->OpenInputStream(path)), "InputStream"); } // [[arrow::export]] -std::shared_ptr fs___FileSystem__OpenInputFile( - const std::shared_ptr& file_system, const std::string& path) { - return ValueOrStop(file_system->OpenInputFile(path)); +R6 fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, + const std::string& path) { + return cpp11::r6(ValueOrStop(file_system->OpenInputFile(path)), "RandomAccessFile"); } // [[arrow::export]] -std::shared_ptr fs___FileSystem__OpenOutputStream( - const std::shared_ptr& file_system, const std::string& path) { - return ValueOrStop(file_system->OpenOutputStream(path)); +R6 fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, + const std::string& path) { + return cpp11::r6(ValueOrStop(file_system->OpenOutputStream(path)), "OutputStream"); } // [[arrow::export]] -std::shared_ptr fs___FileSystem__OpenAppendStream( - const std::shared_ptr& file_system, const std::string& path) { - return ValueOrStop(file_system->OpenAppendStream(path)); +R6 fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, + const std::string& path) { + return cpp11::r6(ValueOrStop(file_system->OpenAppendStream(path)), "OutputStream"); } // [[arrow::export]] @@ -211,14 +210,15 @@ std::string fs___FileSystem__type_name( } // [[arrow::export]] -std::shared_ptr fs___LocalFileSystem__create() { - return std::make_shared(); +R6 fs___LocalFileSystem__create() { + return cpp11::r6(std::make_shared(), "LocalFileSystem"); } // [[arrow::export]] -std::shared_ptr fs___SubTreeFileSystem__create( - const std::string& base_path, const std::shared_ptr& base_fs) { - return std::make_shared(base_path, base_fs); +R6 fs___SubTreeFileSystem__create(const std::string& base_path, + const std::shared_ptr& base_fs) { + return cpp11::r6(std::make_shared(base_path, base_fs), + "SubTreeFileSystem"); } // [[arrow::export]] @@ -239,7 +239,9 @@ cpp11::writable::list fs___FileSystemFromUri(const std::string& path) { std::string out_path; auto file_system = ValueOrStop(fs::FileSystemFromUri(path, &out_path)); - return cpp11::writable::list({"fs"_nm = file_system, "path"_nm = out_path}); + // TODO: needs to call the FileSystem dispatcher + cpp11::sexp out_fs = cpp11::r6(file_system, "FileSystem"); + return cpp11::writable::list({"fs"_nm = out_fs, "path"_nm = out_path}); } // [[arrow::export]] @@ -259,12 +261,12 @@ void fs___CopyFiles(const std::shared_ptr& source_fs, #include // [[s3::export]] -std::shared_ptr fs___S3FileSystem__create( - bool anonymous = false, std::string access_key = "", std::string secret_key = "", - std::string session_token = "", std::string role_arn = "", - std::string session_name = "", std::string external_id = "", int load_frequency = 900, - std::string region = "", std::string endpoint_override = "", std::string scheme = "", - bool background_writes = true) { +R6 fs___S3FileSystem__create(bool anonymous = false, std::string access_key = "", + std::string secret_key = "", std::string session_token = "", + std::string role_arn = "", std::string session_name = "", + std::string external_id = "", int load_frequency = 900, + std::string region = "", std::string endpoint_override = "", + std::string scheme = "", bool background_writes = true) { fs::S3Options s3_opts; // Handle auth (anonymous, keys, default) // (validation/internal coherence handled in R) @@ -295,7 +297,7 @@ std::shared_ptr fs___S3FileSystem__create( s3_opts.background_writes = background_writes; StopIfNotOk(fs::EnsureS3Initialized()); - return ValueOrStop(fs::S3FileSystem::Make(s3_opts)); + return cpp11::r6(ValueOrStop(fs::S3FileSystem::Make(s3_opts)), "S3FileSystem"); } // [[s3::export]] diff --git a/r/src/io.cpp b/r/src/io.cpp index 6a912dd7815..c28472eba40 100644 --- a/r/src/io.cpp +++ b/r/src/io.cpp @@ -24,9 +24,8 @@ // ------ arrow::io::Readable // [[arrow::export]] -std::shared_ptr io___Readable__Read( - const std::shared_ptr& x, int64_t nbytes) { - return ValueOrStop(x->Read(nbytes)); +R6 io___Readable__Read(const std::shared_ptr& x, int64_t nbytes) { + return cpp11::r6(ValueOrStop(x->Read(nbytes)), "Buffer"); } // ------ arrow::io::InputStream @@ -70,34 +69,32 @@ int64_t io___RandomAccessFile__Tell( } // [[arrow::export]] -std::shared_ptr io___RandomAccessFile__Read0( - const std::shared_ptr& x) { +R6 io___RandomAccessFile__Read0(const std::shared_ptr& x) { int64_t current = ValueOrStop(x->Tell()); int64_t n = ValueOrStop(x->GetSize()); - return ValueOrStop(x->Read(n - current)); + return cpp11::r6(ValueOrStop(x->Read(n - current)), "Buffer"); } // [[arrow::export]] -std::shared_ptr io___RandomAccessFile__ReadAt( - const std::shared_ptr& x, int64_t position, - int64_t nbytes) { - return ValueOrStop(x->ReadAt(position, nbytes)); +R6 io___RandomAccessFile__ReadAt(const std::shared_ptr& x, + int64_t position, int64_t nbytes) { + return cpp11::r6(ValueOrStop(x->ReadAt(position, nbytes)), "Buffer"); } // ------ arrow::io::MemoryMappedFile // [[arrow::export]] -std::shared_ptr io___MemoryMappedFile__Create( - const std::string& path, int64_t size) { - return ValueOrStop(arrow::io::MemoryMappedFile::Create(path, size)); +R6 io___MemoryMappedFile__Create(const std::string& path, int64_t size) { + auto out = ValueOrStop(arrow::io::MemoryMappedFile::Create(path, size)); + return cpp11::r6(out, "MemoryMappedFile"); } // [[arrow::export]] -std::shared_ptr io___MemoryMappedFile__Open( - const std::string& path, arrow::io::FileMode::type mode) { - return ValueOrStop(arrow::io::MemoryMappedFile::Open(path, mode)); +R6 io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode) { + auto out = ValueOrStop(arrow::io::MemoryMappedFile::Open(path, mode)); + return cpp11::r6(out, "MemoryMappedFile"); } // [[arrow::export]] @@ -109,17 +106,17 @@ void io___MemoryMappedFile__Resize(const std::shared_ptr io___ReadableFile__Open( - const std::string& path) { - return ValueOrStop(arrow::io::ReadableFile::Open(path, gc_memory_pool())); +R6 io___ReadableFile__Open(const std::string& path) { + auto file = ValueOrStop(arrow::io::ReadableFile::Open(path, gc_memory_pool())); + return cpp11::r6(file, "ReadableFile"); } // ------ arrow::io::BufferReader // [[arrow::export]] -std::shared_ptr io___BufferReader__initialize( - const std::shared_ptr& buffer) { - return std::make_shared(buffer); +R6 io___BufferReader__initialize(const std::shared_ptr& buffer) { + auto reader = std::make_shared(buffer); + return cpp11::r6(reader, "BufferReader"); } // ------- arrow::io::Writable @@ -140,18 +137,18 @@ int64_t io___OutputStream__Tell(const std::shared_ptr& // ------ arrow::io::FileOutputStream // [[arrow::export]] -std::shared_ptr io___FileOutputStream__Open( - const std::string& path) { - return ValueOrStop(arrow::io::FileOutputStream::Open(path)); +R6 io___FileOutputStream__Open(const std::string& path) { + return cpp11::r6(ValueOrStop(arrow::io::FileOutputStream::Open(path)), + "FileOutputStream"); } // ------ arrow::BufferOutputStream // [[arrow::export]] -std::shared_ptr io___BufferOutputStream__Create( - int64_t initial_capacity) { - return ValueOrStop( - arrow::io::BufferOutputStream::Create(initial_capacity, gc_memory_pool())); +R6 io___BufferOutputStream__Create(int64_t initial_capacity) { + auto stream = ValueOrStop( + arrow::io::BufferOutputStream::Create(initial_capacity, gc_memory_pool())); + return cpp11::r6(stream, "BufferOutputStream"); } // [[arrow::export]] @@ -161,9 +158,9 @@ int64_t io___BufferOutputStream__capacity( } // [[arrow::export]] -std::shared_ptr io___BufferOutputStream__Finish( +R6 io___BufferOutputStream__Finish( const std::shared_ptr& stream) { - return ValueOrStop(stream->Finish()); + return cpp11::r6(ValueOrStop(stream->Finish()), "Buffer"); } // [[arrow::export]] diff --git a/r/src/json.cpp b/r/src/json.cpp index 87d40623f6b..86e9f8964ef 100644 --- a/r/src/json.cpp +++ b/r/src/json.cpp @@ -21,37 +21,36 @@ #include // [[arrow::export]] -std::shared_ptr json___ReadOptions__initialize(bool use_threads, - int block_size) { +R6 json___ReadOptions__initialize(bool use_threads, int block_size) { auto res = std::make_shared(arrow::json::ReadOptions::Defaults()); res->use_threads = use_threads; res->block_size = block_size; - return res; + return cpp11::r6(res, "JsonReadOptions"); } // [[arrow::export]] -std::shared_ptr json___ParseOptions__initialize( - bool newlines_in_values) { +R6 json___ParseOptions__initialize(bool newlines_in_values) { auto res = std::make_shared(arrow::json::ParseOptions::Defaults()); res->newlines_in_values = newlines_in_values; - return res; + return cpp11::r6(res, "JsonParseOptions"); } // [[arrow::export]] -std::shared_ptr json___TableReader__Make( +R6 json___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options) { - return ValueOrStop(arrow::json::TableReader::Make(gc_memory_pool(), input, - *read_options, *parse_options)); + auto reader = ValueOrStop(arrow::json::TableReader::Make(gc_memory_pool(), input, + *read_options, *parse_options)); + return cpp11::r6(reader, "JsonTableReader"); } // [[arrow::export]] -std::shared_ptr json___TableReader__Read( +R6 json___TableReader__Read( const std::shared_ptr& table_reader) { - return ValueOrStop(table_reader->Read()); + return cpp11::r6(ValueOrStop(table_reader->Read()), "Table"); } #endif diff --git a/r/src/memorypool.cpp b/r/src/memorypool.cpp index 05b79dc3929..db8f46c5254 100644 --- a/r/src/memorypool.cpp +++ b/r/src/memorypool.cpp @@ -65,8 +65,9 @@ static GcMemoryPool g_pool; arrow::MemoryPool* gc_memory_pool() { return &g_pool; } // [[arrow::export]] -std::shared_ptr MemoryPool__default() { - return std::shared_ptr(&g_pool, [](...) {}); +R6 MemoryPool__default() { + auto pool = std::shared_ptr(&g_pool, [](...) {}); + return cpp11::r6(pool, "MemoryPool"); } // [[arrow::export]] diff --git a/r/src/message.cpp b/r/src/message.cpp index fd50007d93d..01890fddae3 100644 --- a/r/src/message.cpp +++ b/r/src/message.cpp @@ -27,15 +27,13 @@ int64_t ipc___Message__body_length(const std::unique_ptr& m } // [[arrow::export]] -std::shared_ptr ipc___Message__metadata( - const std::unique_ptr& message) { - return message->metadata(); +R6 ipc___Message__metadata(const std::unique_ptr& message) { + return cpp11::r6(message->metadata(), "Buffer"); } // [[arrow::export]] -std::shared_ptr ipc___Message__body( - const std::unique_ptr& message) { - return message->body(); +R6 ipc___Message__body(const std::unique_ptr& message) { + return cpp11::r6(message->body(), "Buffer"); } // [[arrow::export]] @@ -56,48 +54,49 @@ bool ipc___Message__Equals(const std::unique_ptr& x, } // [[arrow::export]] -std::shared_ptr ipc___ReadRecordBatch__Message__Schema( +R6 ipc___ReadRecordBatch__Message__Schema( const std::unique_ptr& message, const std::shared_ptr& schema) { // TODO: perhaps this should come from the R side arrow::ipc::DictionaryMemo memo; - return ValueOrStop(arrow::ipc::ReadRecordBatch(*message, schema, &memo, - arrow::ipc::IpcReadOptions::Defaults())); + auto batch = ValueOrStop(arrow::ipc::ReadRecordBatch( + *message, schema, &memo, arrow::ipc::IpcReadOptions::Defaults())); + return cpp11::r6(batch, "RecordBatch"); } // [[arrow::export]] -std::shared_ptr ipc___ReadSchema_InputStream( - const std::shared_ptr& stream) { +R6 ipc___ReadSchema_InputStream(const std::shared_ptr& stream) { // TODO: promote to function argument arrow::ipc::DictionaryMemo memo; - return ValueOrStop(arrow::ipc::ReadSchema(stream.get(), &memo)); + return cpp11::r6(ValueOrStop(arrow::ipc::ReadSchema(stream.get(), &memo)), "Schema"); } // [[arrow::export]] -std::shared_ptr ipc___ReadSchema_Message( - const std::unique_ptr& message) { +R6 ipc___ReadSchema_Message(const std::unique_ptr& message) { arrow::ipc::DictionaryMemo empty_memo; - return ValueOrStop(arrow::ipc::ReadSchema(*message, &empty_memo)); + return cpp11::r6(ValueOrStop(arrow::ipc::ReadSchema(*message, &empty_memo)), "Schema"); } //--------- MessageReader // [[arrow::export]] -std::shared_ptr ipc___MessageReader__Open( - const std::shared_ptr& stream) { - return arrow::ipc::MessageReader::Open(stream); +R6 ipc___MessageReader__Open(const std::shared_ptr& stream) { + std::shared_ptr reader(arrow::ipc::MessageReader::Open(stream)); + return cpp11::r6(reader, "MessageReader"); } // [[arrow::export]] -std::shared_ptr ipc___MessageReader__ReadNextMessage( +R6 ipc___MessageReader__ReadNextMessage( const std::unique_ptr& reader) { - return ValueOrStop(reader->ReadNextMessage()); + std::shared_ptr msg = ValueOrStop(reader->ReadNextMessage()); + return cpp11::r6(msg, "Message"); } // [[arrow::export]] -std::shared_ptr ipc___ReadMessage( - const std::shared_ptr& stream) { - return ValueOrStop(arrow::ipc::ReadMessage(stream.get())); +R6 ipc___ReadMessage(const std::shared_ptr& stream) { + std::shared_ptr msg = + ValueOrStop(arrow::ipc::ReadMessage(stream.get())); + return cpp11::r6(msg, "Message"); } #endif diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index 6f8db31410f..b749c95b4c0 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -25,9 +25,9 @@ #include // [[arrow::export]] -std::shared_ptr -parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { - return std::make_shared(use_threads); +R6 parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { + return cpp11::r6(std::make_shared(use_threads), + "ParquetReaderProperties"); } // [[arrow::export]] @@ -56,67 +56,68 @@ void parquet___arrow___ArrowReaderProperties__set_read_dictionary( } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__OpenFile( +R6 parquet___arrow___FileReader__OpenFile( const std::shared_ptr& file, const std::shared_ptr& props) { std::unique_ptr reader; parquet::arrow::FileReaderBuilder builder; PARQUET_THROW_NOT_OK(builder.Open(file)); PARQUET_THROW_NOT_OK( - builder.memory_pool(gc_memory_pool())->properties(*props)->Build(&reader)); - return std::move(reader); + builder.memory_pool(gc_memory_pool())->properties(*props)->Build(&reader)); + return cpp11::r6(std::shared_ptr(std::move(reader)), + "ParquetFileReader"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadTable1( +R6 parquet___arrow___FileReader__ReadTable1( const std::shared_ptr& reader) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadTable(&table)); - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadTable2( +R6 parquet___arrow___FileReader__ReadTable2( const std::shared_ptr& reader, const std::vector& column_indices) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadTable(column_indices, &table)); - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadRowGroup1( +R6 parquet___arrow___FileReader__ReadRowGroup1( const std::shared_ptr& reader, int i) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, &table)); - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadRowGroup2( +R6 parquet___arrow___FileReader__ReadRowGroup2( const std::shared_ptr& reader, int i, const std::vector& column_indices) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, column_indices, &table)); - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadRowGroups1( +R6 parquet___arrow___FileReader__ReadRowGroups1( const std::shared_ptr& reader, const std::vector& row_groups) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, &table)); - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadRowGroups2( +R6 parquet___arrow___FileReader__ReadRowGroups2( const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, column_indices, &table)); - return table; + return cpp11::r6(table, "Table"); } // [[arrow::export]] @@ -138,11 +139,11 @@ int parquet___arrow___FileReader__num_row_groups( } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__ReadColumn( +R6 parquet___arrow___FileReader__ReadColumn( const std::shared_ptr& reader, int i) { std::shared_ptr array; PARQUET_THROW_NOT_OK(reader->ReadColumn(i - 1, &array)); - return array; + return cpp11::r6(array, "ChunkedArray"); } namespace parquet { @@ -160,9 +161,9 @@ class ArrowWriterPropertiesBuilder : public ArrowWriterProperties::Builder { } // namespace parquet // [[arrow::export]] -std::shared_ptr parquet___ArrowWriterProperties___create( - bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, - int timestamp_unit) { +R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, + bool use_deprecated_int96_timestamps, + int timestamp_unit) { auto builder = std::make_shared(); builder->store_schema(); @@ -177,13 +178,13 @@ std::shared_ptr parquet___ArrowWriterProperties_ builder->coerce_timestamps(static_cast(timestamp_unit)); } - return builder->build(); + return cpp11::r6(builder->build(), "ParquetArrowWriterProperties"); } // [[arrow::export]] -std::shared_ptr -parquet___WriterProperties___Builder__create() { - return std::make_shared(); +R6 parquet___WriterProperties___Builder__create() { + return cpp11::r6(std::make_shared(), + "ParquetWriterPropertiesBuilder"); } // [[arrow::export]] @@ -275,13 +276,13 @@ void parquet___ArrowWriterProperties___Builder__data_page_size( } // [[arrow::export]] -std::shared_ptr parquet___WriterProperties___Builder__build( +R6 parquet___WriterProperties___Builder__build( const std::shared_ptr& builder) { - return builder->build(); + return cpp11::r6(builder->build(), "ParquetWriterProperties"); } // [[arrow::export]] -std::shared_ptr parquet___arrow___ParquetFileWriter__Open( +R6 parquet___arrow___ParquetFileWriter__Open( const std::shared_ptr& schema, const std::shared_ptr& sink, const std::shared_ptr& properties, @@ -289,7 +290,8 @@ std::shared_ptr parquet___arrow___ParquetFileWriter_ std::unique_ptr writer; PARQUET_THROW_NOT_OK(parquet::arrow::FileWriter::Open( *schema, gc_memory_pool(), sink, properties, arrow_properties, &writer)); - return std::move(writer); + return cpp11::r6(std::shared_ptr(std::move(writer)), + "ParquetFileWriter"); } // [[arrow::export]] @@ -316,11 +318,11 @@ void parquet___arrow___WriteTable( } // [[arrow::export]] -std::shared_ptr parquet___arrow___FileReader__GetSchema( +R6 parquet___arrow___FileReader__GetSchema( const std::shared_ptr& reader) { std::shared_ptr schema; StopIfNotOk(reader->GetSchema(&schema)); - return schema; + return cpp11::r6(schema, "Schema"); } #endif diff --git a/r/src/py-to-r.cpp b/r/src/py-to-r.cpp index d2ff13bc2f2..1c41139b292 100644 --- a/r/src/py-to-r.cpp +++ b/r/src/py-to-r.cpp @@ -20,16 +20,15 @@ #if defined(ARROW_R_WITH_ARROW) // [[arrow::export]] -std::shared_ptr ImportArray(arrow::r::Pointer array, - arrow::r::Pointer schema) { - return ValueOrStop(arrow::ImportArray(array, schema)); +R6 ImportArray(arrow::r::Pointer array, + arrow::r::Pointer schema) { + return cpp11::r6_Array(ValueOrStop(arrow::ImportArray(array, schema))); } // [[arrow::export]] -std::shared_ptr ImportRecordBatch( - arrow::r::Pointer array, - arrow::r::Pointer schema) { - return ValueOrStop(arrow::ImportRecordBatch(array, schema)); +R6 ImportRecordBatch(arrow::r::Pointer array, + arrow::r::Pointer schema) { + return cpp11::r6(ValueOrStop(arrow::ImportRecordBatch(array, schema)), "RecordBatch"); } // [[arrow::export]] diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp index 02b61f60633..a2bc3217b78 100644 --- a/r/src/recordbatch.cpp +++ b/r/src/recordbatch.cpp @@ -37,19 +37,18 @@ int RecordBatch__num_rows(const std::shared_ptr& x) { } // [[arrow::export]] -std::shared_ptr RecordBatch__schema( - const std::shared_ptr& x) { - return x->schema(); +R6 RecordBatch__schema(const std::shared_ptr& x) { + return cpp11::r6(x->schema(), "Schema"); } // [[arrow::export]] -std::shared_ptr RecordBatch__ReplaceSchemaMetadata( - const std::shared_ptr& x, cpp11::strings metadata) { +R6 RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& x, + cpp11::strings metadata) { auto vec_metadata = cpp11::as_cpp>(metadata); auto names_metadata = cpp11::as_cpp>(metadata.names()); auto kv = std::shared_ptr( new arrow::KeyValueMetadata(names_metadata, vec_metadata)); - return x->ReplaceSchemaMetadata(kv); + return cpp11::r6(x->ReplaceSchemaMetadata(kv), "RecordBatch"); } // [[arrow::export]] @@ -64,21 +63,20 @@ arrow::ArrayVector RecordBatch__columns( } // [[arrow::export]] -std::shared_ptr RecordBatch__column( - const std::shared_ptr& batch, R_xlen_t i) { +R6 RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i) { arrow::r::validate_index(i, batch->num_columns()); - return batch->column(i); + return cpp11::r6_Array(batch->column(i)); } // [[arrow::export]] -std::shared_ptr RecordBatch__GetColumnByName( - const std::shared_ptr& batch, const std::string& name) { - return batch->GetColumnByName(name); +R6 RecordBatch__GetColumnByName(const std::shared_ptr& batch, + const std::string& name) { + return cpp11::r6_Array(batch->GetColumnByName(name)); } // [[arrow::export]] -std::shared_ptr RecordBatch__SelectColumns( - const std::shared_ptr& batch, cpp11::integers indices) { +R6 RecordBatch__SelectColumns(const std::shared_ptr& batch, + cpp11::integers indices) { R_xlen_t n = indices.size(); auto nrows = batch->num_rows(); @@ -92,7 +90,7 @@ std::shared_ptr RecordBatch__SelectColumns( } auto schema = std::make_shared(std::move(fields)); - return arrow::RecordBatch::Make(schema, nrows, columns); + return cpp11::r6(arrow::RecordBatch::Make(schema, nrows, columns), "RecordBatch"); } // [[arrow::export]] @@ -103,10 +101,10 @@ bool RecordBatch__Equals(const std::shared_ptr& self, } // [[arrow::export]] -std::shared_ptr RecordBatch__RemoveColumn( - const std::shared_ptr& batch, R_xlen_t i) { +R6 RecordBatch__RemoveColumn(const std::shared_ptr& batch, + R_xlen_t i) { arrow::r::validate_index(i, batch->num_columns()); - return ValueOrStop(batch->RemoveColumn(i)); + return cpp11::r6(ValueOrStop(batch->RemoveColumn(i)), "RecordBatch"); } // [[arrow::export]] @@ -128,18 +126,17 @@ cpp11::writable::strings RecordBatch__names( } // [[arrow::export]] -std::shared_ptr RecordBatch__Slice1( - const std::shared_ptr& self, R_xlen_t offset) { +R6 RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, self->num_rows()); - return self->Slice(offset); + return cpp11::r6(self->Slice(offset), "RecordBatch"); } // [[arrow::export]] -std::shared_ptr RecordBatch__Slice2( - const std::shared_ptr& self, R_xlen_t offset, R_xlen_t length) { +R6 RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t offset, + R_xlen_t length) { arrow::r::validate_slice_offset(offset, self->num_rows()); arrow::r::validate_slice_length(length, self->num_rows() - offset); - return self->Slice(offset, length); + return cpp11::r6(self->Slice(offset, length), "RecordBatch"); } // [[arrow::export]] @@ -163,14 +160,15 @@ cpp11::raws ipc___SerializeRecordBatch__Raw( } // [[arrow::export]] -std::shared_ptr ipc___ReadRecordBatch__InputStream__Schema( +R6 ipc___ReadRecordBatch__InputStream__Schema( const std::shared_ptr& stream, const std::shared_ptr& schema) { // TODO: promote to function arg arrow::ipc::DictionaryMemo memo; StopIfNotOk(memo.fields().AddSchemaFields(*schema)); - return ValueOrStop(arrow::ipc::ReadRecordBatch( + auto batch = ValueOrStop(arrow::ipc::ReadRecordBatch( schema, &memo, arrow::ipc::IpcReadOptions::Defaults(), stream.get())); + return cpp11::r6(batch, "RecordBatch"); } namespace arrow { @@ -260,7 +258,7 @@ arrow::Status CollectRecordBatchArrays( } // namespace arrow // [[arrow::export]] -std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) { +R6 RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) { bool infer_schema = !Rf_inherits(schema_sxp, "Schema"); int num_fields; @@ -273,7 +271,7 @@ std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SE // RecordBatch if (!infer_schema) { - return RecordBatch__from_arrays__known_schema(schema, lst); + return cpp11::r6(RecordBatch__from_arrays__known_schema(schema, lst), "RecordBatch"); } // RecordBatch @@ -285,7 +283,8 @@ std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SE int64_t num_rows = 0; StopIfNotOk(arrow::r::check_consistent_array_size(arrays, &num_rows)); - return arrow::RecordBatch::Make(schema, num_rows, arrays); + auto out = arrow::RecordBatch::Make(schema, num_rows, arrays); + return cpp11::r6(out, "RecordBatch"); } #endif diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp index 7ecb42002a9..8101a274480 100644 --- a/r/src/recordbatchreader.cpp +++ b/r/src/recordbatchreader.cpp @@ -22,26 +22,24 @@ #include // [[arrow::export]] -std::shared_ptr RecordBatchReader__schema( - const std::shared_ptr& reader) { - return reader->schema(); +R6 RecordBatchReader__schema(const std::shared_ptr& reader) { + return cpp11::r6(reader->schema(), "Schema"); } // [[arrow::export]] -std::shared_ptr RecordBatchReader__ReadNext( - const std::shared_ptr& reader) { +R6 RecordBatchReader__ReadNext(const std::shared_ptr& reader) { std::shared_ptr batch; StopIfNotOk(reader->ReadNext(&batch)); - return batch; + return cpp11::r6(batch, "RecordBatch"); } // -------- RecordBatchStreamReader // [[arrow::export]] -std::shared_ptr ipc___RecordBatchStreamReader__Open( +R6 ipc___RecordBatchStreamReader__Open( const std::shared_ptr& stream) { - std::shared_ptr reader; - return ValueOrStop(arrow::ipc::RecordBatchStreamReader::Open(stream)); + auto reader = ValueOrStop(arrow::ipc::RecordBatchStreamReader::Open(stream)); + return cpp11::r6(reader, "RecordBatchStreamReader"); } // [[arrow::export]] @@ -63,9 +61,9 @@ std::vector> ipc___RecordBatchStreamReader__ // -------- RecordBatchFileReader // [[arrow::export]] -std::shared_ptr ipc___RecordBatchFileReader__schema( +R6 ipc___RecordBatchFileReader__schema( const std::shared_ptr& reader) { - return reader->schema(); + return cpp11::r6(reader->schema(), "Schema"); } // [[arrow::export]] @@ -75,23 +73,23 @@ int ipc___RecordBatchFileReader__num_record_batches( } // [[arrow::export]] -std::shared_ptr ipc___RecordBatchFileReader__ReadRecordBatch( +R6 ipc___RecordBatchFileReader__ReadRecordBatch( const std::shared_ptr& reader, int i) { if (i < 0 && i >= reader->num_record_batches()) { cpp11::stop("Record batch index out of bounds"); } - return ValueOrStop(reader->ReadRecordBatch(i)); + return cpp11::r6(ValueOrStop(reader->ReadRecordBatch(i)), "RecordBatch"); } // [[arrow::export]] -std::shared_ptr ipc___RecordBatchFileReader__Open( +SEXP ipc___RecordBatchFileReader__Open( const std::shared_ptr& file) { - std::shared_ptr reader; - return ValueOrStop(arrow::ipc::RecordBatchFileReader::Open(file)); + auto reader = ValueOrStop(arrow::ipc::RecordBatchFileReader::Open(file)); + return cpp11::r6(reader, "RecordBatchFileReader"); } // [[arrow::export]] -std::shared_ptr Table__from_RecordBatchFileReader( +R6 Table__from_RecordBatchFileReader( const std::shared_ptr& reader) { int num_batches = reader->num_record_batches(); std::vector> batches(num_batches); @@ -99,11 +97,12 @@ std::shared_ptr Table__from_RecordBatchFileReader( batches[i] = ValueOrStop(reader->ReadRecordBatch(i)); } - return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); + auto table = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); + return cpp11::r6(table, "Table"); } // [[arrow::export]] -std::shared_ptr Table__from_RecordBatchStreamReader( +R6 Table__from_RecordBatchStreamReader( const std::shared_ptr& reader) { std::shared_ptr batch; std::vector> batches; @@ -113,7 +112,8 @@ std::shared_ptr Table__from_RecordBatchStreamReader( batches.push_back(batch); } - return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); + auto table = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); + return cpp11::r6(table, "Table"); } // [[arrow::export]] diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp index 4714c1d104a..9a5b2e31f0e 100644 --- a/r/src/recordbatchwriter.cpp +++ b/r/src/recordbatchwriter.cpp @@ -41,25 +41,29 @@ void ipc___RecordBatchWriter__Close( } // [[arrow::export]] -std::shared_ptr ipc___RecordBatchFileWriter__Open( +R6 ipc___RecordBatchFileWriter__Open( const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version) { auto options = arrow::ipc::IpcWriteOptions::Defaults(); options.write_legacy_ipc_format = use_legacy_format; options.metadata_version = metadata_version; - return ValueOrStop(arrow::ipc::MakeFileWriter(stream, schema, options)); + + auto writer = ValueOrStop(arrow::ipc::MakeFileWriter(stream, schema, options)); + return cpp11::r6(writer, "RecordBatchFileWriter"); } // [[arrow::export]] -std::shared_ptr ipc___RecordBatchStreamWriter__Open( +R6 ipc___RecordBatchStreamWriter__Open( const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version) { auto options = arrow::ipc::IpcWriteOptions::Defaults(); options.write_legacy_ipc_format = use_legacy_format; options.metadata_version = metadata_version; - return ValueOrStop(MakeStreamWriter(stream, schema, options)); + + auto writer = ValueOrStop(MakeStreamWriter(stream, schema, options)); + return cpp11::r6(writer, "RecordBatchStreamWriter"); } #endif diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index d9a3b569c36..d198dddc2e0 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -22,11 +22,23 @@ #include #include #include +#include + +namespace cpp11 { + +R6 r6_Scalar(const std::shared_ptr& ptr) { + std::string type = "Scalar"; + if (ptr->type->id() == arrow::Type::STRUCT) { + type = "StructScalar"; + } + return r6(ptr, type); +} + +} // namespace cpp11 // [[arrow::export]] -std::shared_ptr Array__GetScalar(const std::shared_ptr& x, - int64_t i) { - return ValueOrStop(x->GetScalar(i)); +R6 Array__GetScalar(const std::shared_ptr& x, int64_t i) { + return cpp11::r6_Scalar(ValueOrStop(x->GetScalar(i))); } // [[arrow::export]] @@ -35,21 +47,20 @@ std::string Scalar__ToString(const std::shared_ptr& s) { } // [[arrow::export]] -std::shared_ptr Scalar__CastTo(const std::shared_ptr& s, - const std::shared_ptr& t) { - return ValueOrStop(s->CastTo(t)); +R6 Scalar__CastTo(const std::shared_ptr& s, + const std::shared_ptr& t) { + return cpp11::r6_Scalar(ValueOrStop(s->CastTo(t))); } // [[arrow::export]] -std::shared_ptr StructScalar__field( - const std::shared_ptr& s, int i) { - return ValueOrStop(s->field(i)); +R6 StructScalar__field(const std::shared_ptr& s, int i) { + return cpp11::r6_Scalar(ValueOrStop(s->field(i))); } // [[arrow::export]] -std::shared_ptr StructScalar__GetFieldByName( - const std::shared_ptr& s, const std::string& name) { - return ValueOrStop(s->field(name)); +R6 StructScalar__GetFieldByName(const std::shared_ptr& s, + const std::string& name) { + return cpp11::r6_Scalar(ValueOrStop(s->field(name))); } // [[arrow::export]] diff --git a/r/src/schema.cpp b/r/src/schema.cpp index 7cb9a02eeab..8d55a36ed08 100644 --- a/r/src/schema.cpp +++ b/r/src/schema.cpp @@ -23,9 +23,8 @@ #include // [[arrow::export]] -std::shared_ptr schema_( - const std::vector>& fields) { - return arrow::schema(fields); +R6 schema_(const std::vector>& fields) { + return cpp11::r6(arrow::schema(fields), "Schema"); } // [[arrow::export]] @@ -39,19 +38,17 @@ int Schema__num_fields(const std::shared_ptr& s) { } // [[arrow::export]] -std::shared_ptr Schema__field(const std::shared_ptr& s, - int i) { +R6 Schema__field(const std::shared_ptr& s, int i) { if (i >= s->num_fields() || i < 0) { cpp11::stop("Invalid field index for schema."); } - return s->field(i); + return cpp11::r6(s->field(i), "Field"); } // [[arrow::export]] -std::shared_ptr Schema__GetFieldByName( - const std::shared_ptr& s, std::string x) { - return s->GetFieldByName(x); +R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x) { + return cpp11::r6(s->GetFieldByName(x), "Field"); } // [[arrow::export]] @@ -95,14 +92,14 @@ cpp11::writable::list Schema__metadata(const std::shared_ptr& sch } // [[arrow::export]] -std::shared_ptr Schema__WithMetadata( - const std::shared_ptr& schema, cpp11::strings metadata) { +R6 Schema__WithMetadata(const std::shared_ptr& schema, + cpp11::strings metadata) { auto values = cpp11::as_cpp>(metadata); auto names = cpp11::as_cpp>(metadata.attr("names")); auto kv = std::make_shared(std::move(names), std::move(values)); - return schema->WithMetadata(std::move(kv)); + return cpp11::r6(schema->WithMetadata(std::move(kv)), "Schema"); } // [[arrow::export]] @@ -119,9 +116,8 @@ bool Schema__Equals(const std::shared_ptr& schema, } // [[arrow::export]] -std::shared_ptr arrow__UnifySchemas( - const std::vector>& schemas) { - return ValueOrStop(arrow::UnifySchemas(schemas)); +R6 arrow__UnifySchemas(const std::vector>& schemas) { + return cpp11::r6(ValueOrStop(arrow::UnifySchemas(schemas)), "Schema"); } #endif diff --git a/r/src/table.cpp b/r/src/table.cpp index 97da768aa59..346162acb34 100644 --- a/r/src/table.cpp +++ b/r/src/table.cpp @@ -31,32 +31,30 @@ int Table__num_columns(const std::shared_ptr& x) { int Table__num_rows(const std::shared_ptr& x) { return x->num_rows(); } // [[arrow::export]] -std::shared_ptr Table__schema(const std::shared_ptr& x) { - return x->schema(); +R6 Table__schema(const std::shared_ptr& x) { + return cpp11::r6(x->schema(), "Schema"); } // [[arrow::export]] -std::shared_ptr Table__ReplaceSchemaMetadata( - const std::shared_ptr& x, cpp11::strings metadata) { +R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, + cpp11::strings metadata) { auto vec_metadata = cpp11::as_cpp>(metadata); auto names_metadata = cpp11::as_cpp>(metadata.names()); auto kv = std::shared_ptr( new arrow::KeyValueMetadata(names_metadata, vec_metadata)); - return x->ReplaceSchemaMetadata(kv); + return cpp11::r6(x->ReplaceSchemaMetadata(kv), "Table"); } // [[arrow::export]] -std::shared_ptr Table__column( - const std::shared_ptr& table, R_xlen_t i) { +R6 Table__column(const std::shared_ptr& table, R_xlen_t i) { arrow::r::validate_index(i, table->num_columns()); - return table->column(i); + return cpp11::r6(table->column(i), "ChunkedArray"); } // [[arrow::export]] -std::shared_ptr Table__field(const std::shared_ptr& table, - R_xlen_t i) { +R6 Table__field(const std::shared_ptr& table, R_xlen_t i) { arrow::r::validate_index(i, table->num_columns()); - return table->field(i); + return cpp11::r6(table->field(i), "Field"); } // [[arrow::export]] @@ -76,18 +74,17 @@ std::vector Table__ColumnNames(const std::shared_ptr& } // [[arrow::export]] -std::shared_ptr Table__Slice1(const std::shared_ptr& table, - R_xlen_t offset) { +R6 Table__Slice1(const std::shared_ptr& table, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, table->num_rows()); - return table->Slice(offset); + return cpp11::r6(table->Slice(offset), "Table"); } // [[arrow::export]] -std::shared_ptr Table__Slice2(const std::shared_ptr& table, - R_xlen_t offset, R_xlen_t length) { +R6 Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, + R_xlen_t length) { arrow::r::validate_slice_offset(offset, table->num_rows()); arrow::r::validate_slice_length(length, table->num_rows() - offset); - return table->Slice(offset, length); + return cpp11::r6(table->Slice(offset, length), "Table"); } // [[arrow::export]] @@ -109,15 +106,15 @@ bool Table__ValidateFull(const std::shared_ptr& table) { } // [[arrow::export]] -std::shared_ptr Table__GetColumnByName( - const std::shared_ptr& table, const std::string& name) { - return table->GetColumnByName(name); +R6 Table__GetColumnByName(const std::shared_ptr& table, + const std::string& name) { + return cpp11::r6(table->GetColumnByName(name), "ChunkedArray"); } // [[arrow::export]] -std::shared_ptr Table__SelectColumns( - const std::shared_ptr& table, const std::vector& indices) { - return ValueOrStop(table->SelectColumns(indices)); +R6 Table__SelectColumns(const std::shared_ptr& table, + const std::vector& indices) { + return cpp11::r6(ValueOrStop(table->SelectColumns(indices)), "Table"); } namespace arrow { @@ -259,7 +256,7 @@ bool all_record_batches(SEXP lst) { } // [[arrow::export]] -std::shared_ptr Table__from_record_batches( +R6 Table__from_record_batches( const std::vector>& batches, SEXP schema_sxp) { bool infer_schema = !Rf_inherits(schema_sxp, "Schema"); @@ -272,11 +269,11 @@ std::shared_ptr Table__from_record_batches( tab = ValueOrStop(arrow::Table::FromRecordBatches(schema, std::move(batches))); } - return tab; + return cpp11::r6(tab, "Table"); } // [[arrow::export]] -std::shared_ptr Table__from_dots(SEXP lst, SEXP schema_sxp) { +R6 Table__from_dots(SEXP lst, SEXP schema_sxp) { bool infer_schema = !Rf_inherits(schema_sxp, "Schema"); int num_fields; @@ -292,7 +289,7 @@ std::shared_ptr Table__from_dots(SEXP lst, SEXP schema_sxp) { StopIfNotOk( arrow::r::CollectTableColumns(lst, schema, num_fields, infer_schema, columns)); - return arrow::Table::Make(schema, columns); + return cpp11::r6(arrow::Table::Make(schema, columns), "Table"); } #endif From 5b9e2b938af2e53935fc34d39c7eed78c4607a1c Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Thu, 8 Oct 2020 16:35:37 +0200 Subject: [PATCH 12/43] - shared_ptr on the R side - explicitly make R6 objects on the c++ side --- r/R/array-data.R | 4 +- r/R/array.R | 8 +- r/R/arrow-package.R | 7 - r/R/arrowExports.R | 8 -- r/R/chunked-array.R | 2 +- r/R/csv.R | 4 +- r/R/dataset-format.R | 2 +- r/R/dataset-scan.R | 6 +- r/R/dataset.R | 13 +- r/R/dictionary.R | 4 +- r/R/field.R | 2 +- r/R/filesystem.R | 12 +- r/R/list.R | 12 +- r/R/record-batch.R | 2 +- r/R/scalar.R | 2 +- r/R/struct.R | 2 +- r/R/type.R | 97 ++++--------- r/src/array.cpp | 21 ++- r/src/array_from_vector.cpp | 9 +- r/src/arraydata.cpp | 9 +- r/src/arrowExports.cpp | 146 ++++++++----------- r/src/arrow_cpp11.h | 36 +---- r/src/arrow_exports.h | 22 +-- r/src/arrow_types.h | 9 +- r/src/chunkedarray.cpp | 13 +- r/src/compute.cpp | 2 +- r/src/csv.cpp | 9 +- r/src/dataset.cpp | 27 ++-- r/src/datatype.cpp | 215 ++++++++++++++++++---------- r/src/field.cpp | 8 +- r/src/filesystem.cpp | 15 +- r/src/recordbatch.cpp | 14 +- r/src/recordbatchreader.cpp | 8 +- r/src/scalar.cpp | 6 +- r/src/schema.cpp | 5 +- r/src/table.cpp | 5 +- r/tests/testthat/helper-roundtrip.R | 4 +- 37 files changed, 368 insertions(+), 402 deletions(-) diff --git a/r/R/array-data.R b/r/R/array-data.R index 988e2a71b2f..08b09133361 100644 --- a/r/R/array-data.R +++ b/r/R/array-data.R @@ -44,10 +44,10 @@ ArrayData <- R6Class("ArrayData", inherit = ArrowObject, active = list( - type = function() DataType$create(ArrayData__get_type(self)), + type = function() ArrayData__get_type(self), length = function() ArrayData__get_length(self), null_count = function() ArrayData__get_null_count(self), offset = function() ArrayData__get_offset(self), - buffers = function() map(ArrayData__buffers(self), shared_ptr, class = Buffer) + buffers = function() ArrayData__buffers(self) ) ) diff --git a/r/R/array.R b/r/R/array.R index f4fb946acd4..021417d55a4 100644 --- a/r/R/array.R +++ b/r/R/array.R @@ -140,7 +140,7 @@ Array <- R6Class("Array", active = list( null_count = function() Array__null_count(self), offset = function() Array__offset(self), - type = function() DataType$create(Array__type(self)) + type = function() Array__type(self) ) ) Array$create <- function(x, type = NULL) { @@ -205,7 +205,7 @@ ListArray <- R6Class("ListArray", inherit = Array, raw_value_offsets = function() ListArray__raw_value_offsets(self) ), active = list( - value_type = function() DataType$create(ListArray__value_type(self)) + value_type = function() ListArray__value_type(self) ) ) @@ -221,7 +221,7 @@ LargeListArray <- R6Class("LargeListArray", inherit = Array, raw_value_offsets = function() LargeListArray__raw_value_offsets(self) ), active = list( - value_type = function() DataType$create(LargeListArray__value_type(self)) + value_type = function() LargeListArray__value_type(self) ) ) @@ -236,7 +236,7 @@ FixedSizeListArray <- R6Class("FixedSizeListArray", inherit = Array, value_offset = function(i) FixedSizeListArray__value_offset(self, i) ), active = list( - value_type = function() DataType$create(FixedSizeListArray__value_type(self)), + value_type = function() FixedSizeListArray__value_type(self), list_size = function() self$type$list_size ) ) diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index bb32efd33d8..7f58c899f19 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -125,10 +125,3 @@ all.equal.ArrowObject <- function(target, current, ..., check.attributes = TRUE) target$Equals(current, check_metadata = check.attributes) } -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) -} diff --git a/r/R/arrowExports.R b/r/R/arrowExports.R index a48d7e6a5cb..2a3900e818c 100644 --- a/r/R/arrowExports.R +++ b/r/R/arrowExports.R @@ -512,14 +512,6 @@ dataset___Dataset__Write <- function(file_write_options, filesystem, base_dir, p invisible(.Call(`_arrow_dataset___Dataset__Write` , file_write_options, filesystem, base_dir, partitioning, basename_template, scanner)) } -shared_ptr_is_null <- function(xp){ - .Call(`_arrow_shared_ptr_is_null` , xp) -} - -unique_ptr_is_null <- function(xp){ - .Call(`_arrow_unique_ptr_is_null` , xp) -} - Int8__initialize <- function(){ .Call(`_arrow_Int8__initialize` ) } diff --git a/r/R/chunked-array.R b/r/R/chunked-array.R index f136c111553..89cd6e4f01a 100644 --- a/r/R/chunked-array.R +++ b/r/R/chunked-array.R @@ -104,7 +104,7 @@ ChunkedArray <- R6Class("ChunkedArray", inherit = ArrowObject, null_count = function() ChunkedArray__null_count(self), num_chunks = function() ChunkedArray__num_chunks(self), chunks = function() map(ChunkedArray__chunks(self), Array$create), - type = function() DataType$create(ChunkedArray__type(self)) + type = function() ChunkedArray__type(self) ) ) diff --git a/r/R/csv.R b/r/R/csv.R index df49c88b49c..160c46e4753 100644 --- a/r/R/csv.R +++ b/r/R/csv.R @@ -481,9 +481,9 @@ TimestampParser <- R6Class("TimestampParser", inherit = ArrowObject, ) TimestampParser$create <- function(format = NULL) { if (is.null(format)) { - shared_ptr(TimestampParser, TimestampParser__MakeISO8601()) + TimestampParser__MakeISO8601() } else { - shared_ptr(TimestampParser, TimestampParser__MakeStrptime(format)) + TimestampParser__MakeStrptime(format) } } diff --git a/r/R/dataset-format.R b/r/R/dataset-format.R index 20e2e970d6c..00bba8e91f5 100644 --- a/r/R/dataset-format.R +++ b/r/R/dataset-format.R @@ -156,6 +156,6 @@ FileWriteOptions$create <- function(format, ...) { if (!inherits(format, "FileFormat")) { format <- FileFormat$create(format) } - options <- shared_ptr(FileWriteOptions, dataset___FileFormat__DefaultWriteOptions(format)) + options <- dataset___FileFormat__DefaultWriteOptions(format) options$update(...) } diff --git a/r/R/dataset-scan.R b/r/R/dataset-scan.R index fd4ac90d33e..45fc968ed08 100644 --- a/r/R/dataset-scan.R +++ b/r/R/dataset-scan.R @@ -56,10 +56,10 @@ Scanner <- R6Class("Scanner", inherit = ArrowObject, public = list( ToTable = function() dataset___Scanner__ToTable(self), - Scan = function() map(dataset___Scanner__Scan(self), shared_ptr, class = ScanTask) + Scan = function() dataset___Scanner__Scan(self) ), active = list( - schema = function() shared_ptr(Schema, dataset___Scanner__schema(self)) + schema = function() dataset___Scanner__schema(self) ) ) Scanner$create <- function(dataset, @@ -169,7 +169,7 @@ ScannerBuilder <- R6Class("ScannerBuilder", inherit = ArrowObject, dataset___ScannerBuilder__BatchSize(self, batch_size) self }, - Finish = function() unique_ptr(Scanner, dataset___ScannerBuilder__Finish(self)) + Finish = function() dataset___ScannerBuilder__Finish(self) ), active = list( schema = function() dataset___ScannerBuilder__schema(self) diff --git a/r/R/dataset.R b/r/R/dataset.R index f8d9338d872..485c1c345e8 100644 --- a/r/R/dataset.R +++ b/r/R/dataset.R @@ -148,8 +148,13 @@ Dataset <- R6Class("Dataset", inherit = ArrowObject, # @description # Start a new scan of the data # @return A [ScannerBuilder] - NewScan = function() unique_ptr(ScannerBuilder, dataset___Dataset__NewScan(self)), - ToString = function() self$schema$ToString() + NewScan = function() dataset___Dataset__NewScan(self), + ToString = function() self$schema$ToString(), + write = function(path, filesystem = NULL, schema = self$schema, format, partitioning, ...) { + path_and_fs <- get_path_and_filesystem(path, filesystem) + dataset___Dataset__Write(self, schema, format, path_and_fs$fs, path_and_fs$path, partitioning) + invisible(self) + } ), active = list( schema = function(schema) { @@ -274,7 +279,7 @@ tail.Dataset <- function(x, n = 6L, ...) { batch_num <- 0 scanner <- Scanner$create(ensure_group_vars(x)) for (scan_task in rev(dataset___Scanner__Scan(scanner))) { - for (batch in rev(shared_ptr(ScanTask, scan_task)$Execute())) { + for (batch in rev(scan_task$Execute())) { batch_num <- batch_num + 1 result[[batch_num]] <- tail(batch, n) n <- n - nrow(batch) @@ -311,7 +316,7 @@ take_dataset_rows <- function(x, i) { i <- sort(i) - 1L scanner <- Scanner$create(ensure_group_vars(x)) for (scan_task in dataset___Scanner__Scan(scanner)) { - for (batch in shared_ptr(ScanTask, scan_task)$Execute()) { + for (batch in scan_task$Execute()) { # Take all rows that are in this batch this_batch_nrows <- batch$num_rows in_this_batch <- i > -1L & i < this_batch_nrows diff --git a/r/R/dictionary.R b/r/R/dictionary.R index 46fc1049e6a..b701768d661 100644 --- a/r/R/dictionary.R +++ b/r/R/dictionary.R @@ -37,8 +37,8 @@ DictionaryType <- R6Class("DictionaryType", } ), active = list( - index_type = function() DataType$create(DictionaryType__index_type(self)), - value_type = function() DataType$create(DictionaryType__value_type(self)), + index_type = function() DictionaryType__index_type(self), + value_type = function() DictionaryType__value_type(self), name = function() DictionaryType__name(self), ordered = function() DictionaryType__ordered(self) ) diff --git a/r/R/field.R b/r/R/field.R index 52abbade312..33549d344c5 100644 --- a/r/R/field.R +++ b/r/R/field.R @@ -49,7 +49,7 @@ Field <- R6Class("Field", inherit = ArrowObject, Field__nullable(self) }, type = function() { - DataType$create(Field__type(self)) + Field__type(self) } ) ) diff --git a/r/R/filesystem.R b/r/R/filesystem.R index af2432d3e47..d35009c49c4 100644 --- a/r/R/filesystem.R +++ b/r/R/filesystem.R @@ -202,17 +202,9 @@ FileSystem <- R6Class("FileSystem", inherit = ArrowObject, public = list( GetFileInfo = function(x) { if (inherits(x, "FileSelector")) { - map( - fs___FileSystem__GetTargetInfos_FileSelector(self, x), - shared_ptr, - class = FileInfo - ) + fs___FileSystem__GetTargetInfos_FileSelector(self, x) } else if (is.character(x)){ - map( - fs___FileSystem__GetTargetInfos_Paths(self, clean_path_rel(x)), - shared_ptr, - class = FileInfo - ) + fs___FileSystem__GetTargetInfos_Paths(self, clean_path_rel(x)) } else { abort("incompatible type for FileSystem$GetFileInfo()") } diff --git a/r/R/list.R b/r/R/list.R index b40d26a8a77..7db8d9a2ff1 100644 --- a/r/R/list.R +++ b/r/R/list.R @@ -21,25 +21,25 @@ ListType <- R6Class("ListType", inherit = NestedType, active = list( value_field = function() ListType__value_field(self), - value_type = function() DataType$create(ListType__value_type(self)) + value_type = function() ListType__value_type(self) ) ) #' @rdname data-type #' @export -list_of <- function(type) shared_ptr(ListType, list__(type)) +list_of <- function(type) list__(type) LargeListType <- R6Class("LargeListType", inherit = NestedType, active = list( value_field = function() LargeListType__value_field(self), - value_type = function() DataType$create(LargeListType__value_type(self)) + value_type = function() LargeListType__value_type(self) ) ) #' @rdname data-type #' @export -large_list_of <- function(type) shared_ptr(LargeListType, large_list__(type)) +large_list_of <- function(type) large_list__(type) #' @rdname data-type #' @export @@ -47,11 +47,11 @@ FixedSizeListType <- R6Class("FixedSizeListType", inherit = NestedType, active = list( value_field = function() FixedSizeListType__value_field(self), - value_type = function() DataType$create(FixedSizeListType__value_type(self)), + value_type = function() FixedSizeListType__value_type(self), list_size = function() FixedSizeListType__list_size(self) ) ) #' @rdname data-type #' @export -fixed_size_list_of <- function(type, list_size) shared_ptr(LargeListType, fixed_size_list__(type, list_size)) +fixed_size_list_of <- function(type, list_size) fixed_size_list__(type, list_size) diff --git a/r/R/record-batch.R b/r/R/record-batch.R index 5c87b6c6d8c..c2a20c792b0 100644 --- a/r/R/record-batch.R +++ b/r/R/record-batch.R @@ -142,7 +142,7 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, self } }, - columns = function() map(RecordBatch__columns(self), shared_ptr, Array) + columns = function() RecordBatch__columns(self) ) ) diff --git a/r/R/scalar.R b/r/R/scalar.R index 871e19e0571..12f29990e0a 100644 --- a/r/R/scalar.R +++ b/r/R/scalar.R @@ -40,7 +40,7 @@ Scalar <- R6Class("Scalar", active = list( is_valid = function() Scalar__is_valid(self), null_count = function() sum(!self$is_valid), - type = function() DataType$create(Scalar__type(self)) + type = function() Scalar__type(self) ) ) Scalar$create <- function(x, type = NULL) { diff --git a/r/R/struct.R b/r/R/struct.R index 0e871a8780d..7cfa7c9326c 100644 --- a/r/R/struct.R +++ b/r/R/struct.R @@ -24,7 +24,7 @@ StructType <- R6Class("StructType", GetFieldIndex = function(name) StructType__GetFieldIndex(self, name) ) ) -StructType$create <- function(...) shared_ptr(StructType, struct__(.fields(list(...)))) +StructType$create <- function(...) struct__(.fields(list(...))) #' @rdname data-type #' @export diff --git a/r/R/type.R b/r/R/type.R index f6a497ba758..fcefe83de3f 100644 --- a/r/R/type.R +++ b/r/R/type.R @@ -49,45 +49,6 @@ DataType <- R6Class("DataType", }, fields = function() { DataType__fields(self) - }, - ..dispatch = function() { - switch(names(Type)[self$id + 1], - "NA" = null(), - BOOL = boolean(), - UINT8 = uint8(), - INT8 = int8(), - UINT16 = uint16(), - INT16 = int16(), - UINT32 = uint32(), - INT32 = int32(), - UINT64 = uint64(), - INT64 = int64(), - HALF_FLOAT = float16(), - FLOAT = float32(), - DOUBLE = float64(), - STRING = utf8(), - BINARY = binary(), - FIXED_SIZE_BINARY = shared_ptr(FixedSizeBinary, self$pointer()), - DATE32 = date32(), - DATE64 = date64(), - TIMESTAMP = shared_ptr(Timestamp, self$pointer()), - TIME32 = shared_ptr(Time32, self$pointer()), - TIME64 = shared_ptr(Time64, self$pointer()), - INTERVAL = stop("Type INTERVAL not implemented yet"), - DECIMAL = shared_ptr(Decimal128Type, self$pointer()), - LIST = shared_ptr(ListType, self$pointer()), - STRUCT = shared_ptr(StructType, self$pointer()), - SPARSE_UNION = stop("Type SPARSE_UNION not implemented yet"), - DENSE_UNION = stop("Type DENSE_UNION not implemented yet"), - DICTIONARY = shared_ptr(DictionaryType, self$pointer()), - MAP = stop("Type MAP not implemented yet"), - EXTENSION = stop("Type EXTENSION not implemented yet"), - FIXED_SIZE_LIST = shared_ptr(FixedSizeListType, self$pointer()), - DURATION = stop("Type DURATION not implemented yet"), - LARGE_STRING = large_utf8(), - LARGE_BINARY = large_binary(), - LARGE_LIST = shared_ptr(LargeListType, self$pointer()) - ) } ), @@ -97,8 +58,6 @@ DataType <- R6Class("DataType", ) ) -DataType$create <- function(xp) shared_ptr(DataType, xp)$..dispatch() - INTEGER_TYPES <- as.character(outer(c("uint", "int"), c(8, 16, 32, 64), paste0)) FLOAT_TYPES <- c("float16", "float32", "float64", "halffloat", "float", "double") @@ -111,7 +70,7 @@ FLOAT_TYPES <- c("float16", "float32", "float64", "halffloat", "float", "double" type <- function(x) UseMethod("type") #' @export -type.default <- function(x) DataType$create(Array__infer_type(x)) +type.default <- function(x) Array__infer_type(x) #' @export type.Array <- function(x) x$type @@ -238,39 +197,39 @@ NestedType <- R6Class("NestedType", inherit = DataType) #' timestamp("ms", timezone = "CEST") #' time64("ns") #' } -int8 <- function() shared_ptr(Int8, Int8__initialize()) +int8 <- function() Int8__initialize() #' @rdname data-type #' @export -int16 <- function() shared_ptr(Int16, Int16__initialize()) +int16 <- function() Int16__initialize() #' @rdname data-type #' @export -int32 <- function() shared_ptr(Int32, Int32__initialize()) +int32 <- function() Int32__initialize() #' @rdname data-type #' @export -int64 <- function() shared_ptr(Int64, Int64__initialize()) +int64 <- function() Int64__initialize() #' @rdname data-type #' @export -uint8 <- function() shared_ptr(UInt8, UInt8__initialize()) +uint8 <- function() UInt8__initialize() #' @rdname data-type #' @export -uint16 <- function() shared_ptr(UInt16, UInt16__initialize()) +uint16 <- function() UInt16__initialize() #' @rdname data-type #' @export -uint32 <- function() shared_ptr(UInt32, UInt32__initialize()) +uint32 <- function() UInt32__initialize() #' @rdname data-type #' @export -uint64 <- function() shared_ptr(UInt64, UInt64__initialize()) +uint64 <- function() UInt64__initialize() #' @rdname data-type #' @export -float16 <- function() shared_ptr(Float16, Float16__initialize()) +float16 <- function() Float16__initialize() #' @rdname data-type #' @export @@ -278,7 +237,7 @@ halffloat <- float16 #' @rdname data-type #' @export -float32 <- function() shared_ptr(Float32, Float32__initialize()) +float32 <- function() Float32__initialize() #' @rdname data-type #' @export @@ -286,11 +245,11 @@ float <- float32 #' @rdname data-type #' @export -float64 <- function() shared_ptr(Float64, Float64__initialize()) +float64 <- function() Float64__initialize() #' @rdname data-type #' @export -boolean <- function() shared_ptr(Boolean, Boolean__initialize()) +boolean <- function() Boolean__initialize() #' @rdname data-type #' @export @@ -298,29 +257,23 @@ bool <- boolean #' @rdname data-type #' @export -utf8 <- function() shared_ptr(Utf8, Utf8__initialize()) +utf8 <- function() Utf8__initialize() #' @rdname data-type #' @export -large_utf8 <- function() shared_ptr(LargeUtf8, LargeUtf8__initialize()) +large_utf8 <- function() LargeUtf8__initialize() #' @rdname data-type #' @export -binary <- function() { - shared_ptr(Binary, Binary__initialize()) -} +binary <- function() Binary__initialize() #' @rdname data-type #' @export -large_binary <- function() { - shared_ptr(LargeBinary, LargeBinary__initialize()) -} +large_binary <- function() LargeBinary__initialize() #' @rdname data-type #' @export -fixed_size_binary <- function(byte_width) { - shared_ptr(FixedSizeBinary, FixedSizeBinary__initialize(byte_width)) -} +fixed_size_binary <- function(byte_width) FixedSizeBinary__initialize(byte_width) #' @rdname data-type #' @export @@ -328,11 +281,11 @@ string <- utf8 #' @rdname data-type #' @export -date32 <- function() shared_ptr(Date32, Date32__initialize()) +date32 <- function() Date32__initialize() #' @rdname data-type #' @export -date64 <- function() shared_ptr(Date64, Date64__initialize()) +date64 <- function() Date64__initialize() #' @rdname data-type #' @export @@ -341,7 +294,7 @@ time32 <- function(unit = c("ms", "s")) { unit <- match.arg(unit) } unit <- make_valid_time_unit(unit, valid_time32_units) - shared_ptr(Time32, Time32__initialize(unit)) + Time32__initialize(unit) } valid_time32_units <- c( @@ -377,12 +330,12 @@ time64 <- function(unit = c("ns", "us")) { unit <- match.arg(unit) } unit <- make_valid_time_unit(unit, valid_time64_units) - shared_ptr(Time64, Time64__initialize(unit)) + Time64__initialize(unit) } #' @rdname data-type #' @export -null <- function() shared_ptr(Null, Null__initialize()) +null <- function() Null__initialize() #' @rdname data-type #' @export @@ -392,7 +345,7 @@ timestamp <- function(unit = c("s", "ms", "us", "ns"), timezone = "") { } unit <- make_valid_time_unit(unit, c(valid_time64_units, valid_time32_units)) assert_that(is.string(timezone)) - shared_ptr(Timestamp, Timestamp__initialize(unit, timezone)) + Timestamp__initialize(unit, timezone) } #' @rdname data-type @@ -408,7 +361,7 @@ decimal <- function(precision, scale) { } else { stop('"scale" must be an integer', call. = FALSE) } - shared_ptr(Decimal128Type, Decimal128Type__initialize(precision, scale)) + Decimal128Type__initialize(precision, scale) } as_type <- function(type, name = "type") { diff --git a/r/src/array.cpp b/r/src/array.cpp index e715781095e..f88be176f57 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -24,6 +24,8 @@ namespace cpp11 { R6 r6_Array(const std::shared_ptr& array) { + if (array == nullptr) return R_NilValue; + using arrow::Type; auto type = array->type_id(); @@ -114,8 +116,8 @@ int Array__offset(const std::shared_ptr& x) { return x->offset(); int Array__null_count(const std::shared_ptr& x) { return x->null_count(); } // [[arrow::export]] -std::shared_ptr Array__type(const std::shared_ptr& x) { - return x->type(); +R6 Array__type(const std::shared_ptr& x) { + return cpp11::r6_DataType(x->type()); } // [[arrow::export]] @@ -194,21 +196,18 @@ R6 StructArray__GetFieldByName(const std::shared_ptr& array, } // [[arrow::export]] -arrow::ArrayVector StructArray__Flatten( - const std::shared_ptr& array) { - return ValueOrStop(array->Flatten()); +cpp11::list StructArray__Flatten(const std::shared_ptr& array) { + return arrow::r::to_r_list(ValueOrStop(array->Flatten()), cpp11::r6_Array); } // [[arrow::export]] -std::shared_ptr ListArray__value_type( - const std::shared_ptr& array) { - return array->value_type(); +R6 ListArray__value_type(const std::shared_ptr& array) { + return cpp11::r6_DataType(array->value_type()); } // [[arrow::export]] -std::shared_ptr LargeListArray__value_type( - const std::shared_ptr& array) { - return array->value_type(); +R6 LargeListArray__value_type(const std::shared_ptr& array) { + return cpp11::r6_DataType(array->value_type()); } // [[arrow::export]] diff --git a/r/src/array_from_vector.cpp b/r/src/array_from_vector.cpp index dacf9272bc8..fcb2ed29974 100644 --- a/r/src/array_from_vector.cpp +++ b/r/src/array_from_vector.cpp @@ -1528,12 +1528,10 @@ std::shared_ptr Array__from_vector( } // namespace arrow // [[arrow::export]] -std::shared_ptr Array__infer_type(SEXP x) { - return arrow::r::InferArrowType(x); -} +R6 Array__infer_type(SEXP x) { return cpp11::r6_DataType(arrow::r::InferArrowType(x)); } // [[arrow::export]] -std::shared_ptr Array__from_vector(SEXP x, SEXP s_type) { +R6 Array__from_vector(SEXP x, SEXP s_type) { // the type might be NULL, in which case we need to infer it from the data // we keep track of whether it was inferred or supplied bool type_inferred = Rf_isNull(s_type); @@ -1544,7 +1542,8 @@ std::shared_ptr Array__from_vector(SEXP x, SEXP s_type) { type = cpp11::as_cpp>(s_type); } - return arrow::r::Array__from_vector(x, type, type_inferred); + auto array = arrow::r::Array__from_vector(x, type, type_inferred); + return cpp11::r6_Array(array); } // [[arrow::export]] diff --git a/r/src/arraydata.cpp b/r/src/arraydata.cpp index a8ee60f36a0..d2ecf28541c 100644 --- a/r/src/arraydata.cpp +++ b/r/src/arraydata.cpp @@ -21,9 +21,8 @@ #include // [[arrow::export]] -std::shared_ptr ArrayData__get_type( - const std::shared_ptr& x) { - return x->type; +R6 ArrayData__get_type(const std::shared_ptr& x) { + return cpp11::r6_DataType(x->type); } // [[arrow::export]] @@ -43,7 +42,9 @@ int ArrayData__get_offset(const std::shared_ptr& x) { // [[arrow::export]] cpp11::list ArrayData__buffers(const std::shared_ptr& x) { - return cpp11::as_sexp(x->buffers); + return arrow::r::to_r_list(x->buffers, [](const std::shared_ptr& buf) { + return cpp11::r6(buf, "Buffer"); + }); } #endif diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index a91873c95c2..1b2af0f9d66 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -116,7 +116,7 @@ extern "C" SEXP _arrow_Array__null_count(SEXP x_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__type(const std::shared_ptr& x); +R6 Array__type(const std::shared_ptr& x); extern "C" SEXP _arrow_Array__type(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -321,7 +321,7 @@ extern "C" SEXP _arrow_StructArray__GetFieldByName(SEXP array_sexp, SEXP name_se // array.cpp #if defined(ARROW_R_WITH_ARROW) -arrow::ArrayVector StructArray__Flatten(const std::shared_ptr& array); +cpp11::list StructArray__Flatten(const std::shared_ptr& array); extern "C" SEXP _arrow_StructArray__Flatten(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -336,7 +336,7 @@ extern "C" SEXP _arrow_StructArray__Flatten(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ListArray__value_type(const std::shared_ptr& array); +R6 ListArray__value_type(const std::shared_ptr& array); extern "C" SEXP _arrow_ListArray__value_type(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -351,7 +351,7 @@ extern "C" SEXP _arrow_ListArray__value_type(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr LargeListArray__value_type(const std::shared_ptr& array); +R6 LargeListArray__value_type(const std::shared_ptr& array); extern "C" SEXP _arrow_LargeListArray__value_type(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -522,7 +522,7 @@ extern "C" SEXP _arrow_LargeListArray__raw_value_offsets(SEXP array_sexp){ // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__infer_type(SEXP x); +R6 Array__infer_type(SEXP x); extern "C" SEXP _arrow_Array__infer_type(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -537,7 +537,7 @@ extern "C" SEXP _arrow_Array__infer_type(SEXP x_sexp){ // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Array__from_vector(SEXP x, SEXP s_type); +R6 Array__from_vector(SEXP x, SEXP s_type); extern "C" SEXP _arrow_Array__from_vector(SEXP x_sexp, SEXP s_type_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -648,7 +648,7 @@ extern "C" SEXP _arrow_Table__to_dataframe(SEXP table_sexp, SEXP use_threads_sex // arraydata.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ArrayData__get_type(const std::shared_ptr& x); +R6 ArrayData__get_type(const std::shared_ptr& x); extern "C" SEXP _arrow_ArrayData__get_type(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -906,7 +906,7 @@ extern "C" SEXP _arrow_ChunkedArray__chunks(SEXP chunked_array_sexp){ // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ChunkedArray__type(const std::shared_ptr& chunked_array); +R6 ChunkedArray__type(const std::shared_ptr& chunked_array); extern "C" SEXP _arrow_ChunkedArray__type(SEXP chunked_array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -1320,7 +1320,7 @@ extern "C" SEXP _arrow_TimestampParser__format(SEXP parser_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr TimestampParser__MakeStrptime(std::string format); +R6 TimestampParser__MakeStrptime(std::string format); extern "C" SEXP _arrow_TimestampParser__MakeStrptime(SEXP format_sexp){ BEGIN_CPP11 arrow::r::Input::type format(format_sexp); @@ -1335,7 +1335,7 @@ extern "C" SEXP _arrow_TimestampParser__MakeStrptime(SEXP format_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr TimestampParser__MakeISO8601(); +R6 TimestampParser__MakeISO8601(); extern "C" SEXP _arrow_TimestampParser__MakeISO8601(){ BEGIN_CPP11 return cpp11::as_sexp(TimestampParser__MakeISO8601()); @@ -1441,7 +1441,7 @@ extern "C" SEXP _arrow_dataset___InMemoryDataset__create(SEXP table_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -ds::DatasetVector dataset___UnionDataset__children(const std::shared_ptr& ds); +cpp11::list dataset___UnionDataset__children(const std::shared_ptr& ds); extern "C" SEXP _arrow_dataset___UnionDataset__children(SEXP ds_sexp){ BEGIN_CPP11 arrow::r::Input&>::type ds(ds_sexp); @@ -1951,7 +1951,7 @@ extern "C" SEXP _arrow_dataset___Scanner__head(SEXP scanner_sexp, SEXP n_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> dataset___Scanner__Scan(const std::shared_ptr& scanner); +cpp11::list dataset___Scanner__Scan(const std::shared_ptr& scanner); extern "C" SEXP _arrow_dataset___Scanner__Scan(SEXP scanner_sexp){ BEGIN_CPP11 arrow::r::Input&>::type scanner(scanner_sexp); @@ -1966,7 +1966,7 @@ extern "C" SEXP _arrow_dataset___Scanner__Scan(SEXP scanner_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___Scanner__schema(const std::shared_ptr& sc); +R6 dataset___Scanner__schema(const std::shared_ptr& sc); extern "C" SEXP _arrow_dataset___Scanner__schema(SEXP sc_sexp){ BEGIN_CPP11 arrow::r::Input&>::type sc(sc_sexp); @@ -1981,7 +1981,7 @@ extern "C" SEXP _arrow_dataset___Scanner__schema(SEXP sc_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> dataset___ScanTask__get_batches(const std::shared_ptr& scan_task); +cpp11::list dataset___ScanTask__get_batches(const std::shared_ptr& scan_task); extern "C" SEXP _arrow_dataset___ScanTask__get_batches(SEXP scan_task_sexp){ BEGIN_CPP11 arrow::r::Input&>::type scan_task(scan_task_sexp); @@ -2017,37 +2017,7 @@ extern "C" SEXP _arrow_dataset___Dataset__Write(SEXP file_write_options_sexp, SE // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -bool shared_ptr_is_null(SEXP xp); -extern "C" SEXP _arrow_shared_ptr_is_null(SEXP xp_sexp){ -BEGIN_CPP11 - arrow::r::Input::type xp(xp_sexp); - return cpp11::as_sexp(shared_ptr_is_null(xp)); -END_CPP11 -} -#else -extern "C" SEXP _arrow_shared_ptr_is_null(SEXP xp_sexp){ - Rf_error("Cannot call shared_ptr_is_null(). Please use arrow::install_arrow() to install required runtime libraries. "); -} -#endif - -// datatype.cpp -#if defined(ARROW_R_WITH_ARROW) -bool unique_ptr_is_null(SEXP xp); -extern "C" SEXP _arrow_unique_ptr_is_null(SEXP xp_sexp){ -BEGIN_CPP11 - arrow::r::Input::type xp(xp_sexp); - return cpp11::as_sexp(unique_ptr_is_null(xp)); -END_CPP11 -} -#else -extern "C" SEXP _arrow_unique_ptr_is_null(SEXP xp_sexp){ - Rf_error("Cannot call unique_ptr_is_null(). Please use arrow::install_arrow() to install required runtime libraries. "); -} -#endif - -// datatype.cpp -#if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Int8__initialize(); +R6 Int8__initialize(); extern "C" SEXP _arrow_Int8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int8__initialize()); @@ -2061,7 +2031,7 @@ extern "C" SEXP _arrow_Int8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Int16__initialize(); +R6 Int16__initialize(); extern "C" SEXP _arrow_Int16__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int16__initialize()); @@ -2075,7 +2045,7 @@ extern "C" SEXP _arrow_Int16__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Int32__initialize(); +R6 Int32__initialize(); extern "C" SEXP _arrow_Int32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int32__initialize()); @@ -2089,7 +2059,7 @@ extern "C" SEXP _arrow_Int32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Int64__initialize(); +R6 Int64__initialize(); extern "C" SEXP _arrow_Int64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int64__initialize()); @@ -2103,7 +2073,7 @@ extern "C" SEXP _arrow_Int64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr UInt8__initialize(); +R6 UInt8__initialize(); extern "C" SEXP _arrow_UInt8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt8__initialize()); @@ -2117,7 +2087,7 @@ extern "C" SEXP _arrow_UInt8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr UInt16__initialize(); +R6 UInt16__initialize(); extern "C" SEXP _arrow_UInt16__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt16__initialize()); @@ -2131,7 +2101,7 @@ extern "C" SEXP _arrow_UInt16__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr UInt32__initialize(); +R6 UInt32__initialize(); extern "C" SEXP _arrow_UInt32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt32__initialize()); @@ -2145,7 +2115,7 @@ extern "C" SEXP _arrow_UInt32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr UInt64__initialize(); +R6 UInt64__initialize(); extern "C" SEXP _arrow_UInt64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt64__initialize()); @@ -2159,7 +2129,7 @@ extern "C" SEXP _arrow_UInt64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Float16__initialize(); +R6 Float16__initialize(); extern "C" SEXP _arrow_Float16__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Float16__initialize()); @@ -2173,7 +2143,7 @@ extern "C" SEXP _arrow_Float16__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Float32__initialize(); +R6 Float32__initialize(); extern "C" SEXP _arrow_Float32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Float32__initialize()); @@ -2187,7 +2157,7 @@ extern "C" SEXP _arrow_Float32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Float64__initialize(); +R6 Float64__initialize(); extern "C" SEXP _arrow_Float64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Float64__initialize()); @@ -2201,7 +2171,7 @@ extern "C" SEXP _arrow_Float64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Boolean__initialize(); +R6 Boolean__initialize(); extern "C" SEXP _arrow_Boolean__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Boolean__initialize()); @@ -2215,7 +2185,7 @@ extern "C" SEXP _arrow_Boolean__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Utf8__initialize(); +R6 Utf8__initialize(); extern "C" SEXP _arrow_Utf8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Utf8__initialize()); @@ -2229,7 +2199,7 @@ extern "C" SEXP _arrow_Utf8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr LargeUtf8__initialize(); +R6 LargeUtf8__initialize(); extern "C" SEXP _arrow_LargeUtf8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(LargeUtf8__initialize()); @@ -2243,7 +2213,7 @@ extern "C" SEXP _arrow_LargeUtf8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Binary__initialize(); +R6 Binary__initialize(); extern "C" SEXP _arrow_Binary__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Binary__initialize()); @@ -2257,7 +2227,7 @@ extern "C" SEXP _arrow_Binary__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr LargeBinary__initialize(); +R6 LargeBinary__initialize(); extern "C" SEXP _arrow_LargeBinary__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(LargeBinary__initialize()); @@ -2271,7 +2241,7 @@ extern "C" SEXP _arrow_LargeBinary__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Date32__initialize(); +R6 Date32__initialize(); extern "C" SEXP _arrow_Date32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Date32__initialize()); @@ -2285,7 +2255,7 @@ extern "C" SEXP _arrow_Date32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Date64__initialize(); +R6 Date64__initialize(); extern "C" SEXP _arrow_Date64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Date64__initialize()); @@ -2299,7 +2269,7 @@ extern "C" SEXP _arrow_Date64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Null__initialize(); +R6 Null__initialize(); extern "C" SEXP _arrow_Null__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Null__initialize()); @@ -2313,7 +2283,7 @@ extern "C" SEXP _arrow_Null__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Decimal128Type__initialize(int32_t precision, int32_t scale); +R6 Decimal128Type__initialize(int32_t precision, int32_t scale); extern "C" SEXP _arrow_Decimal128Type__initialize(SEXP precision_sexp, SEXP scale_sexp){ BEGIN_CPP11 arrow::r::Input::type precision(precision_sexp); @@ -2329,7 +2299,7 @@ extern "C" SEXP _arrow_Decimal128Type__initialize(SEXP precision_sexp, SEXP scal // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr FixedSizeBinary__initialize(R_xlen_t byte_width); +R6 FixedSizeBinary__initialize(R_xlen_t byte_width); extern "C" SEXP _arrow_FixedSizeBinary__initialize(SEXP byte_width_sexp){ BEGIN_CPP11 arrow::r::Input::type byte_width(byte_width_sexp); @@ -2344,7 +2314,7 @@ extern "C" SEXP _arrow_FixedSizeBinary__initialize(SEXP byte_width_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone); +R6 Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone); extern "C" SEXP _arrow_Timestamp__initialize(SEXP unit_sexp, SEXP timezone_sexp){ BEGIN_CPP11 arrow::r::Input::type unit(unit_sexp); @@ -2360,7 +2330,7 @@ extern "C" SEXP _arrow_Timestamp__initialize(SEXP unit_sexp, SEXP timezone_sexp) // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Time32__initialize(arrow::TimeUnit::type unit); +R6 Time32__initialize(arrow::TimeUnit::type unit); extern "C" SEXP _arrow_Time32__initialize(SEXP unit_sexp){ BEGIN_CPP11 arrow::r::Input::type unit(unit_sexp); @@ -2375,7 +2345,7 @@ extern "C" SEXP _arrow_Time32__initialize(SEXP unit_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Time64__initialize(arrow::TimeUnit::type unit); +R6 Time64__initialize(arrow::TimeUnit::type unit); extern "C" SEXP _arrow_Time64__initialize(SEXP unit_sexp){ BEGIN_CPP11 arrow::r::Input::type unit(unit_sexp); @@ -2390,7 +2360,7 @@ extern "C" SEXP _arrow_Time64__initialize(SEXP unit_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -SEXP list__(SEXP x); +R6 list__(SEXP x); extern "C" SEXP _arrow_list__(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -2405,7 +2375,7 @@ extern "C" SEXP _arrow_list__(SEXP x_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -SEXP large_list__(SEXP x); +R6 large_list__(SEXP x); extern "C" SEXP _arrow_large_list__(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -2420,7 +2390,7 @@ extern "C" SEXP _arrow_large_list__(SEXP x_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -SEXP fixed_size_list__(SEXP x, int list_size); +R6 fixed_size_list__(SEXP x, int list_size); extern "C" SEXP _arrow_fixed_size_list__(SEXP x_sexp, SEXP list_size_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -2436,7 +2406,7 @@ extern "C" SEXP _arrow_fixed_size_list__(SEXP x_sexp, SEXP list_size_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr struct__(const std::vector>& fields); +R6 struct__(const std::vector>& fields); extern "C" SEXP _arrow_struct__(SEXP fields_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type fields(fields_sexp); @@ -2512,7 +2482,7 @@ extern "C" SEXP _arrow_DataType__num_fields(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> DataType__fields(const std::shared_ptr& type); +cpp11::list DataType__fields(const std::shared_ptr& type); extern "C" SEXP _arrow_DataType__fields(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2679,7 +2649,7 @@ extern "C" SEXP _arrow_DictionaryType__initialize(SEXP index_type_sexp, SEXP val // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr DictionaryType__index_type(const std::shared_ptr& type); +R6 DictionaryType__index_type(const std::shared_ptr& type); extern "C" SEXP _arrow_DictionaryType__index_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2694,7 +2664,7 @@ extern "C" SEXP _arrow_DictionaryType__index_type(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr DictionaryType__value_type(const std::shared_ptr& type); +R6 DictionaryType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_DictionaryType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2786,7 +2756,7 @@ extern "C" SEXP _arrow_ListType__value_field(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr ListType__value_type(const std::shared_ptr& type); +R6 ListType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_ListType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2816,7 +2786,7 @@ extern "C" SEXP _arrow_LargeListType__value_field(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr LargeListType__value_type(const std::shared_ptr& type); +R6 LargeListType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_LargeListType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2846,7 +2816,7 @@ extern "C" SEXP _arrow_FixedSizeListType__value_field(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr FixedSizeListType__value_type(const std::shared_ptr& type); +R6 FixedSizeListType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_FixedSizeListType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -3255,7 +3225,7 @@ extern "C" SEXP _arrow_Field__nullable(SEXP field_sexp){ // field.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Field__type(const std::shared_ptr& field); +R6 Field__type(const std::shared_ptr& field); extern "C" SEXP _arrow_Field__type(SEXP field_sexp){ BEGIN_CPP11 arrow::r::Input&>::type field(field_sexp); @@ -3490,7 +3460,7 @@ extern "C" SEXP _arrow_fs___FileSelector__create(SEXP base_dir_sexp, SEXP allow_ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> fs___FileSystem__GetTargetInfos_Paths(const std::shared_ptr& file_system, const std::vector& paths); +cpp11::list fs___FileSystem__GetTargetInfos_Paths(const std::shared_ptr& file_system, const std::vector& paths); extern "C" SEXP _arrow_fs___FileSystem__GetTargetInfos_Paths(SEXP file_system_sexp, SEXP paths_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3506,7 +3476,7 @@ extern "C" SEXP _arrow_fs___FileSystem__GetTargetInfos_Paths(SEXP file_system_se // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> fs___FileSystem__GetTargetInfos_FileSelector(const std::shared_ptr& file_system, const std::shared_ptr& selector); +cpp11::list fs___FileSystem__GetTargetInfos_FileSelector(const std::shared_ptr& file_system, const std::shared_ptr& selector); extern "C" SEXP _arrow_fs___FileSystem__GetTargetInfos_FileSelector(SEXP file_system_sexp, SEXP selector_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -5211,7 +5181,7 @@ extern "C" SEXP _arrow_RecordBatch__ReplaceSchemaMetadata(SEXP x_sexp, SEXP meta // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -arrow::ArrayVector RecordBatch__columns(const std::shared_ptr& batch); +cpp11::list RecordBatch__columns(const std::shared_ptr& batch); extern "C" SEXP _arrow_RecordBatch__columns(SEXP batch_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5463,7 +5433,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchStreamReader__Open(SEXP stream_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> ipc___RecordBatchStreamReader__batches(const std::shared_ptr& reader); +cpp11::list ipc___RecordBatchStreamReader__batches(const std::shared_ptr& reader); extern "C" SEXP _arrow_ipc___RecordBatchStreamReader__batches(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5569,7 +5539,7 @@ extern "C" SEXP _arrow_Table__from_RecordBatchStreamReader(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> ipc___RecordBatchFileReader__batches(const std::shared_ptr& reader); +cpp11::list ipc___RecordBatchFileReader__batches(const std::shared_ptr& reader); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__batches(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5779,7 +5749,7 @@ extern "C" SEXP _arrow_Scalar__is_valid(SEXP s_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr Scalar__type(const std::shared_ptr& s); +R6 Scalar__type(const std::shared_ptr& s); extern "C" SEXP _arrow_Scalar__type(SEXP s_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5871,7 +5841,7 @@ extern "C" SEXP _arrow_Schema__GetFieldByName(SEXP s_sexp, SEXP x_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> Schema__fields(const std::shared_ptr& schema); +cpp11::list Schema__fields(const std::shared_ptr& schema); extern "C" SEXP _arrow_Schema__fields(SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schema(schema_sexp); @@ -6087,7 +6057,7 @@ extern "C" SEXP _arrow_Table__field(SEXP table_sexp, SEXP i_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -std::vector> Table__columns(const std::shared_ptr& table); +cpp11::list Table__columns(const std::shared_ptr& table); extern "C" SEXP _arrow_Table__columns(SEXP table_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6456,8 +6426,6 @@ static const R_CallMethodDef CallEntries[] = { { "_arrow_dataset___Scanner__schema", (DL_FUNC) &_arrow_dataset___Scanner__schema, 1}, { "_arrow_dataset___ScanTask__get_batches", (DL_FUNC) &_arrow_dataset___ScanTask__get_batches, 1}, { "_arrow_dataset___Dataset__Write", (DL_FUNC) &_arrow_dataset___Dataset__Write, 6}, - { "_arrow_shared_ptr_is_null", (DL_FUNC) &_arrow_shared_ptr_is_null, 1}, - { "_arrow_unique_ptr_is_null", (DL_FUNC) &_arrow_unique_ptr_is_null, 1}, { "_arrow_Int8__initialize", (DL_FUNC) &_arrow_Int8__initialize, 0}, { "_arrow_Int16__initialize", (DL_FUNC) &_arrow_Int16__initialize, 0}, { "_arrow_Int32__initialize", (DL_FUNC) &_arrow_Int32__initialize, 0}, diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 12b1a9e6873..e9f09f97283 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -26,16 +26,6 @@ using R6 = SEXP; -namespace cpp11 { - -template -SEXP as_sexp(const std::shared_ptr& ptr); - -template -SEXP as_sexp(const std::vector>& vec); - -} // namespace cpp11 - // TODO: move this include up once we can resolve this issue in cpp11 // https://github.com/apache/arrow/pull/7819#discussion_r471664878 #include @@ -269,18 +259,16 @@ cpp11::writable::strings to_r_strings(const std::vector>& x, return to_r_vector(x, std::forward(to_string)); } -template -cpp11::writable::list to_r_list(const std::vector>& x) { - auto as_sexp = [](const std::shared_ptr& t) { return cpp11::as_sexp(t); }; - return to_r_vector(x, as_sexp); -} +// template +// cpp11::writable::list to_r_list(const std::vector>& x) { +// auto as_sexp = [](const std::shared_ptr& t) { return cpp11::as_sexp(t); }; +// return to_r_vector(x, as_sexp); +// } template cpp11::writable::list to_r_list(const std::vector>& x, ToListElement&& to_element) { - auto as_sexp = [&](const std::shared_ptr& t) { - return cpp11::as_sexp(to_element(t)); - }; + auto as_sexp = [&](const std::shared_ptr& t) { return to_element(t); }; return to_r_vector(x, as_sexp); } @@ -304,7 +292,7 @@ bool GetBoolOption(const std::string& name, bool default_); namespace cpp11 { template -SEXP r6(const std::shared_ptr& x, const std::string& r_class_name) { +R6 r6(const std::shared_ptr& x, const std::string& r_class_name) { if (x == nullptr) return R_NilValue; cpp11::external_pointer> xp(new std::shared_ptr(x)); SEXP r6_class = Rf_install(r_class_name.c_str()); @@ -329,16 +317,6 @@ enable_if_shared_ptr as_cpp(SEXP from) { return arrow::r::ExternalPtrInput(from); } -template -SEXP as_sexp(const std::shared_ptr& ptr) { - return cpp11::external_pointer>(new std::shared_ptr(ptr)); -} - -template -SEXP as_sexp(const std::vector>& vec) { - return arrow::r::to_r_list(vec); -} - template enable_if_enum as_sexp(E e) { return as_sexp(static_cast(e)); diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index 904f1c86a7e..42dcf0acce3 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -31,9 +31,13 @@ #include #include +namespace ds = ::arrow::dataset; +namespace fs = ::arrow::fs; + namespace arrow { namespace compute { + struct CastOptions; } // namespace compute @@ -57,9 +61,6 @@ struct ParseOptions; } // namespace arrow -namespace ds = ::arrow::dataset; -namespace fs = ::arrow::fs; - namespace parquet { struct ParquetVersion { @@ -84,19 +85,4 @@ class FileWriter; } // namespace arrow } // namespace parquet -namespace arrow { -namespace dataset { - -class DirectoryPartitioning; -class HivePartitioning; -class FileSystemDatasetFactory; - -} // namespace dataset - -namespace fs { -class S3FileSystem; -} - -} // namespace arrow - #endif diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index b36856c7285..cc86dbedbfc 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -35,7 +35,7 @@ SEXP ChunkedArray__as_vector(const std::shared_ptr& chunked_array); SEXP Array__as_vector(const std::shared_ptr& array); -std::shared_ptr Array__from_vector(SEXP x, SEXP type); +R6 Array__from_vector(SEXP x, SEXP type); R6 RecordBatch__from_arrays(SEXP, SEXP); arrow::MemoryPool* gc_memory_pool(); @@ -122,7 +122,12 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, namespace cpp11 { R6 r6_Array(const std::shared_ptr& array); +R6 r6_DataType(const std::shared_ptr& type); +R6 r6_Field(const std::shared_ptr& field); +R6 r6_ChunkedArray(const std::shared_ptr& array); +R6 r6_RecordBatch(const std::shared_ptr& batch); +R6 r6_Scalar(const std::shared_ptr& ptr); -} +} // namespace cpp11 #endif diff --git a/r/src/chunkedarray.cpp b/r/src/chunkedarray.cpp index 5fda0fa0ce6..afb9d7ec6b8 100644 --- a/r/src/chunkedarray.cpp +++ b/r/src/chunkedarray.cpp @@ -21,6 +21,12 @@ #include +namespace cpp11 { +R6 r6_ChunkedArray(const std::shared_ptr& array) { + return r6(array, "ChunkedArray"); +} +} // namespace cpp11 + // [[arrow::export]] int ChunkedArray__length(const std::shared_ptr& chunked_array) { return chunked_array->length(); @@ -45,13 +51,12 @@ R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array // [[arrow::export]] cpp11::list ChunkedArray__chunks( const std::shared_ptr& chunked_array) { - return cpp11::as_sexp(chunked_array->chunks()); + return arrow::r::to_r_list(chunked_array->chunks(), cpp11::r6_Array); } // [[arrow::export]] -std::shared_ptr ChunkedArray__type( - const std::shared_ptr& chunked_array) { - return chunked_array->type(); +R6 ChunkedArray__type(const std::shared_ptr& chunked_array) { + return cpp11::r6_DataType(chunked_array->type()); } // [[arrow::export]] diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 5c5884b16b2..28c524b1555 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -131,7 +131,7 @@ arrow::Datum as_cpp(SEXP x) { SEXP from_datum(arrow::Datum datum) { switch (datum.kind()) { case arrow::Datum::SCALAR: - return cpp11::as_sexp(datum.scalar()); + return cpp11::r6_Scalar(datum.scalar()); case arrow::Datum::ARRAY: return cpp11::r6_Array(datum.make_array()); diff --git a/r/src/csv.cpp b/r/src/csv.cpp index cb3fb9b5ef7..02845908e83 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -161,14 +161,13 @@ std::string TimestampParser__format( } // [[arrow::export]] -std::shared_ptr TimestampParser__MakeStrptime( - std::string format) { - return arrow::TimestampParser::MakeStrptime(format); +R6 TimestampParser__MakeStrptime(std::string format) { + return cpp11::r6(arrow::TimestampParser::MakeStrptime(format), "TimestampParser"); } // [[arrow::export]] -std::shared_ptr TimestampParser__MakeISO8601() { - return arrow::TimestampParser::MakeISO8601(); +R6 TimestampParser__MakeISO8601() { + return cpp11::r6(arrow::TimestampParser::MakeISO8601(), "TimestampParser"); } #endif diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 1393b4fe1c7..2fdaab8dd94 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -31,6 +31,7 @@ namespace fs = ::arrow::fs; namespace cpp11 { R6 r6_Dataset(const std::shared_ptr& dataset) { + if (dataset == nullptr) return R_NilValue; auto type_name = dataset->type_name(); if (type_name == "union") { @@ -43,6 +44,7 @@ R6 r6_Dataset(const std::shared_ptr& dataset) { } R6 r6_FileSystem(const std::shared_ptr& file_system) { + if (file_system == nullptr) return R_NilValue; auto type_name = file_system->type_name(); if (type_name == "local") { @@ -57,6 +59,7 @@ R6 r6_FileSystem(const std::shared_ptr& file_system) { } R6 r6_FileFormat(const std::shared_ptr& file_format) { + if (file_format == nullptr) return R_NilValue; auto type_name = file_format->type_name(); if (type_name == "parquet") { return cpp11::r6(file_format, "ParquetFileFormat"); @@ -110,9 +113,9 @@ R6 dataset___InMemoryDataset__create(const std::shared_ptr& table) } // [[arrow::export]] -ds::DatasetVector dataset___UnionDataset__children( +cpp11::list dataset___UnionDataset__children( const std::shared_ptr& ds) { - return ds->children(); + return arrow::r::to_r_list(ds->children(), cpp11::r6_Dataset); } // [[arrow::export]] @@ -219,8 +222,7 @@ std::string dataset___FileFormat__type_name( } // [[arrow::export]] -R6 dataset___FileFormat__DefaultWriteOptions( - const std::shared_ptr& fmt) { +R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt) { return cpp11::r6(fmt->DefaultWriteOptions(), "FileWriteOptions"); } @@ -377,8 +379,7 @@ R6 dataset___Scanner__head(const std::shared_ptr& scanner, int n) { } // [[arrow::export]] -std::vector> dataset___Scanner__Scan( - const std::shared_ptr& scanner) { +cpp11::list dataset___Scanner__Scan(const std::shared_ptr& scanner) { auto it = ValueOrStop(scanner->Scan()); std::vector> out; std::shared_ptr scan_task; @@ -387,17 +388,19 @@ std::vector> dataset___Scanner__Scan( scan_task = ValueOrStop(st); out.push_back(scan_task); } - return out; + + return arrow::r::to_r_list(out, [](const std::shared_ptr& task) { + return cpp11::r6(task, "ScanTask"); + }); } // [[arrow::export]] -std::shared_ptr dataset___Scanner__schema( - const std::shared_ptr& sc) { - return sc->schema(); +R6 dataset___Scanner__schema(const std::shared_ptr& sc) { + return cpp11::r6(sc->schema(), "Schema"); } // [[arrow::export]] -std::vector> dataset___ScanTask__get_batches( +cpp11::list dataset___ScanTask__get_batches( const std::shared_ptr& scan_task) { arrow::RecordBatchIterator rbi; rbi = ValueOrStop(scan_task->Execute()); @@ -407,7 +410,7 @@ std::vector> dataset___ScanTask__get_batches batch = ValueOrStop(b); out.push_back(batch); } - return out; + return arrow::r::to_r_list(out, cpp11::r6_RecordBatch); } // [[arrow::export]] diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index de1ddd25d36..9e455f03b64 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -20,121 +20,199 @@ #if defined(ARROW_R_WITH_ARROW) #include -// [[arrow::export]] -bool shared_ptr_is_null(SEXP xp) { - return reinterpret_cast*>(R_ExternalPtrAddr(xp))->get() == - nullptr; -} +namespace cpp11 { +R6 r6_DataType(const std::shared_ptr& type) { + if (type == nullptr) return R_NilValue; + + using arrow::Type; -// [[arrow::export]] -bool unique_ptr_is_null(SEXP xp) { - return reinterpret_cast*>(R_ExternalPtrAddr(xp))->get() == - nullptr; + switch (type->id()) { + case Type::NA: + return r6(type, "Null"); + case Type::BOOL: + return r6(type, "Boolean"); + case Type::UINT8: + return r6(type, "UInt8"); + case Type::UINT16: + return r6(type, "UInt16"); + case Type::UINT32: + return r6(type, "UInt32"); + case Type::UINT64: + return r6(type, "UInt64"); + + case Type::INT8: + return r6(type, "Int8"); + case Type::INT16: + return r6(type, "Int16"); + case Type::INT32: + return r6(type, "Int32"); + case Type::INT64: + return r6(type, "Int64"); + + case Type::HALF_FLOAT: + return r6(type, "Float16"); + case Type::FLOAT: + return r6(type, "Float32"); + case Type::DOUBLE: + return r6(type, "Float64"); + + case Type::STRING: + return r6(type, "Utf8"); + case Type::LARGE_STRING: + return r6(type, "LargeUtf8"); + + case Type::BINARY: + return r6(type, "Binary"); + case Type::FIXED_SIZE_BINARY: + return r6(type, "FixedSizeBinary"); + case Type::LARGE_BINARY: + return r6(type, "LargeBinary"); + + case Type::DATE32: + return r6(type, "Date32"); + case Type::DATE64: + return r6(type, "Date64"); + case Type::TIMESTAMP: + return r6(type, "Timestamp"); + + case Type::TIME32: + return r6(type, "Time32"); + case Type::TIME64: + return r6(type, "Time64"); + + case Type::DECIMAL: + return r6(type, "Decimal128Type"); + + case Type::LIST: + return r6(type, "ListType"); + case Type::LARGE_LIST: + return r6(type, "LargeListType"); + case Type::FIXED_SIZE_LIST: + return r6(type, "FixedSizeListType"); + + case Type::STRUCT: + return r6(type, "StructType"); + case Type::DICTIONARY: + return r6(type, "DictionaryType"); + + default: + break; + }; + + return r6(type, "DataType"); + + // switch(names(Type)[self$id + 1], + // + // INTERVAL = stop("Type INTERVAL not implemented yet"), + // SPARSE_UNION = stop("Type SPARSE_UNION not implemented yet"), + // DENSE_UNION = stop("Type DENSE_UNION not implemented yet"), + // MAP = stop("Type MAP not implemented yet"), + // EXTENSION = stop("Type EXTENSION not implemented yet"), + // DURATION = stop("Type DURATION not implemented yet"), } +} // namespace cpp11 + // [[arrow::export]] -std::shared_ptr Int8__initialize() { return arrow::int8(); } +R6 Int8__initialize() { return cpp11::r6(arrow::int8(), "Int8"); } // [[arrow::export]] -std::shared_ptr Int16__initialize() { return arrow::int16(); } +R6 Int16__initialize() { return cpp11::r6(arrow::int16(), "Int16"); } // [[arrow::export]] -std::shared_ptr Int32__initialize() { return arrow::int32(); } +R6 Int32__initialize() { return cpp11::r6(arrow::int32(), "Int32"); } // [[arrow::export]] -std::shared_ptr Int64__initialize() { return arrow::int64(); } +R6 Int64__initialize() { return cpp11::r6(arrow::int64(), "Int64"); } // [[arrow::export]] -std::shared_ptr UInt8__initialize() { return arrow::uint8(); } +R6 UInt8__initialize() { return cpp11::r6(arrow::uint8(), "UInt8"); } // [[arrow::export]] -std::shared_ptr UInt16__initialize() { return arrow::uint16(); } +R6 UInt16__initialize() { return cpp11::r6(arrow::uint16(), "UInt16"); } // [[arrow::export]] -std::shared_ptr UInt32__initialize() { return arrow::uint32(); } +R6 UInt32__initialize() { return cpp11::r6(arrow::uint32(), "UInt32"); } // [[arrow::export]] -std::shared_ptr UInt64__initialize() { return arrow::uint64(); } +R6 UInt64__initialize() { return cpp11::r6(arrow::uint64(), "UInt64"); } // [[arrow::export]] -std::shared_ptr Float16__initialize() { return arrow::float16(); } +R6 Float16__initialize() { return cpp11::r6(arrow::float16(), "Float16"); } // [[arrow::export]] -std::shared_ptr Float32__initialize() { return arrow::float32(); } +R6 Float32__initialize() { return cpp11::r6(arrow::float32(), "Float32"); } // [[arrow::export]] -std::shared_ptr Float64__initialize() { return arrow::float64(); } +R6 Float64__initialize() { return cpp11::r6(arrow::float64(), "Float64"); } // [[arrow::export]] -std::shared_ptr Boolean__initialize() { return arrow::boolean(); } +R6 Boolean__initialize() { return cpp11::r6(arrow::boolean(), "Boolean"); } // [[arrow::export]] -std::shared_ptr Utf8__initialize() { return arrow::utf8(); } +R6 Utf8__initialize() { return cpp11::r6(arrow::utf8(), "Utf8"); } // [[arrow::export]] -std::shared_ptr LargeUtf8__initialize() { return arrow::large_utf8(); } +R6 LargeUtf8__initialize() { return cpp11::r6(arrow::large_utf8(), "LargeUtf8"); } // [[arrow::export]] -std::shared_ptr Binary__initialize() { return arrow::binary(); } +R6 Binary__initialize() { return cpp11::r6(arrow::binary(), "Binary"); } // [[arrow::export]] -std::shared_ptr LargeBinary__initialize() { - return arrow::large_binary(); -} +R6 LargeBinary__initialize() { return cpp11::r6(arrow::large_binary(), "LargeBinary"); } // [[arrow::export]] -std::shared_ptr Date32__initialize() { return arrow::date32(); } +R6 Date32__initialize() { return cpp11::r6(arrow::date32(), "Date32"); } // [[arrow::export]] -std::shared_ptr Date64__initialize() { return arrow::date64(); } +R6 Date64__initialize() { return cpp11::r6(arrow::date64(), "Date64"); } // [[arrow::export]] -std::shared_ptr Null__initialize() { return arrow::null(); } +R6 Null__initialize() { return cpp11::r6(arrow::null(), "Null"); } // [[arrow::export]] -std::shared_ptr Decimal128Type__initialize(int32_t precision, - int32_t scale) { +R6 Decimal128Type__initialize(int32_t precision, int32_t scale) { // Use the builder that validates inputs - return ValueOrStop(arrow::Decimal128Type::Make(precision, scale)); + return cpp11::r6(ValueOrStop(arrow::Decimal128Type::Make(precision, scale)), + "Decimal128Type"); } // [[arrow::export]] -std::shared_ptr FixedSizeBinary__initialize(R_xlen_t byte_width) { +R6 FixedSizeBinary__initialize(R_xlen_t byte_width) { if (byte_width == NA_INTEGER) { cpp11::stop("'byte_width' cannot be NA"); } if (byte_width < 1) { cpp11::stop("'byte_width' must be > 0"); } - return arrow::fixed_size_binary(byte_width); + return cpp11::r6(arrow::fixed_size_binary(byte_width), "FixedSizeBinary"); } // [[arrow::export]] -std::shared_ptr Timestamp__initialize(arrow::TimeUnit::type unit, - const std::string& timezone) { - return arrow::timestamp(unit, timezone); +R6 Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone) { + return cpp11::r6(arrow::timestamp(unit, timezone), "Timestamp"); } // [[arrow::export]] -std::shared_ptr Time32__initialize(arrow::TimeUnit::type unit) { - return arrow::time32(unit); +R6 Time32__initialize(arrow::TimeUnit::type unit) { + return cpp11::r6(arrow::time32(unit), "Time32"); } // [[arrow::export]] -std::shared_ptr Time64__initialize(arrow::TimeUnit::type unit) { - return arrow::time64(unit); +R6 Time64__initialize(arrow::TimeUnit::type unit) { + return cpp11::r6(arrow::time64(unit), "Time64"); } // [[arrow::export]] -SEXP list__(SEXP x) { +R6 list__(SEXP x) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); - return cpp11::as_sexp(arrow::list(field)); + return cpp11::r6(arrow::list(field), "ListType"); } if (Rf_inherits(x, "DataType")) { auto type = cpp11::as_cpp>(x); - return cpp11::as_sexp(arrow::list(type)); + return cpp11::r6(arrow::list(type), "ListType"); } cpp11::stop("incompatible"); @@ -142,15 +220,15 @@ SEXP list__(SEXP x) { } // [[arrow::export]] -SEXP large_list__(SEXP x) { +R6 large_list__(SEXP x) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); - return cpp11::as_sexp(arrow::large_list(field)); + return cpp11::r6(arrow::large_list(field), "LargeListType"); } if (Rf_inherits(x, "DataType")) { auto type = cpp11::as_cpp>(x); - return cpp11::as_sexp(arrow::large_list(type)); + return cpp11::r6(arrow::large_list(type), "LargeListType"); } cpp11::stop("incompatible"); @@ -158,15 +236,15 @@ SEXP large_list__(SEXP x) { } // [[arrow::export]] -SEXP fixed_size_list__(SEXP x, int list_size) { +R6 fixed_size_list__(SEXP x, int list_size) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); - return cpp11::as_sexp(arrow::fixed_size_list(field, list_size)); + return cpp11::r6(arrow::fixed_size_list(field, list_size), "FixedSizeListType"); } if (Rf_inherits(x, "DataType")) { auto type = cpp11::as_cpp>(x); - return cpp11::as_sexp(arrow::fixed_size_list(type, list_size)); + return cpp11::r6(arrow::fixed_size_list(type, list_size), "FixedSizeListType"); } cpp11::stop("incompatible"); @@ -174,9 +252,8 @@ SEXP fixed_size_list__(SEXP x, int list_size) { } // [[arrow::export]] -std::shared_ptr struct__( - const std::vector>& fields) { - return arrow::struct_(fields); +R6 struct__(const std::vector>& fields) { + return cpp11::r6(arrow::struct_(fields), "StructType"); } // [[arrow::export]] @@ -201,9 +278,8 @@ int DataType__num_fields(const std::shared_ptr& type) { } // [[arrow::export]] -std::vector> DataType__fields( - const std::shared_ptr& type) { - return type->fields(); +cpp11::list DataType__fields(const std::shared_ptr& type) { + return arrow::r::to_r_list(type->fields(), cpp11::r6_Field); } // [[arrow::export]] @@ -261,15 +337,13 @@ R6 DictionaryType__initialize(const std::shared_ptr& index_type } // [[arrow::export]] -std::shared_ptr DictionaryType__index_type( - const std::shared_ptr& type) { - return type->index_type(); +R6 DictionaryType__index_type(const std::shared_ptr& type) { + return cpp11::r6_DataType(type->index_type()); } // [[arrow::export]] -std::shared_ptr DictionaryType__value_type( - const std::shared_ptr& type) { - return type->value_type(); +R6 DictionaryType__value_type(const std::shared_ptr& type) { + return cpp11::r6_DataType(type->value_type()); } // [[arrow::export]] @@ -300,9 +374,8 @@ R6 ListType__value_field(const std::shared_ptr& type) { } // [[arrow::export]] -std::shared_ptr ListType__value_type( - const std::shared_ptr& type) { - return type->value_type(); +R6 ListType__value_type(const std::shared_ptr& type) { + return cpp11::r6_DataType(type->value_type()); } // [[arrow::export]] @@ -311,9 +384,8 @@ R6 LargeListType__value_field(const std::shared_ptr& type) } // [[arrow::export]] -std::shared_ptr LargeListType__value_type( - const std::shared_ptr& type) { - return type->value_type(); +R6 LargeListType__value_type(const std::shared_ptr& type) { + return cpp11::r6_DataType(type->value_type()); } // [[arrow::export]] @@ -322,9 +394,8 @@ R6 FixedSizeListType__value_field(const std::shared_ptr FixedSizeListType__value_type( - const std::shared_ptr& type) { - return type->value_type(); +R6 FixedSizeListType__value_type(const std::shared_ptr& type) { + return cpp11::r6_DataType(type->value_type()); } // [[arrow::export]] diff --git a/r/src/field.cpp b/r/src/field.cpp index 67469ca863b..3057d8218ff 100644 --- a/r/src/field.cpp +++ b/r/src/field.cpp @@ -20,6 +20,10 @@ #if defined(ARROW_R_WITH_ARROW) #include +namespace cpp11 { +R6 r6_Field(const std::shared_ptr& field) { return r6(field, "Field"); } +} // namespace cpp11 + // [[arrow::export]] R6 Field__initialize(const std::string& name, const std::shared_ptr& field, @@ -49,8 +53,8 @@ bool Field__nullable(const std::shared_ptr& field) { } // [[arrow::export]] -std::shared_ptr Field__type(const std::shared_ptr& field) { - return field->type(); +R6 Field__type(const std::shared_ptr& field) { + return cpp11::r6_DataType(field->type()); } #endif diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index f365d3298b5..26229c30f9c 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -122,19 +122,26 @@ std::vector> shared_ptr_vector(const std::vector& vec) { } // [[arrow::export]] -std::vector> fs___FileSystem__GetTargetInfos_Paths( +cpp11::list fs___FileSystem__GetTargetInfos_Paths( const std::shared_ptr& file_system, const std::vector& paths) { auto results = ValueOrStop(file_system->GetFileInfo(paths)); - return shared_ptr_vector(results); + return arrow::r::to_r_list(shared_ptr_vector(results), + [](const std::shared_ptr& info) { + return cpp11::r6(info, "FileInfo"); + }); } // [[arrow::export]] -std::vector> fs___FileSystem__GetTargetInfos_FileSelector( +cpp11::list fs___FileSystem__GetTargetInfos_FileSelector( const std::shared_ptr& file_system, const std::shared_ptr& selector) { auto results = ValueOrStop(file_system->GetFileInfo(*selector)); - return shared_ptr_vector(results); + + return arrow::r::to_r_list(shared_ptr_vector(results), + [](const std::shared_ptr& info) { + return cpp11::r6(info, "FileInfo"); + }); } // [[arrow::export]] diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp index a2bc3217b78..f17896a11f6 100644 --- a/r/src/recordbatch.cpp +++ b/r/src/recordbatch.cpp @@ -26,6 +26,12 @@ #include #include +namespace cpp11 { +R6 r6_RecordBatch(const std::shared_ptr& batch) { + return r6(batch, "RecordBatch"); +} +} // namespace cpp11 + // [[arrow::export]] int RecordBatch__num_columns(const std::shared_ptr& x) { return x->num_columns(); @@ -52,14 +58,13 @@ R6 RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& } // [[arrow::export]] -arrow::ArrayVector RecordBatch__columns( - const std::shared_ptr& batch) { +cpp11::list RecordBatch__columns(const std::shared_ptr& batch) { auto nc = batch->num_columns(); arrow::ArrayVector res(nc); for (int i = 0; i < nc; i++) { res[i] = batch->column(i); } - return res; + return arrow::r::to_r_list(res, cpp11::r6_Array); } // [[arrow::export]] @@ -71,7 +76,8 @@ R6 RecordBatch__column(const std::shared_ptr& batch, R_xlen_ // [[arrow::export]] R6 RecordBatch__GetColumnByName(const std::shared_ptr& batch, const std::string& name) { - return cpp11::r6_Array(batch->GetColumnByName(name)); + auto array = batch->GetColumnByName(name); + return cpp11::r6_Array(array); } // [[arrow::export]] diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp index 8101a274480..9c1fdc0e507 100644 --- a/r/src/recordbatchreader.cpp +++ b/r/src/recordbatchreader.cpp @@ -43,7 +43,7 @@ R6 ipc___RecordBatchStreamReader__Open( } // [[arrow::export]] -std::vector> ipc___RecordBatchStreamReader__batches( +cpp11::list ipc___RecordBatchStreamReader__batches( const std::shared_ptr& reader) { std::vector> res; @@ -55,7 +55,7 @@ std::vector> ipc___RecordBatchStreamReader__ res.push_back(batch); } - return res; + return arrow::r::to_r_list(res, cpp11::r6_RecordBatch); } // -------- RecordBatchFileReader @@ -117,7 +117,7 @@ R6 Table__from_RecordBatchStreamReader( } // [[arrow::export]] -std::vector> ipc___RecordBatchFileReader__batches( +cpp11::list ipc___RecordBatchFileReader__batches( const std::shared_ptr& reader) { auto n = reader->num_record_batches(); std::vector> res(n); @@ -126,7 +126,7 @@ std::vector> ipc___RecordBatchFileReader__ba res[i] = ValueOrStop(reader->ReadRecordBatch(i)); } - return res; + return arrow::r::to_r_list(res, cpp11::r6_RecordBatch); } #endif diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index d198dddc2e0..1ea8886252a 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -27,6 +27,8 @@ namespace cpp11 { R6 r6_Scalar(const std::shared_ptr& ptr) { + if (ptr == nullptr) return R_NilValue; + std::string type = "Scalar"; if (ptr->type->id() == arrow::Type::STRUCT) { type = "StructScalar"; @@ -76,8 +78,8 @@ SEXP Scalar__as_vector(const std::shared_ptr& scalar) { bool Scalar__is_valid(const std::shared_ptr& s) { return s->is_valid; } // [[arrow::export]] -std::shared_ptr Scalar__type(const std::shared_ptr& s) { - return s->type; +R6 Scalar__type(const std::shared_ptr& s) { + return cpp11::r6_DataType(s->type); } #endif diff --git a/r/src/schema.cpp b/r/src/schema.cpp index 8d55a36ed08..f1bf958902f 100644 --- a/r/src/schema.cpp +++ b/r/src/schema.cpp @@ -52,9 +52,8 @@ R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x } // [[arrow::export]] -std::vector> Schema__fields( - const std::shared_ptr& schema) { - return schema->fields(); +cpp11::list Schema__fields(const std::shared_ptr& schema) { + return arrow::r::to_r_list(schema->fields(), cpp11::r6_Field); } // [[arrow::export]] diff --git a/r/src/table.cpp b/r/src/table.cpp index 346162acb34..f007470e8ad 100644 --- a/r/src/table.cpp +++ b/r/src/table.cpp @@ -58,14 +58,13 @@ R6 Table__field(const std::shared_ptr& table, R_xlen_t i) { } // [[arrow::export]] -std::vector> Table__columns( - const std::shared_ptr& table) { +cpp11::list Table__columns(const std::shared_ptr& table) { auto nc = table->num_columns(); std::vector> res(nc); for (int i = 0; i < nc; i++) { res[i] = table->column(i); } - return res; + return arrow::r::to_r_list(res, cpp11::r6_ChunkedArray); } // [[arrow::export]] diff --git a/r/tests/testthat/helper-roundtrip.R b/r/tests/testthat/helper-roundtrip.R index 16d002c9f2a..4aa435cd298 100644 --- a/r/tests/testthat/helper-roundtrip.R +++ b/r/tests/testthat/helper-roundtrip.R @@ -19,7 +19,7 @@ expect_array_roundtrip <- function(x, type, as = NULL) { a <- Array$create(x, type = as) expect_type_equal(a$type, type) expect_identical(length(a), length(x)) - if (!inherits(type, c("ListType", "LargeListType"))) { + if (!inherits(type, c("ListType", "LargeListType", "FixedSizeListType"))) { # TODO: revisit how missingness works with ListArrays # R list objects don't handle missingness the same way as other vectors. # Is there some vctrs thing we should do on the roundtrip back to R? @@ -34,7 +34,7 @@ expect_array_roundtrip <- function(x, type, as = NULL) { x_sliced <- x[-1] expect_type_equal(a_sliced$type, type) expect_identical(length(a_sliced), length(x_sliced)) - if (!inherits(type, c("ListType", "LargeListType"))) { + if (!inherits(type, c("ListType", "LargeListType", "FixedSizeListType"))) { expect_equal(as.vector(is.na(a_sliced)), is.na(x_sliced)) } expect_equivalent(as.vector(a_sliced), x_sliced) From d2f598e79ccc2241fc5f1c1bc94287a12892cd8d Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 9 Oct 2020 10:41:42 +0200 Subject: [PATCH 13/43] You don't need a ; after a } [readability/braces] [4] --- r/src/datatype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index 9e455f03b64..13629428cf5 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -97,7 +97,7 @@ R6 r6_DataType(const std::shared_ptr& type) { default: break; - }; + } return r6(type, "DataType"); From ff20e20712f76ff7bcda2bb8066fe256f4c20a32 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 9 Oct 2020 11:03:54 +0200 Subject: [PATCH 14/43] dispatch FileSystem --- r/src/arrow_types.h | 2 ++ r/src/filesystem.cpp | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index cc86dbedbfc..7c9a24afcee 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -25,6 +25,7 @@ #include // for RBuffer definition below #include +#include #include #include @@ -127,6 +128,7 @@ R6 r6_Field(const std::shared_ptr& field); R6 r6_ChunkedArray(const std::shared_ptr& array); R6 r6_RecordBatch(const std::shared_ptr& batch); R6 r6_Scalar(const std::shared_ptr& ptr); +R6 r6_FileSystem(const std::shared_ptr& file_system); } // namespace cpp11 diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 26229c30f9c..f36cc7d5ea3 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -245,9 +245,8 @@ cpp11::writable::list fs___FileSystemFromUri(const std::string& path) { using cpp11::literals::operator"" _nm; std::string out_path; - auto file_system = ValueOrStop(fs::FileSystemFromUri(path, &out_path)); - // TODO: needs to call the FileSystem dispatcher - cpp11::sexp out_fs = cpp11::r6(file_system, "FileSystem"); + cpp11::sexp out_fs = + cpp11::r6_FileSystem(ValueOrStop(fs::FileSystemFromUri(path, &out_path))); return cpp11::writable::list({"fs"_nm = out_fs, "path"_nm = out_path}); } From 17acc8be4a51fa26585069f1f97ea24feade2b28 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 9 Oct 2020 11:25:43 +0200 Subject: [PATCH 15/43] replace only (undocumented) use of glue with paste0() --- r/R/expression.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/R/expression.R b/r/R/expression.R index 3d2cbd6e987..d5623fb7786 100644 --- a/r/R/expression.R +++ b/r/R/expression.R @@ -37,7 +37,7 @@ Ops.Array <- function(e1, e2) { expr <- build_array_expression(.Generic, e1, e2) eval_array_expression(expr) } else { - stop(glue::glue("Unsupported operation on {class(e1)[1L]} : "), .Generic, call. = FALSE) + stop(paste0("Unsupported operation on `", class(e1)[1L], "` : "), .Generic, call. = FALSE) } } From 992f6f3bf31b11a1ecadc7f24fe8146e67b4f224 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Wed, 28 Oct 2020 10:30:15 +0100 Subject: [PATCH 16/43] finish rebase --- r/R/filesystem.R | 2 +- r/src/arrowExports.cpp | 2 +- r/src/filesystem.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/r/R/filesystem.R b/r/R/filesystem.R index d35009c49c4..21738c17986 100644 --- a/r/R/filesystem.R +++ b/r/R/filesystem.R @@ -405,7 +405,7 @@ s3_bucket <- function(bucket, ...) { SubTreeFileSystem <- R6Class("SubTreeFileSystem", inherit = FileSystem, active = list( base_fs = function() { - shared_ptr(FileSystem, fs___SubTreeFileSystem__base_fs(self))$..dispatch() + fs___SubTreeFileSystem__base_fs(self) }, base_path = function() fs___SubTreeFileSystem__base_path(self) ) diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index 1b2af0f9d66..1ddea322833 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -3723,7 +3723,7 @@ extern "C" SEXP _arrow_fs___SubTreeFileSystem__create(SEXP base_path_sexp, SEXP // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr fs___SubTreeFileSystem__base_fs(const std::shared_ptr& file_system); +R6 fs___SubTreeFileSystem__base_fs(const std::shared_ptr& file_system); extern "C" SEXP _arrow_fs___SubTreeFileSystem__base_fs(SEXP file_system_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index f36cc7d5ea3..623554fbc0c 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -229,9 +229,9 @@ R6 fs___SubTreeFileSystem__create(const std::string& base_path, } // [[arrow::export]] -std::shared_ptr fs___SubTreeFileSystem__base_fs( +R6 fs___SubTreeFileSystem__base_fs( const std::shared_ptr& file_system) { - return file_system->base_fs(); + return cpp11::r6_FileSystem(file_system->base_fs()); } // [[arrow::export]] From 43a99d1896a68dd3b51358b57173fc36e4be26bc Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 9 Oct 2020 16:30:05 +0200 Subject: [PATCH 17/43] attempt to release memory early --- r/R/arrow-package.R | 13 +++++++++++++ r/R/dplyr.R | 11 +++++++---- r/data-raw/codegen.R | 31 +++++++++++++++++++++++++++++++ r/src/arrowExports.cpp | 26 ++++++++++++++++++++++++++ r/src/arrow_cpp11.h | 16 ++++++++++------ 5 files changed, 87 insertions(+), 10 deletions(-) diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index 7f58c899f19..289fd803919 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -79,6 +79,8 @@ option_use_threads <- function() { !is_false(getOption("arrow.use_threads")) } +ns_arrow <- environment() + #' @include enums.R ArrowObject <- R6Class("ArrowObject", public = list( @@ -108,6 +110,17 @@ ArrowObject <- R6Class("ArrowObject", cat(self$ToString(), "\n", sep = "") } invisible(self) + }, + + invalidate = function() { + cl <- class(self)[1L] + # if there is a Reset function for that class, call it + reset <- get(paste0("_arrow_", cl, "__Reset"), ns_arrow) + if (!is.null(reset)) { + get(".Call")(reset, self) + } + # but in any case, set the external pointer to NULL + assign(".:xp:.", NULL, envir = self) } ) ) diff --git a/r/R/dplyr.R b/r/R/dplyr.R index fd69c852e68..f3dd078c952 100644 --- a/r/R/dplyr.R +++ b/r/R/dplyr.R @@ -285,15 +285,18 @@ collect.arrow_dplyr_query <- function(x, as_data_frame = TRUE, ...) { # Pull only the selected rows and cols into R if (query_on_dataset(x)) { # See dataset.R for Dataset and Scanner(Builder) classes - df <- Scanner$create(x)$ToTable() + tab <- Scanner$create(x)$ToTable() } else { # This is a Table/RecordBatch. See record-batch.R for the [ method - df <- x$.data[x$filtered_rows, x$selected_columns, keep_na = FALSE] + tab <- x$.data[x$filtered_rows, x$selected_columns, keep_na = FALSE] } if (as_data_frame) { - df <- as.data.frame(df) + df <- as.data.frame(tab) + tab$invalidate() + restore_dplyr_features(df, x) + } else { + restore_dplyr_features(tab, x) } - restore_dplyr_features(df, x) } collect.Table <- as.data.frame.Table collect.RecordBatch <- as.data.frame.RecordBatch diff --git a/r/data-raw/codegen.R b/r/data-raw/codegen.R index ede4043c46f..dbe2de62f3d 100644 --- a/r/data-raw/codegen.R +++ b/r/data-raw/codegen.R @@ -71,6 +71,11 @@ wrap_call <- function(name, return_type, args) { all_decorations <- cpp_decorations() arrow_exports <- get_exported_functions(all_decorations, c("arrow", "s3")) +arrow_classes <- c( + "Table" = "arrow::Table", + "RecordBatch" = "arrow::RecordBatch" +) + cpp_functions_definitions <- arrow_exports %>% select(name, return_type, args, file, line, decoration) %>% pmap_chr(function(name, return_type, args, file, line, decoration){ @@ -106,6 +111,30 @@ cpp_functions_registration <- arrow_exports %>% }) %>% glue_collapse(sep = "\n") +cpp_classes_finalizers <- map2(names(arrow_classes), arrow_classes, function(name, class) { + glue::glue(' + # if defined(ARROW_R_WITH_ARROW) + extern "C" SEXP _arrow_{name}__Reset(SEXP r6) {{ + BEGIN_CPP11 + arrow::r::r6_reset_pointer<{class}>(r6); + END_CPP11 + return R_NilValue; + }} + # else + extern "C" SEXP _arrow_{name}__Reset(SEXP r6) {{ + Rf_error("Cannot call _arrow_{name}__Reset(). Please use arrow::install_arrow() to install required runtime libraries. "); + }} + # endif + ') +}) %>% + glue_collapse(sep = "\n") + +classes_finalizers_registration <- map2(names(arrow_classes), arrow_classes, function(name, class) { + glue('\t\t{{ "_arrow_{name}__Reset", (DL_FUNC) &_arrow_{name}__Reset, 1}}, ') + }) %>% + glue_collapse(sep = "\n") + + writeLines(con = "src/arrowExports.cpp", glue::glue(' // Generated by using data-raw/codegen.R -> do not edit by hand #include @@ -114,6 +143,7 @@ writeLines(con = "src/arrowExports.cpp", glue::glue(' #include "./arrow_exports.h" {cpp_functions_definitions} +{cpp_classes_finalizers} extern "C" SEXP _arrow_available() {{ return Rf_ScalarLogical( @@ -139,6 +169,7 @@ static const R_CallMethodDef CallEntries[] = {{ \t\t{{ "_arrow_available", (DL_FUNC)& _arrow_available, 0 }}, \t\t{{ "_s3_available", (DL_FUNC)& _s3_available, 0 }}, {cpp_functions_registration} +{classes_finalizers_registration} \t\t{{NULL, NULL, 0}} }}; diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index 1ddea322833..5e71f06ec87 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -6274,6 +6274,30 @@ extern "C" SEXP _arrow_SetCpuThreadPoolCapacity(SEXP threads_sexp){ } #endif +# if defined(ARROW_R_WITH_ARROW) +extern "C" SEXP _arrow_Table__Reset(SEXP r6) { + BEGIN_CPP11 + arrow::r::r6_reset_pointer(r6); + END_CPP11 + return R_NilValue; +} +# else +extern "C" SEXP _arrow_Table__Reset(SEXP r6) { + Rf_error("Cannot call _arrow_Table__Reset(). Please use arrow::install_arrow() to install required runtime libraries. "); +} +# endif +# if defined(ARROW_R_WITH_ARROW) +extern "C" SEXP _arrow_RecordBatch__Reset(SEXP r6) { + BEGIN_CPP11 + arrow::r::r6_reset_pointer(r6); + END_CPP11 + return R_NilValue; +} +# else +extern "C" SEXP _arrow_RecordBatch__Reset(SEXP r6) { + Rf_error("Cannot call _arrow_RecordBatch__Reset(). Please use arrow::install_arrow() to install required runtime libraries. "); +} +# endif extern "C" SEXP _arrow_available() { return Rf_ScalarLogical( @@ -6698,6 +6722,8 @@ static const R_CallMethodDef CallEntries[] = { { "_arrow_Table__from_dots", (DL_FUNC) &_arrow_Table__from_dots, 2}, { "_arrow_GetCpuThreadPoolCapacity", (DL_FUNC) &_arrow_GetCpuThreadPoolCapacity, 0}, { "_arrow_SetCpuThreadPoolCapacity", (DL_FUNC) &_arrow_SetCpuThreadPoolCapacity, 1}, + { "_arrow_Table__Reset", (DL_FUNC) &_arrow_Table__Reset, 1}, + { "_arrow_RecordBatch__Reset", (DL_FUNC) &_arrow_RecordBatch__Reset, 1}, {NULL, NULL, 0} }; diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index e9f09f97283..a3c04b7e320 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -166,6 +166,16 @@ Pointer r6_to_pointer(SEXP self) { return reinterpret_cast(p); } +template +void r6_reset_pointer(SEXP r6) { + SEXP xp = Rf_findVarInFrame(r6, arrow::r::symbols::xp); + void* p = R_ExternalPtrAddr(xp); + if (p != nullptr) { + delete reinterpret_cast*>(p); + R_SetExternalPtrAddr(xp, nullptr); + } +} + // T is either std::shared_ptr or std::unique_ptr // e.g. T = std::shared_ptr template @@ -259,12 +269,6 @@ cpp11::writable::strings to_r_strings(const std::vector>& x, return to_r_vector(x, std::forward(to_string)); } -// template -// cpp11::writable::list to_r_list(const std::vector>& x) { -// auto as_sexp = [](const std::shared_ptr& t) { return cpp11::as_sexp(t); }; -// return to_r_vector(x, as_sexp); -// } - template cpp11::writable::list to_r_list(const std::vector>& x, ToListElement&& to_element) { From 2ed53a62fca5f29d32952b06995781f8e2a85b2b Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Wed, 28 Oct 2020 17:39:45 +0100 Subject: [PATCH 18/43] simplify default invalidate() and use super$invalidate() where needed --- r/R/arrow-package.R | 9 --------- r/R/record-batch.R | 5 +++++ r/R/table.R | 6 ++++++ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/r/R/arrow-package.R b/r/R/arrow-package.R index 289fd803919..5d1dbbebdd3 100644 --- a/r/R/arrow-package.R +++ b/r/R/arrow-package.R @@ -79,8 +79,6 @@ option_use_threads <- function() { !is_false(getOption("arrow.use_threads")) } -ns_arrow <- environment() - #' @include enums.R ArrowObject <- R6Class("ArrowObject", public = list( @@ -113,13 +111,6 @@ ArrowObject <- R6Class("ArrowObject", }, invalidate = function() { - cl <- class(self)[1L] - # if there is a Reset function for that class, call it - reset <- get(paste0("_arrow_", cl, "__Reset"), ns_arrow) - if (!is.null(reset)) { - get(".Call")(reset, self) - } - # but in any case, set the external pointer to NULL assign(".:xp:.", NULL, envir = self) } ) diff --git a/r/R/record-batch.R b/r/R/record-batch.R index c2a20c792b0..c050ef806b8 100644 --- a/r/R/record-batch.R +++ b/r/R/record-batch.R @@ -121,6 +121,11 @@ RecordBatch <- R6Class("RecordBatch", inherit = ArrowObject, assert_that(identical(self$schema$names, target_schema$names), msg = "incompatible schemas") RecordBatch__cast(self, target_schema, options) + }, + + invalidate = function() { + .Call(`_arrow_RecordBatch__Reset`, self) + super$invalidate() } ), diff --git a/r/R/table.R b/r/R/table.R index cf25e898e62..bc85483be4e 100644 --- a/r/R/table.R +++ b/r/R/table.R @@ -150,7 +150,13 @@ Table <- R6Class("Table", inherit = ArrowObject, ValidateFull = function() { Table__ValidateFull(self) + }, + + invalidate = function() { + .Call(`_arrow_Table__Reset`, self) + super$invalidate() } + ), active = list( From 5639d3dd17bc65e10875876cddf16ccf4570b2ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Fran=C3=A7ois?= Date: Thu, 29 Oct 2020 09:48:57 +0100 Subject: [PATCH 19/43] Update r/R/filesystem.R Co-authored-by: Neal Richardson --- r/R/filesystem.R | 1 - 1 file changed, 1 deletion(-) diff --git a/r/R/filesystem.R b/r/R/filesystem.R index 21738c17986..ed0bc7adc7a 100644 --- a/r/R/filesystem.R +++ b/r/R/filesystem.R @@ -262,7 +262,6 @@ FileSystem <- R6Class("FileSystem", inherit = ArrowObject, # TODO: see fs package for glob/regexp filtering # TODO: verbose method that shows other attributes as df # TODO: print methods for FileInfo, SubTreeFileSystem, S3FileSystem - fs___FileSystem__OpenAppendStream(self, clean_path_rel(path)) } ), active = list( From 0bd9dc72e0c8d33b94debc12f3aa0914093bc7a6 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 29 Oct 2020 13:58:27 -0700 Subject: [PATCH 20/43] Clean up rebase --- r/R/dataset-format.R | 12 ++---------- r/R/dataset.R | 7 +------ r/src/dataset.cpp | 2 +- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/r/R/dataset-format.R b/r/R/dataset-format.R index 00bba8e91f5..eb57b893e0c 100644 --- a/r/R/dataset-format.R +++ b/r/R/dataset-format.R @@ -84,16 +84,8 @@ as.character.FileFormat <- function(x, ...) { ParquetFileFormat <- R6Class("ParquetFileFormat", inherit = FileFormat) ParquetFileFormat$create <- function(use_buffered_stream = FALSE, buffer_size = 8196, - dict_columns = character(0), - writer_properties = NULL, - arrow_writer_properties = NULL) { - if (is.null(writer_properties) && is.null(arrow_writer_properties)) { - dataset___ParquetFileFormat__MakeRead(use_buffered_stream, buffer_size, dict_columns) - } else { - writer_properties = writer_properties %||% ParquetWriterProperties$create() - arrow_writer_properties = arrow_writer_properties %||% ParquetArrowWriterProperties$create() - dataset___ParquetFileFormat__MakeWrite(writer_properties, arrow_writer_properties) - } + dict_columns = character(0)) { + dataset___ParquetFileFormat__Make(use_buffered_stream, buffer_size, dict_columns) } #' @usage NULL diff --git a/r/R/dataset.R b/r/R/dataset.R index 485c1c345e8..e990ff3cb86 100644 --- a/r/R/dataset.R +++ b/r/R/dataset.R @@ -149,12 +149,7 @@ Dataset <- R6Class("Dataset", inherit = ArrowObject, # Start a new scan of the data # @return A [ScannerBuilder] NewScan = function() dataset___Dataset__NewScan(self), - ToString = function() self$schema$ToString(), - write = function(path, filesystem = NULL, schema = self$schema, format, partitioning, ...) { - path_and_fs <- get_path_and_filesystem(path, filesystem) - dataset___Dataset__Write(self, schema, format, path_and_fs$fs, path_and_fs$path, partitioning) - invisible(self) - } + ToString = function() self$schema$ToString() ), active = list( schema = function(schema) { diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 2fdaab8dd94..68d9bc18cbf 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -227,7 +227,7 @@ R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr(); From 5173591e3d9eabddf1aa7b3503f1916c448050b6 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 29 Oct 2020 15:24:30 -0700 Subject: [PATCH 21/43] Final(?) cleanups --- r/R/arrowExports.R | 4 ++-- r/R/python.R | 2 +- r/src/arrowExports.cpp | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/r/R/arrowExports.R b/r/R/arrowExports.R index 2a3900e818c..991925d09fc 100644 --- a/r/R/arrowExports.R +++ b/r/R/arrowExports.R @@ -420,8 +420,8 @@ dataset___FileFormat__DefaultWriteOptions <- function(fmt){ .Call(`_arrow_dataset___FileFormat__DefaultWriteOptions` , fmt) } -dataset___ParquetFileFormat__MakeRead <- function(use_buffered_stream, buffer_size, dict_columns){ - .Call(`_arrow_dataset___ParquetFileFormat__MakeRead` , use_buffered_stream, buffer_size, dict_columns) +dataset___ParquetFileFormat__Make <- function(use_buffered_stream, buffer_size, dict_columns){ + .Call(`_arrow_dataset___ParquetFileFormat__Make` , use_buffered_stream, buffer_size, dict_columns) } dataset___FileWriteOptions__type_name <- function(options){ diff --git a/r/R/python.R b/r/R/python.R index f348316e87e..739f048b218 100644 --- a/r/R/python.R +++ b/r/R/python.R @@ -24,7 +24,7 @@ py_to_r.pyarrow.lib.Array <- function(x, ...) { }) x$`_export_to_c`(array_ptr, schema_ptr) - Array$create(ImportArray(array_ptr, schema_ptr)) + ImportArray(array_ptr, schema_ptr) } r_to_py.Array <- function(x, convert = FALSE) { diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index 5e71f06ec87..d188536f4bc 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -1647,18 +1647,18 @@ extern "C" SEXP _arrow_dataset___FileFormat__DefaultWriteOptions(SEXP fmt_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___ParquetFileFormat__MakeRead(bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns); -extern "C" SEXP _arrow_dataset___ParquetFileFormat__MakeRead(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ +R6 dataset___ParquetFileFormat__Make(bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns); +extern "C" SEXP _arrow_dataset___ParquetFileFormat__Make(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ BEGIN_CPP11 arrow::r::Input::type use_buffered_stream(use_buffered_stream_sexp); arrow::r::Input::type buffer_size(buffer_size_sexp); arrow::r::Input::type dict_columns(dict_columns_sexp); - return cpp11::as_sexp(dataset___ParquetFileFormat__MakeRead(use_buffered_stream, buffer_size, dict_columns)); + return cpp11::as_sexp(dataset___ParquetFileFormat__Make(use_buffered_stream, buffer_size, dict_columns)); END_CPP11 } #else -extern "C" SEXP _arrow_dataset___ParquetFileFormat__MakeRead(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ - Rf_error("Cannot call dataset___ParquetFileFormat__MakeRead(). Please use arrow::install_arrow() to install required runtime libraries. "); +extern "C" SEXP _arrow_dataset___ParquetFileFormat__Make(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ + Rf_error("Cannot call dataset___ParquetFileFormat__Make(). Please use arrow::install_arrow() to install required runtime libraries. "); } #endif @@ -6427,7 +6427,7 @@ static const R_CallMethodDef CallEntries[] = { { "_arrow_dataset___FileSystemDatasetFactory__Make3", (DL_FUNC) &_arrow_dataset___FileSystemDatasetFactory__Make3, 4}, { "_arrow_dataset___FileFormat__type_name", (DL_FUNC) &_arrow_dataset___FileFormat__type_name, 1}, { "_arrow_dataset___FileFormat__DefaultWriteOptions", (DL_FUNC) &_arrow_dataset___FileFormat__DefaultWriteOptions, 1}, - { "_arrow_dataset___ParquetFileFormat__MakeRead", (DL_FUNC) &_arrow_dataset___ParquetFileFormat__MakeRead, 3}, + { "_arrow_dataset___ParquetFileFormat__Make", (DL_FUNC) &_arrow_dataset___ParquetFileFormat__Make, 3}, { "_arrow_dataset___FileWriteOptions__type_name", (DL_FUNC) &_arrow_dataset___FileWriteOptions__type_name, 1}, { "_arrow_dataset___ParquetFileWriteOptions__update", (DL_FUNC) &_arrow_dataset___ParquetFileWriteOptions__update, 3}, { "_arrow_dataset___IpcFileWriteOptions__update2", (DL_FUNC) &_arrow_dataset___IpcFileWriteOptions__update2, 4}, From bed4adf047995bda8673c35150e0360fbbb04104 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 29 Oct 2020 15:53:26 -0700 Subject: [PATCH 22/43] lint --- r/src/dataset.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 68d9bc18cbf..ec4d4062a54 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -228,7 +228,7 @@ R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr(); fmt->reader_options.use_buffered_stream = use_buffered_stream; From 2f57f6bec43c185088e16db9a4848a5e4f9ffd2a Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 30 Oct 2020 10:08:07 +0100 Subject: [PATCH 23/43] remove DataType$children() and DataType$num_children() --- r/R/type.R | 7 -- r/tests/testthat/test-data-type.R | 104 +++++++++++++++--------------- 2 files changed, 52 insertions(+), 59 deletions(-) diff --git a/r/R/type.R b/r/R/type.R index fcefe83de3f..b21ead8e5ed 100644 --- a/r/R/type.R +++ b/r/R/type.R @@ -40,13 +40,6 @@ DataType <- R6Class("DataType", num_fields = function() { DataType__num_fields(self) }, - num_children = function() { - DataType__num_fields(self) - }, - children = function() { - # TODO: this is deprecated - DataType__fields(self) - }, fields = function() { DataType__fields(self) } diff --git a/r/tests/testthat/test-data-type.R b/r/tests/testthat/test-data-type.R index 8ff3fc36713..476b00c7854 100644 --- a/r/tests/testthat/test-data-type.R +++ b/r/tests/testthat/test-data-type.R @@ -24,8 +24,8 @@ test_that("null type works as expected",{ expect_equal(x$ToString(), "null") expect_true(x == x) expect_false(x == int8()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) }) test_that("boolean type work as expected",{ @@ -35,8 +35,8 @@ test_that("boolean type work as expected",{ expect_equal(x$ToString(), "bool") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 1L) }) @@ -47,8 +47,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "uint8") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 8L) x <- int8() @@ -57,8 +57,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "int8") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 8L) x <- uint16() @@ -67,8 +67,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "uint16") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 16L) x <- int16() @@ -77,8 +77,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "int16") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 16L) x <- uint32() @@ -87,8 +87,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "uint32") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 32L) x <- int32() @@ -97,8 +97,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "int32") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 32L) x <- uint64() @@ -107,8 +107,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "uint64") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) x <- int64() @@ -117,8 +117,8 @@ test_that("int types works as expected",{ expect_equal(x$ToString(), "int64") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) }) @@ -129,8 +129,8 @@ test_that("float types work as expected",{ expect_equal(x$ToString(), "halffloat") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 16L) x <- float32() @@ -139,8 +139,8 @@ test_that("float types work as expected",{ expect_equal(x$ToString(), "float") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 32L) x <- float64() @@ -149,8 +149,8 @@ test_that("float types work as expected",{ expect_equal(x$ToString(), "double") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) }) @@ -161,8 +161,8 @@ test_that("utf8 type works as expected",{ expect_equal(x$ToString(), "string") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) }) test_that("date types work as expected", { @@ -172,8 +172,8 @@ test_that("date types work as expected", { expect_equal(x$ToString(), "date32[day]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$unit(), unclass(DateUnit$DAY)) x <- date64() @@ -182,8 +182,8 @@ test_that("date types work as expected", { expect_equal(x$ToString(), "date64[ms]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$unit(), unclass(DateUnit$MILLI)) }) @@ -194,8 +194,8 @@ test_that("timestamp type works as expected", { expect_equal(x$ToString(), "timestamp[s]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) expect_equal(x$timezone(), "") expect_equal(x$unit(), unclass(TimeUnit$SECOND)) @@ -206,8 +206,8 @@ test_that("timestamp type works as expected", { expect_equal(x$ToString(), "timestamp[ms]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) expect_equal(x$timezone(), "") expect_equal(x$unit(), unclass(TimeUnit$MILLI)) @@ -218,8 +218,8 @@ test_that("timestamp type works as expected", { expect_equal(x$ToString(), "timestamp[us]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) expect_equal(x$timezone(), "") expect_equal(x$unit(), unclass(TimeUnit$MICRO)) @@ -230,8 +230,8 @@ test_that("timestamp type works as expected", { expect_equal(x$ToString(), "timestamp[ns]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) expect_equal(x$timezone(), "") expect_equal(x$unit(), unclass(TimeUnit$NANO)) @@ -248,8 +248,8 @@ test_that("time32 types work as expected", { expect_equal(x$ToString(), "time32[s]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 32L) expect_equal(x$unit(), unclass(TimeUnit$SECOND)) @@ -259,8 +259,8 @@ test_that("time32 types work as expected", { expect_equal(x$ToString(), "time32[ms]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 32L) expect_equal(x$unit(), unclass(TimeUnit$MILLI)) }) @@ -272,8 +272,8 @@ test_that("time64 types work as expected", { expect_equal(x$ToString(), "time64[us]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) expect_equal(x$unit(), unclass(TimeUnit$MICRO)) @@ -283,8 +283,8 @@ test_that("time64 types work as expected", { expect_equal(x$ToString(), "time64[ns]") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 0L) - expect_equal(x$children(), list()) + expect_equal(x$num_fields(), 0L) + expect_equal(x$fields(), list()) expect_equal(x$bit_width, 64L) expect_equal(x$unit(), unclass(TimeUnit$NANO)) }) @@ -329,9 +329,9 @@ test_that("list type works as expected", { expect_equal(x$ToString(), "list") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 1L) + expect_equal(x$num_fields(), 1L) expect_equal( - x$children(), + x$fields(), list(field("item", int32())) ) expect_equal(x$value_type, int32()) @@ -345,9 +345,9 @@ test_that("struct type works as expected", { expect_equal(x$ToString(), "struct") expect_true(x == x) expect_false(x == null()) - expect_equal(x$num_children(), 2L) + expect_equal(x$num_fields(), 2L) expect_equal( - x$children(), + x$fields(), list(field("x", int32()), field("y", boolean())) ) expect_equal(x$GetFieldIndex("x"), 0L) From 28982a717b0c8bce9b1454d9081675556db19e8d Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Fri, 30 Oct 2020 10:33:18 +0100 Subject: [PATCH 24/43] lint after rebase --- r/src/compression.cpp | 2 +- r/src/compute.cpp | 6 ++++-- r/src/csv.cpp | 5 ++--- r/src/dataset.cpp | 1 - r/src/io.cpp | 2 +- r/src/json.cpp | 4 ++-- r/src/message.cpp | 3 ++- r/src/parquet.cpp | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/r/src/compression.cpp b/r/src/compression.cpp index c35d05b1425..061240bbcaf 100644 --- a/r/src/compression.cpp +++ b/r/src/compression.cpp @@ -51,7 +51,7 @@ R6 io___CompressedOutputStream__Make( R6 io___CompressedInputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw) { auto stream = ValueOrStop( - arrow::io::CompressedInputStream::Make(codec.get(), raw, gc_memory_pool())); + arrow::io::CompressedInputStream::Make(codec.get(), raw, gc_memory_pool())); return cpp11::r6(stream, "CompressedInputStream"); } diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 28c524b1555..52ca69d59be 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -42,7 +42,8 @@ R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_tr R6 Array__cast(const std::shared_ptr& array, const std::shared_ptr& target_type, const std::shared_ptr& options) { - auto out = ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); + auto out = + ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); return cpp11::r6_Array(out); } @@ -51,7 +52,8 @@ R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, const std::shared_ptr& target_type, const std::shared_ptr& options) { arrow::Datum value(chunked_array); - arrow::Datum out = ValueOrStop(arrow::compute::Cast(value, target_type, *options, gc_context())); + arrow::Datum out = + ValueOrStop(arrow::compute::Cast(value, target_type, *options, gc_context())); return cpp11::r6(out.chunked_array(), "ChunkedArray"); } diff --git a/r/src/csv.cpp b/r/src/csv.cpp index 02845908e83..6c68cb2c93b 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -138,9 +138,8 @@ R6 csv___TableReader__Make( const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options) { - auto reader = ValueOrStop( - arrow::csv::TableReader::Make(gc_memory_pool(), input, *read_options, - *parse_options, *convert_options)); + auto reader = ValueOrStop(arrow::csv::TableReader::Make( + gc_memory_pool(), input, *read_options, *parse_options, *convert_options)); return cpp11::r6(reader, "CsvTableReader"); } diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index ec4d4062a54..bf5bfcf0221 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -78,7 +78,6 @@ R6 r6_FileFormat(const std::shared_ptr& file_format) { // [[arrow::export]] R6 dataset___Dataset__NewScan(const std::shared_ptr& ds) { - auto context = std::make_shared(); context->pool = gc_memory_pool(); auto out = ValueOrStop(ds->NewScan(std::move(context))); diff --git a/r/src/io.cpp b/r/src/io.cpp index c28472eba40..c67627120eb 100644 --- a/r/src/io.cpp +++ b/r/src/io.cpp @@ -147,7 +147,7 @@ R6 io___FileOutputStream__Open(const std::string& path) { // [[arrow::export]] R6 io___BufferOutputStream__Create(int64_t initial_capacity) { auto stream = ValueOrStop( - arrow::io::BufferOutputStream::Create(initial_capacity, gc_memory_pool())); + arrow::io::BufferOutputStream::Create(initial_capacity, gc_memory_pool())); return cpp11::r6(stream, "BufferOutputStream"); } diff --git a/r/src/json.cpp b/r/src/json.cpp index 86e9f8964ef..51c76b5ad47 100644 --- a/r/src/json.cpp +++ b/r/src/json.cpp @@ -42,8 +42,8 @@ R6 json___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options) { - auto reader = ValueOrStop(arrow::json::TableReader::Make(gc_memory_pool(), input, - *read_options, *parse_options)); + auto reader = ValueOrStop(arrow::json::TableReader::Make( + gc_memory_pool(), input, *read_options, *parse_options)); return cpp11::r6(reader, "JsonTableReader"); } diff --git a/r/src/message.cpp b/r/src/message.cpp index 01890fddae3..dd69e7b249b 100644 --- a/r/src/message.cpp +++ b/r/src/message.cpp @@ -81,7 +81,8 @@ R6 ipc___ReadSchema_Message(const std::unique_ptr& message) // [[arrow::export]] R6 ipc___MessageReader__Open(const std::shared_ptr& stream) { - std::shared_ptr reader(arrow::ipc::MessageReader::Open(stream)); + std::shared_ptr reader( + arrow::ipc::MessageReader::Open(stream)); return cpp11::r6(reader, "MessageReader"); } diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index b749c95b4c0..ea33624680e 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -63,7 +63,7 @@ R6 parquet___arrow___FileReader__OpenFile( parquet::arrow::FileReaderBuilder builder; PARQUET_THROW_NOT_OK(builder.Open(file)); PARQUET_THROW_NOT_OK( - builder.memory_pool(gc_memory_pool())->properties(*props)->Build(&reader)); + builder.memory_pool(gc_memory_pool())->properties(*props)->Build(&reader)); return cpp11::r6(std::shared_ptr(std::move(reader)), "ParquetFileReader"); } From 9f731c651fe66e02b2f2b8a09fb7254cc6075f1c Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Mon, 2 Nov 2020 10:43:30 +0100 Subject: [PATCH 25/43] automatic shared_ptr<> -> R6 --- r/NAMESPACE | 2 +- r/R/parquet.R | 22 +-- ...ies.Rd => ParquetArrowReaderProperties.Rd} | 8 +- r/man/ParquetFileReader.Rd | 2 +- r/man/read_parquet.Rd | 4 +- r/src/array.cpp | 60 ++++--- r/src/array_from_vector.cpp | 11 +- r/src/arraydata.cpp | 6 +- r/src/arrowExports.cpp | 2 +- r/src/arrow_cpp11.h | 31 +++- r/src/arrow_types.h | 44 ++++- r/src/buffer.cpp | 19 ++- r/src/chunkedarray.cpp | 18 +-- r/src/compression.cpp | 10 +- r/src/compute.cpp | 30 ++-- r/src/csv.cpp | 33 +++- r/src/dataset.cpp | 151 +++++++++++------- r/src/datatype.cpp | 150 +++++++++-------- r/src/expression.cpp | 35 ++-- r/src/feather.cpp | 11 +- r/src/field.cpp | 8 +- r/src/filesystem.cpp | 54 ++++--- r/src/io.cpp | 44 +++-- r/src/json.cpp | 22 ++- r/src/memorypool.cpp | 3 +- r/src/message.cpp | 29 ++-- r/src/parquet.cpp | 83 ++++++---- r/src/py-to-r.cpp | 4 +- r/src/recordbatch.cpp | 32 ++-- r/src/recordbatchreader.cpp | 35 ++-- r/src/recordbatchwriter.cpp | 12 +- r/src/scalar.cpp | 19 +-- r/src/schema.cpp | 12 +- r/src/table.cpp | 22 +-- r/tests/testthat/test-dataset.R | 6 +- r/tests/testthat/test-read-record-batch.R | 2 +- r/tests/testthat/test-record-batch-reader.R | 4 +- r/tests/testthat/test-schema.R | 2 +- 38 files changed, 600 insertions(+), 442 deletions(-) rename r/man/{ParquetReaderProperties.Rd => ParquetArrowReaderProperties.Rd} (72%) diff --git a/r/NAMESPACE b/r/NAMESPACE index 9bb3e150179..ea611c8b88a 100644 --- a/r/NAMESPACE +++ b/r/NAMESPACE @@ -161,10 +161,10 @@ export(MemoryMappedFile) export(MessageReader) export(MessageType) export(MetadataVersion) +export(ParquetArrowReaderProperties) export(ParquetFileFormat) export(ParquetFileReader) export(ParquetFileWriter) -export(ParquetReaderProperties) export(ParquetVersionType) export(ParquetWriterProperties) export(Partitioning) diff --git a/r/R/parquet.R b/r/R/parquet.R index 1c1fd4ceec2..722d1d27070 100644 --- a/r/R/parquet.R +++ b/r/R/parquet.R @@ -21,7 +21,7 @@ #' This function enables you to read Parquet files into R. #' #' @inheritParams read_feather -#' @param props [ParquetReaderProperties] +#' @param props [ParquetArrowReaderProperties] #' @param ... Additional arguments passed to `ParquetFileReader$create()` #' #' @return A [arrow::Table][Table], or a `data.frame` if `as_data_frame` is @@ -38,7 +38,7 @@ read_parquet <- function(file, col_select = NULL, as_data_frame = TRUE, - props = ParquetReaderProperties$create(), + props = ParquetArrowReaderProperties$create(), ...) { if (is.string(file)) { file <- make_readable_file(file) @@ -425,7 +425,7 @@ ParquetFileWriter$create <- function(schema, #' #' - `file` A character file name, raw vector, or Arrow file connection object #' (e.g. `RandomAccessFile`). -#' - `props` Optional [ParquetReaderProperties] +#' - `props` Optional [ParquetArrowReaderProperties] #' - `mmap` Logical: whether to memory-map the file (default `TRUE`) #' - `...` Additional arguments, currently ignored #' @@ -510,18 +510,18 @@ ParquetFileReader <- R6Class("ParquetFileReader", ) ParquetFileReader$create <- function(file, - props = ParquetReaderProperties$create(), + props = ParquetArrowReaderProperties$create(), mmap = TRUE, ...) { file <- make_readable_file(file, mmap) - assert_is(props, "ParquetReaderProperties") + assert_is(props, "ParquetArrowReaderProperties") parquet___arrow___FileReader__OpenFile(file, props) } -#' @title ParquetReaderProperties class -#' @rdname ParquetReaderProperties -#' @name ParquetReaderProperties +#' @title ParquetArrowReaderProperties class +#' @rdname ParquetArrowReaderProperties +#' @name ParquetArrowReaderProperties #' @docType class #' @usage NULL #' @format NULL @@ -530,7 +530,7 @@ ParquetFileReader$create <- function(file, #' #' @section Factory: #' -#' The `ParquetReaderProperties$create()` factory method instantiates the object +#' The `ParquetArrowReaderProperties$create()` factory method instantiates the object #' and takes the following arguments: #' #' - `use_threads` Logical: whether to use multithreading (default `TRUE`) @@ -542,7 +542,7 @@ ParquetFileReader$create <- function(file, #' - `$use_threads(use_threads)` #' #' @export -ParquetReaderProperties <- R6Class("ParquetReaderProperties", +ParquetArrowReaderProperties <- R6Class("ParquetArrowReaderProperties", inherit = ArrowObject, public = list( read_dictionary = function(column_index) { @@ -563,6 +563,6 @@ ParquetReaderProperties <- R6Class("ParquetReaderProperties", ) ) -ParquetReaderProperties$create <- function(use_threads = option_use_threads()) { +ParquetArrowReaderProperties$create <- function(use_threads = option_use_threads()) { parquet___arrow___ArrowReaderProperties__Make(isTRUE(use_threads)) } diff --git a/r/man/ParquetReaderProperties.Rd b/r/man/ParquetArrowReaderProperties.Rd similarity index 72% rename from r/man/ParquetReaderProperties.Rd rename to r/man/ParquetArrowReaderProperties.Rd index 5cf777039e6..33a50f71266 100644 --- a/r/man/ParquetReaderProperties.Rd +++ b/r/man/ParquetArrowReaderProperties.Rd @@ -1,9 +1,9 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/parquet.R \docType{class} -\name{ParquetReaderProperties} -\alias{ParquetReaderProperties} -\title{ParquetReaderProperties class} +\name{ParquetArrowReaderProperties} +\alias{ParquetArrowReaderProperties} +\title{ParquetArrowReaderProperties class} \description{ This class holds settings to control how a Parquet file is read by \link{ParquetFileReader}. @@ -11,7 +11,7 @@ by \link{ParquetFileReader}. \section{Factory}{ -The \code{ParquetReaderProperties$create()} factory method instantiates the object +The \code{ParquetArrowReaderProperties$create()} factory method instantiates the object and takes the following arguments: \itemize{ \item \code{use_threads} Logical: whether to use multithreading (default \code{TRUE}) diff --git a/r/man/ParquetFileReader.Rd b/r/man/ParquetFileReader.Rd index 828ba696e28..13682a7ee35 100644 --- a/r/man/ParquetFileReader.Rd +++ b/r/man/ParquetFileReader.Rd @@ -15,7 +15,7 @@ takes the following arguments: \itemize{ \item \code{file} A character file name, raw vector, or Arrow file connection object (e.g. \code{RandomAccessFile}). -\item \code{props} Optional \link{ParquetReaderProperties} +\item \code{props} Optional \link{ParquetArrowReaderProperties} \item \code{mmap} Logical: whether to memory-map the file (default \code{TRUE}) \item \code{...} Additional arguments, currently ignored } diff --git a/r/man/read_parquet.Rd b/r/man/read_parquet.Rd index ec36734e599..4e9b526b369 100644 --- a/r/man/read_parquet.Rd +++ b/r/man/read_parquet.Rd @@ -8,7 +8,7 @@ read_parquet( file, col_select = NULL, as_data_frame = TRUE, - props = ParquetReaderProperties$create(), + props = ParquetArrowReaderProperties$create(), ... ) } @@ -27,7 +27,7 @@ of columns, as used in \code{dplyr::select()}.} \item{as_data_frame}{Should the function return a \code{data.frame} (default) or an Arrow \link{Table}?} -\item{props}{\link{ParquetReaderProperties}} +\item{props}{\link{ParquetArrowReaderProperties}} \item{...}{Additional arguments passed to \code{ParquetFileReader$create()}} } diff --git a/r/src/array.cpp b/r/src/array.cpp index f88be176f57..3ca0184fdec 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -23,28 +23,26 @@ #include namespace cpp11 { -R6 r6_Array(const std::shared_ptr& array) { - if (array == nullptr) return R_NilValue; - - using arrow::Type; +template <> std::string r6_class_name(const std::shared_ptr& array) { auto type = array->type_id(); switch (type) { - case Type::DICTIONARY: - return cpp11::r6(array, "DictionaryArray"); - case Type::STRUCT: - return cpp11::r6(array, "StructArray"); - case Type::LIST: - return cpp11::r6(array, "ListArray"); - case Type::LARGE_LIST: - return cpp11::r6(array, "LargeListArray"); - case Type::FIXED_SIZE_LIST: - return cpp11::r6(array, "FixedSizeListArray"); - - default: - return cpp11::r6(array, "Array"); + case arrow::Type::DICTIONARY: + return "DictionaryArray"; + case arrow::Type::STRUCT: + return "StructArray"; + case arrow::Type::LIST: + return "ListArray"; + case arrow::Type::LARGE_LIST: + return "LargeListArray"; + case arrow::Type::FIXED_SIZE_LIST: + return "FixedSizeListArray"; + + default: + return "Array"; } } + } // namespace cpp11 void arrow::r::validate_slice_offset(R_xlen_t offset, int64_t len) { @@ -74,7 +72,7 @@ void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) { // [[arrow::export]] R6 Array__Slice1(const std::shared_ptr& array, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, array->length()); - return cpp11::r6_Array(array->Slice(offset)); + return array->Slice(offset); } // [[arrow::export]] @@ -82,7 +80,7 @@ R6 Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, array->length()); arrow::r::validate_slice_length(length, array->length() - offset); - return cpp11::r6_Array(array->Slice(offset, length)); + return array->Slice(offset, length); } void arrow::r::validate_index(int i, int len) { @@ -117,7 +115,7 @@ int Array__null_count(const std::shared_ptr& x) { return x->null_c // [[arrow::export]] R6 Array__type(const std::shared_ptr& x) { - return cpp11::r6_DataType(x->type()); + return x->type(); } // [[arrow::export]] @@ -144,7 +142,7 @@ bool Array__ApproxEquals(const std::shared_ptr& lhs, // [[arrow::export]] R6 Array__data(const std::shared_ptr& array) { - return cpp11::r6(array->data(), "ArrayData"); + return array->data(); } // [[arrow::export]] @@ -166,7 +164,7 @@ bool Array__RangeEquals(const std::shared_ptr& self, // [[arrow::export]] R6 Array__View(const std::shared_ptr& array, const std::shared_ptr& type) { - return cpp11::r6_Array(ValueOrStop(array->View(type))); + return ValueOrStop(array->View(type)); } // [[arrow::export]] @@ -176,48 +174,48 @@ void Array__Validate(const std::shared_ptr& array) { // [[arrow::export]] R6 DictionaryArray__indices(const std::shared_ptr& array) { - return cpp11::r6_Array(array->indices()); + return array->indices(); } // [[arrow::export]] R6 DictionaryArray__dictionary(const std::shared_ptr& array) { - return cpp11::r6_Array(array->dictionary()); + return array->dictionary(); } // [[arrow::export]] R6 StructArray__field(const std::shared_ptr& array, int i) { - return cpp11::r6_Array(array->field(i)); + return array->field(i); } // [[arrow::export]] R6 StructArray__GetFieldByName(const std::shared_ptr& array, const std::string& name) { - return cpp11::r6_Array(array->GetFieldByName(name)); + return array->GetFieldByName(name); } // [[arrow::export]] cpp11::list StructArray__Flatten(const std::shared_ptr& array) { - return arrow::r::to_r_list(ValueOrStop(array->Flatten()), cpp11::r6_Array); + return arrow::r::to_r_list(ValueOrStop(array->Flatten()), cpp11::to_r6); } // [[arrow::export]] R6 ListArray__value_type(const std::shared_ptr& array) { - return cpp11::r6_DataType(array->value_type()); + return array->value_type(); } // [[arrow::export]] R6 LargeListArray__value_type(const std::shared_ptr& array) { - return cpp11::r6_DataType(array->value_type()); + return array->value_type(); } // [[arrow::export]] R6 ListArray__values(const std::shared_ptr& array) { - return cpp11::r6_Array(array->values()); + return array->values(); } // [[arrow::export]] R6 LargeListArray__values(const std::shared_ptr& array) { - return cpp11::r6_Array(array->values()); + return array->values(); } // [[arrow::export]] diff --git a/r/src/array_from_vector.cpp b/r/src/array_from_vector.cpp index fcb2ed29974..6523d102a12 100644 --- a/r/src/array_from_vector.cpp +++ b/r/src/array_from_vector.cpp @@ -1528,7 +1528,7 @@ std::shared_ptr Array__from_vector( } // namespace arrow // [[arrow::export]] -R6 Array__infer_type(SEXP x) { return cpp11::r6_DataType(arrow::r::InferArrowType(x)); } +R6 Array__infer_type(SEXP x) { return arrow::r::InferArrowType(x); } // [[arrow::export]] R6 Array__from_vector(SEXP x, SEXP s_type) { @@ -1542,8 +1542,7 @@ R6 Array__from_vector(SEXP x, SEXP s_type) { type = cpp11::as_cpp>(s_type); } - auto array = arrow::r::Array__from_vector(x, type, type_inferred); - return cpp11::r6_Array(array); + return arrow::r::Array__from_vector(x, type, type_inferred); } // [[arrow::export]] @@ -1583,16 +1582,14 @@ R6 ChunkedArray__from_list(cpp11::list chunks, SEXP s_type) { } } - auto array = std::make_shared(std::move(vec)); - return cpp11::r6(array, "ChunkedArray"); + return std::make_shared(std::move(vec)); } // [[arrow::export]] R6 DictionaryArray__FromArrays(const std::shared_ptr& type, const std::shared_ptr& indices, const std::shared_ptr& dict) { - auto array = ValueOrStop(arrow::DictionaryArray::FromArrays(type, indices, dict)); - return cpp11::r6(array, "DictionaryArray"); + return ValueOrStop(arrow::DictionaryArray::FromArrays(type, indices, dict)); } #endif diff --git a/r/src/arraydata.cpp b/r/src/arraydata.cpp index d2ecf28541c..0e3c2892f87 100644 --- a/r/src/arraydata.cpp +++ b/r/src/arraydata.cpp @@ -22,7 +22,7 @@ // [[arrow::export]] R6 ArrayData__get_type(const std::shared_ptr& x) { - return cpp11::r6_DataType(x->type); + return x->type; } // [[arrow::export]] @@ -42,9 +42,7 @@ int ArrayData__get_offset(const std::shared_ptr& x) { // [[arrow::export]] cpp11::list ArrayData__buffers(const std::shared_ptr& x) { - return arrow::r::to_r_list(x->buffers, [](const std::shared_ptr& buf) { - return cpp11::r6(buf, "Buffer"); - }); + return arrow::r::to_r_list(x->buffers, cpp11::to_r6); } #endif diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index d188536f4bc..bc36001cea7 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -5494,7 +5494,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__ReadRecordBatch(SEXP reader_ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -SEXP ipc___RecordBatchFileReader__Open(const std::shared_ptr& file); +R6 ipc___RecordBatchFileReader__Open(const std::shared_ptr& file); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__Open(SEXP file_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file(file_sexp); diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index a3c04b7e320..10d0e607d58 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -24,8 +24,6 @@ #include "./nameof.h" -using R6 = SEXP; - // TODO: move this include up once we can resolve this issue in cpp11 // https://github.com/apache/arrow/pull/7819#discussion_r471664878 #include @@ -296,8 +294,13 @@ bool GetBoolOption(const std::string& name, bool default_); namespace cpp11 { template -R6 r6(const std::shared_ptr& x, const std::string& r_class_name) { +std::string r6_class_name(const std::shared_ptr& x) ; + +template +SEXP to_r6(const std::shared_ptr& x) { if (x == nullptr) return R_NilValue; + + auto r_class_name = cpp11::r6_class_name(x); cpp11::external_pointer> xp(new std::shared_ptr(x)); SEXP r6_class = Rf_install(r_class_name.c_str()); @@ -311,6 +314,28 @@ R6 r6(const std::shared_ptr& x, const std::string& r_class_name) { UNPROTECT(3); return r6; } +} + +class R6 { +public: + + template + R6(const std::shared_ptr& x) : data_(cpp11::to_r6(x)){} + + template + R6(std::unique_ptr x) : data_(cpp11::to_r6(std::shared_ptr(x.release()))){} + + R6(SEXP data) : data_(data){} + + operator SEXP() const { + return data_; + } + +private: + SEXP data_; +}; + +namespace cpp11 { template using enable_if_shared_ptr = typename std::enable_if< diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index 7c9a24afcee..5072a763730 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -122,13 +122,43 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, namespace cpp11 { -R6 r6_Array(const std::shared_ptr& array); -R6 r6_DataType(const std::shared_ptr& type); -R6 r6_Field(const std::shared_ptr& field); -R6 r6_ChunkedArray(const std::shared_ptr& array); -R6 r6_RecordBatch(const std::shared_ptr& batch); -R6 r6_Scalar(const std::shared_ptr& ptr); -R6 r6_FileSystem(const std::shared_ptr& file_system); +template <> std::string r6_class_name(const std::shared_ptr& array); +template <> std::string r6_class_name(const std::shared_ptr& type); +template <> std::string r6_class_name(const std::shared_ptr& ptr); + +template <> inline std::string r6_class_name(const std::shared_ptr& array_data) { + return "Field"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& array_data) { + return "ArrayData"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& array) { + return "ChunkedArray"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& array) { + return "Buffer"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "Codec"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CompressedOutputStream"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CompressedInputStream"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "RecordBatch"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "Table"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "Schema"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "MemoryPool"; +} } // namespace cpp11 diff --git a/r/src/buffer.cpp b/r/src/buffer.cpp index 5d596d3efb5..3182c9a7357 100644 --- a/r/src/buffer.cpp +++ b/r/src/buffer.cpp @@ -41,21 +41,24 @@ int64_t Buffer__size(const std::shared_ptr& buffer) { // [[arrow::export]] R6 r___RBuffer__initialize(SEXP x) { + std::shared_ptr out; switch (TYPEOF(x)) { case RAWSXP: - return cpp11::r6(std::make_shared>(x), "Buffer"); + out = std::make_shared>(x); + break; case REALSXP: - return cpp11::r6(std::make_shared>(x), "Buffer"); + out = std::make_shared>(x); + break; case INTSXP: - return cpp11::r6(std::make_shared>(x), "Buffer"); + out = std::make_shared>(x); + break; case CPLXSXP: - return cpp11::r6( - std::make_shared>(arrow::r::complexs(x)), - "Buffer"); - default: + out = std::make_shared>(arrow::r::complexs(x)); break; + default: + cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x))); } - cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x))); + return out; } // [[arrow::export]] diff --git a/r/src/chunkedarray.cpp b/r/src/chunkedarray.cpp index afb9d7ec6b8..0763475e8f6 100644 --- a/r/src/chunkedarray.cpp +++ b/r/src/chunkedarray.cpp @@ -21,12 +21,6 @@ #include -namespace cpp11 { -R6 r6_ChunkedArray(const std::shared_ptr& array) { - return r6(array, "ChunkedArray"); -} -} // namespace cpp11 - // [[arrow::export]] int ChunkedArray__length(const std::shared_ptr& chunked_array) { return chunked_array->length(); @@ -45,25 +39,25 @@ int ChunkedArray__num_chunks(const std::shared_ptr& chunked // [[arrow::export]] R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i) { arrow::r::validate_index(i, chunked_array->num_chunks()); - return cpp11::r6_Array(chunked_array->chunk(i)); + return chunked_array->chunk(i); } // [[arrow::export]] cpp11::list ChunkedArray__chunks( const std::shared_ptr& chunked_array) { - return arrow::r::to_r_list(chunked_array->chunks(), cpp11::r6_Array); + return arrow::r::to_r_list(chunked_array->chunks(), cpp11::to_r6); } // [[arrow::export]] R6 ChunkedArray__type(const std::shared_ptr& chunked_array) { - return cpp11::r6_DataType(chunked_array->type()); + return chunked_array->type(); } // [[arrow::export]] R6 ChunkedArray__Slice1(const std::shared_ptr& chunked_array, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, chunked_array->length()); - return cpp11::r6(chunked_array->Slice(offset), "ChunkedArray"); + return chunked_array->Slice(offset); } // [[arrow::export]] @@ -71,13 +65,13 @@ R6 ChunkedArray__Slice2(const std::shared_ptr& chunked_arra R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, chunked_array->length()); arrow::r::validate_slice_length(length, chunked_array->length() - offset); - return cpp11::r6(chunked_array->Slice(offset, length), "ChunkedArray"); + return chunked_array->Slice(offset, length); } // [[arrow::export]] R6 ChunkedArray__View(const std::shared_ptr& array, const std::shared_ptr& type) { - return cpp11::r6(ValueOrStop(array->View(type)), "ChunkedArray"); + return ValueOrStop(array->View(type)); } // [[arrow::export]] diff --git a/r/src/compression.cpp b/r/src/compression.cpp index 061240bbcaf..856eeedb274 100644 --- a/r/src/compression.cpp +++ b/r/src/compression.cpp @@ -23,9 +23,7 @@ // [[arrow::export]] R6 util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level) { - std::shared_ptr out = - ValueOrStop(arrow::util::Codec::Create(codec, compression_level)); - return cpp11::r6(out, "Codec"); + return ValueOrStop(arrow::util::Codec::Create(codec, compression_level)); } // [[arrow::export]] @@ -42,17 +40,15 @@ bool util___Codec__IsAvailable(arrow::Compression::type codec) { R6 io___CompressedOutputStream__Make( const std::shared_ptr& codec, const std::shared_ptr& raw) { - auto stream = ValueOrStop( + return ValueOrStop( arrow::io::CompressedOutputStream::Make(codec.get(), raw, gc_memory_pool())); - return cpp11::r6(stream, "CompressedOutputStream"); } // [[arrow::export]] R6 io___CompressedInputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw) { - auto stream = ValueOrStop( + return ValueOrStop( arrow::io::CompressedInputStream::Make(codec.get(), raw, gc_memory_pool())); - return cpp11::r6(stream, "CompressedInputStream"); } #endif diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 52ca69d59be..ee0c0f324d6 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -23,6 +23,12 @@ #include #include +namespace cpp11 { +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CastOptions"; +} +} + arrow::compute::ExecContext* gc_context() { static arrow::compute::ExecContext context(gc_memory_pool()); return &context; @@ -35,16 +41,14 @@ R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_tr options->allow_int_overflow = allow_int_overflow; options->allow_time_truncate = allow_time_truncate; options->allow_float_truncate = allow_float_truncate; - return cpp11::r6(options, "CastOptions"); + return options; } // [[arrow::export]] R6 Array__cast(const std::shared_ptr& array, const std::shared_ptr& target_type, const std::shared_ptr& options) { - auto out = - ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); - return cpp11::r6_Array(out); + return ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); } // [[arrow::export]] @@ -54,7 +58,7 @@ R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, arrow::Datum value(chunked_array); arrow::Datum out = ValueOrStop(arrow::compute::Cast(value, target_type, *options, gc_context())); - return cpp11::r6(out.chunked_array(), "ChunkedArray"); + return out.chunked_array(); } // [[arrow::export]] @@ -69,8 +73,7 @@ R6 RecordBatch__cast(const std::shared_ptr& batch, arrow::compute::Cast(*batch->column(i), schema->field(i)->type(), *options)); } - auto out = arrow::RecordBatch::Make(schema, batch->num_rows(), std::move(columns)); - return cpp11::r6(out, "RecordBatch"); + return arrow::RecordBatch::Make(schema, batch->num_rows(), std::move(columns)); } // [[arrow::export]] @@ -87,8 +90,7 @@ R6 Table__cast(const std::shared_ptr& table, ValueOrStop(arrow::compute::Cast(value, schema->field(i)->type(), *options)); columns[i] = out.chunked_array(); } - auto out = arrow::Table::Make(schema, std::move(columns), table->num_rows()); - return cpp11::r6(out, "Table"); + return arrow::Table::Make(schema, std::move(columns), table->num_rows()); } template @@ -133,19 +135,19 @@ arrow::Datum as_cpp(SEXP x) { SEXP from_datum(arrow::Datum datum) { switch (datum.kind()) { case arrow::Datum::SCALAR: - return cpp11::r6_Scalar(datum.scalar()); + return R6(datum.scalar()); case arrow::Datum::ARRAY: - return cpp11::r6_Array(datum.make_array()); + return R6(datum.make_array()); case arrow::Datum::CHUNKED_ARRAY: - return cpp11::r6(datum.chunked_array(), "ChunkedArray"); + return R6(datum.chunked_array()); case arrow::Datum::RECORD_BATCH: - return cpp11::r6(datum.record_batch(), "RecordBatch"); + return R6(datum.record_batch()); case arrow::Datum::TABLE: - return cpp11::r6(datum.table(), "Table"); + return R6(datum.table()); default: break; diff --git a/r/src/csv.cpp b/r/src/csv.cpp index 6c68cb2c93b..3aebaa032df 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -22,6 +22,24 @@ #include #include +namespace cpp11 { +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CsvReadOptions"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CsvParseOptions"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CsvConvertOptions"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "CsvTableReader"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "TimestampParser"; +} +} + // [[arrow::export]] R6 csv___ReadOptions__initialize(cpp11::list options) { auto res = @@ -33,7 +51,7 @@ R6 csv___ReadOptions__initialize(cpp11::list options) { res->autogenerate_column_names = cpp11::as_cpp(options["autogenerate_column_names"]); - return cpp11::r6(res, "CsvReadOptions"); + return res; } // [[arrow::export]] @@ -47,7 +65,7 @@ R6 csv___ParseOptions__initialize(cpp11::list options) { res->escape_char = cpp11::as_cpp(options["escape_char"]); res->newlines_in_values = cpp11::as_cpp(options["newlines_in_values"]); res->ignore_empty_lines = cpp11::as_cpp(options["ignore_empty_lines"]); - return cpp11::r6(res, "CsvParseOptions"); + return res; } // [[arrow::export]] @@ -129,7 +147,7 @@ R6 csv___ConvertOptions__initialize(cpp11::list options) { res->timestamp_parsers = timestamp_parsers; } - return cpp11::r6(res, "CsvConvertOptions"); + return res; } // [[arrow::export]] @@ -138,14 +156,13 @@ R6 csv___TableReader__Make( const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options) { - auto reader = ValueOrStop(arrow::csv::TableReader::Make( + return ValueOrStop(arrow::csv::TableReader::Make( gc_memory_pool(), input, *read_options, *parse_options, *convert_options)); - return cpp11::r6(reader, "CsvTableReader"); } // [[arrow::export]] R6 csv___TableReader__Read(const std::shared_ptr& table_reader) { - return cpp11::r6(ValueOrStop(table_reader->Read()), "Table"); + return ValueOrStop(table_reader->Read()); } // [[arrow::export]] @@ -161,12 +178,12 @@ std::string TimestampParser__format( // [[arrow::export]] R6 TimestampParser__MakeStrptime(std::string format) { - return cpp11::r6(arrow::TimestampParser::MakeStrptime(format), "TimestampParser"); + return arrow::TimestampParser::MakeStrptime(format); } // [[arrow::export]] R6 TimestampParser__MakeISO8601() { - return cpp11::r6(arrow::TimestampParser::MakeISO8601(), "TimestampParser"); + return arrow::TimestampParser::MakeISO8601(); } #endif diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index bf5bfcf0221..69a1470cfb2 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -30,47 +30,93 @@ namespace fs = ::arrow::fs; namespace cpp11 { -R6 r6_Dataset(const std::shared_ptr& dataset) { - if (dataset == nullptr) return R_NilValue; +template <> std::string r6_class_name(const std::shared_ptr& dataset) { auto type_name = dataset->type_name(); if (type_name == "union") { - return cpp11::r6(dataset, "UnionDataset"); + return "UnionDataset"; } else if (type_name == "filesystem") { - return cpp11::r6(dataset, "FileSystemDataset"); + return "FileSystemDataset"; + } else if(type_name == "in-memory"){ + return "InMemoryDataset"; } else { - return cpp11::r6(dataset, "Dataset"); + return "Dataset"; } } +template <> std::string r6_class_name(const std::shared_ptr& dataset) { + return "UnionDataset"; +} +template <> std::string r6_class_name(const std::shared_ptr& dataset) { + return "InMemoryDataset"; +} +template <> std::string r6_class_name(const std::shared_ptr& dataset) { + return "FileSystemDataset"; +} -R6 r6_FileSystem(const std::shared_ptr& file_system) { - if (file_system == nullptr) return R_NilValue; + +template <> std::string r6_class_name(const std::shared_ptr& file_system) { auto type_name = file_system->type_name(); if (type_name == "local") { - return cpp11::r6(file_system, "LocalFileSystem"); + return "LocalFileSystem"; } else if (type_name == "s3") { - return cpp11::r6(file_system, "S3FileSystem"); + return "S3FileSystem"; } else if (type_name == "subtree") { - return cpp11::r6(file_system, "SubTreeFileSystem"); + return "SubTreeFileSystem"; } else { - return cpp11::r6(file_system, "FileSystem"); + return "FileSystem"; } } -R6 r6_FileFormat(const std::shared_ptr& file_format) { - if (file_format == nullptr) return R_NilValue; +template <> std::string r6_class_name(const std::shared_ptr& file_format) { auto type_name = file_format->type_name(); if (type_name == "parquet") { - return cpp11::r6(file_format, "ParquetFileFormat"); + return "ParquetFileFormat"; } else if (type_name == "ipc") { - return cpp11::r6(file_format, "IpcFileFormat"); + return "IpcFileFormat"; } else if (type_name == "csv") { - return cpp11::r6(file_format, "CsvFileFormat"); + return "CsvFileFormat"; } else { - return cpp11::r6(file_format, "FileFormat"); + return "FileFormat"; } } +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ScannerBuilder"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "DatasetFactory"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "FileSystemDatasetFactory"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "PartitioningFactory"; +} + +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetFileFormat"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "IpcFileFormat"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "CsvFileFormat"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "DirectoryPartitioning"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "HivePartitioning"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "Scanner"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ScanTask"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "FileWriteOptions"; +} } // namespace cpp11 @@ -80,13 +126,12 @@ R6 r6_FileFormat(const std::shared_ptr& file_format) { R6 dataset___Dataset__NewScan(const std::shared_ptr& ds) { auto context = std::make_shared(); context->pool = gc_memory_pool(); - auto out = ValueOrStop(ds->NewScan(std::move(context))); - return cpp11::r6(std::shared_ptr(std::move(out)), "ScannerBuilder"); + return ValueOrStop(ds->NewScan(std::move(context))); } // [[arrow::export]] R6 dataset___Dataset__schema(const std::shared_ptr& dataset) { - return cpp11::r6(dataset->schema(), "Schema"); + return dataset->schema(); } // [[arrow::export]] @@ -97,36 +142,36 @@ std::string dataset___Dataset__type_name(const std::shared_ptr& dat // [[arrow::export]] R6 dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, const std::shared_ptr& schm) { - return cpp11::r6_Dataset(ValueOrStop(dataset->ReplaceSchema(schm))); + return ValueOrStop(dataset->ReplaceSchema(schm)); } // [[arrow::export]] R6 dataset___UnionDataset__create(const ds::DatasetVector& datasets, const std::shared_ptr& schm) { - return cpp11::r6(ValueOrStop(ds::UnionDataset::Make(schm, datasets)), "UnionDataset"); + return ValueOrStop(ds::UnionDataset::Make(schm, datasets)); } // [[arrow::export]] R6 dataset___InMemoryDataset__create(const std::shared_ptr& table) { - return cpp11::r6(std::make_shared(table), "InMemoryDataset"); + return std::make_shared(table); } // [[arrow::export]] cpp11::list dataset___UnionDataset__children( const std::shared_ptr& ds) { - return arrow::r::to_r_list(ds->children(), cpp11::r6_Dataset); + return arrow::r::to_r_list(ds->children(), cpp11::to_r6); } // [[arrow::export]] R6 dataset___FileSystemDataset__format( const std::shared_ptr& dataset) { - return cpp11::r6_FileFormat(dataset->format()); + return dataset->format(); } // [[arrow::export]] R6 dataset___FileSystemDataset__filesystem( const std::shared_ptr& dataset) { - return cpp11::r6_FileSystem(dataset->filesystem()); + return dataset->filesystem(); } // [[arrow::export]] @@ -144,13 +189,13 @@ R6 dataset___DatasetFactory__Finish1(const std::shared_ptr& if (unify_schemas) { opts.inspect_options.fragments = ds::InspectOptions::kInspectAllFragments; } - return cpp11::r6_Dataset(ValueOrStop(factory->Finish(opts))); + return ValueOrStop(factory->Finish(opts)); } // [[arrow::export]] R6 dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, const std::shared_ptr& schema) { - return cpp11::r6_Dataset(ValueOrStop(factory->Finish(schema))); + return ValueOrStop(factory->Finish(schema)); } // [[arrow::export]] @@ -160,14 +205,13 @@ R6 dataset___DatasetFactory__Inspect(const std::shared_ptr& if (unify_schemas) { opts.fragments = ds::InspectOptions::kInspectAllFragments; } - return cpp11::r6(ValueOrStop(factory->Inspect(opts)), "Schema"); + return ValueOrStop(factory->Inspect(opts)); } // [[arrow::export]] R6 dataset___UnionDatasetFactory__Make( const std::vector>& children) { - return cpp11::r6(ValueOrStop(ds::UnionDatasetFactory::Make(children)), - "DatasetFactory"); + return ValueOrStop(ds::UnionDatasetFactory::Make(children)); } // [[arrow::export]] @@ -182,9 +226,7 @@ R6 dataset___FileSystemDatasetFactory__Make2( options.partitioning = partitioning; } - auto factory = - ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); - return cpp11::r6(factory, "FileSystemDatasetFactory"); + return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); } // [[arrow::export]] @@ -207,9 +249,7 @@ R6 dataset___FileSystemDatasetFactory__Make3( options.partitioning = factory; } - auto ptr = - ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); - return cpp11::r6(ptr, "FileSystemDatasetFactory"); + return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); } // FileFormat, ParquetFileFormat, IpcFileFormat @@ -222,7 +262,7 @@ std::string dataset___FileFormat__type_name( // [[arrow::export]] R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt) { - return cpp11::r6(fmt->DefaultWriteOptions(), "FileWriteOptions"); + return fmt->DefaultWriteOptions(); } // [[arrow::export]] @@ -238,7 +278,7 @@ R6 dataset___ParquetFileFormat__Make(bool use_buffered_stream, int64_t buffer_si std::move(dict_columns_vector.begin(), dict_columns_vector.end(), std::inserter(d, d.end())); - return cpp11::r6(fmt, "ParquetFileFormat"); + return fmt; } // [[arrow::export]] @@ -276,7 +316,7 @@ void dataset___IpcFileWriteOptions__update1( // [[arrow::export]] R6 dataset___IpcFileFormat__Make() { - return cpp11::r6(std::make_shared(), "IpcFileFormat"); + return std::make_shared(); } // [[arrow::export]] @@ -284,32 +324,30 @@ R6 dataset___CsvFileFormat__Make( const std::shared_ptr& parse_options) { auto format = std::make_shared(); format->parse_options = *parse_options; - return cpp11::r6(format, "CsvFileFormat"); + return format; } // DirectoryPartitioning, HivePartitioning // [[arrow::export]] R6 dataset___DirectoryPartitioning(const std::shared_ptr& schm) { - return cpp11::r6(std::make_shared(schm), - "DirectoryPartitioning"); + return std::make_shared(schm); } // [[arrow::export]] R6 dataset___DirectoryPartitioning__MakeFactory( const std::vector& field_names) { - return cpp11::r6(ds::DirectoryPartitioning::MakeFactory(field_names), - "DirectoryPartitioningFactory"); + return ds::DirectoryPartitioning::MakeFactory(field_names); } // [[arrow::export]] R6 dataset___HivePartitioning(const std::shared_ptr& schm) { - return cpp11::r6(std::make_shared(schm), "HivePartitioning"); + return std::make_shared(schm); } // [[arrow::export]] R6 dataset___HivePartitioning__MakeFactory() { - return cpp11::r6(ds::HivePartitioning::MakeFactory(), "HivePartitioningFactory"); + return ds::HivePartitioning::MakeFactory(); } // ScannerBuilder, Scanner @@ -343,19 +381,17 @@ void dataset___ScannerBuilder__BatchSize(const std::shared_ptr& sb) { - return cpp11::r6(sb->schema(), "Schema"); + return sb->schema(); } // [[arrow::export]] R6 dataset___ScannerBuilder__Finish(const std::shared_ptr& sb) { - auto out = ValueOrStop(sb->Finish()); - - return cpp11::r6(std::shared_ptr(std::move(out)), "Scanner"); + return ValueOrStop(sb->Finish()); } // [[arrow::export]] R6 dataset___Scanner__ToTable(const std::shared_ptr& scanner) { - return cpp11::r6(ValueOrStop(scanner->ToTable()), "Table"); + return ValueOrStop(scanner->ToTable()); } // [[arrow::export]] @@ -373,8 +409,7 @@ R6 dataset___Scanner__head(const std::shared_ptr& scanner, int n) { } if (n < 0) break; } - auto out = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); - return cpp11::r6(out, "Table"); + return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); } // [[arrow::export]] @@ -388,14 +423,12 @@ cpp11::list dataset___Scanner__Scan(const std::shared_ptr& scanner) out.push_back(scan_task); } - return arrow::r::to_r_list(out, [](const std::shared_ptr& task) { - return cpp11::r6(task, "ScanTask"); - }); + return arrow::r::to_r_list(out, cpp11::to_r6); } // [[arrow::export]] R6 dataset___Scanner__schema(const std::shared_ptr& sc) { - return cpp11::r6(sc->schema(), "Schema"); + return sc->schema(); } // [[arrow::export]] @@ -409,7 +442,7 @@ cpp11::list dataset___ScanTask__get_batches( batch = ValueOrStop(b); out.push_back(batch); } - return arrow::r::to_r_list(out, cpp11::r6_RecordBatch); + return arrow::r::to_r_list(out, cpp11::to_r6); } // [[arrow::export]] diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index 13629428cf5..157b3da3187 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -21,85 +21,83 @@ #include namespace cpp11 { -R6 r6_DataType(const std::shared_ptr& type) { - if (type == nullptr) return R_NilValue; - +template <> std::string r6_class_name(const std::shared_ptr& type) { using arrow::Type; switch (type->id()) { case Type::NA: - return r6(type, "Null"); + return "Null"; case Type::BOOL: - return r6(type, "Boolean"); + return "Boolean"; case Type::UINT8: - return r6(type, "UInt8"); + return "UInt8"; case Type::UINT16: - return r6(type, "UInt16"); + return "UInt16"; case Type::UINT32: - return r6(type, "UInt32"); + return "UInt32"; case Type::UINT64: - return r6(type, "UInt64"); + return "UInt64"; case Type::INT8: - return r6(type, "Int8"); + return "Int8"; case Type::INT16: - return r6(type, "Int16"); + return "Int16"; case Type::INT32: - return r6(type, "Int32"); + return "Int32"; case Type::INT64: - return r6(type, "Int64"); + return "Int64"; case Type::HALF_FLOAT: - return r6(type, "Float16"); + return "Float16"; case Type::FLOAT: - return r6(type, "Float32"); + return "Float32"; case Type::DOUBLE: - return r6(type, "Float64"); + return "Float64"; case Type::STRING: - return r6(type, "Utf8"); + return "Utf8"; case Type::LARGE_STRING: - return r6(type, "LargeUtf8"); + return "LargeUtf8"; case Type::BINARY: - return r6(type, "Binary"); + return "Binary"; case Type::FIXED_SIZE_BINARY: - return r6(type, "FixedSizeBinary"); + return "FixedSizeBinary"; case Type::LARGE_BINARY: - return r6(type, "LargeBinary"); + return "LargeBinary"; case Type::DATE32: - return r6(type, "Date32"); + return "Date32"; case Type::DATE64: - return r6(type, "Date64"); + return "Date64"; case Type::TIMESTAMP: - return r6(type, "Timestamp"); + return "Timestamp"; case Type::TIME32: - return r6(type, "Time32"); + return "Time32"; case Type::TIME64: - return r6(type, "Time64"); + return "Time64"; case Type::DECIMAL: - return r6(type, "Decimal128Type"); + return "Decimal128Type"; case Type::LIST: - return r6(type, "ListType"); + return "ListType"; case Type::LARGE_LIST: - return r6(type, "LargeListType"); + return "LargeListType"; case Type::FIXED_SIZE_LIST: - return r6(type, "FixedSizeListType"); + return "FixedSizeListType"; case Type::STRUCT: - return r6(type, "StructType"); + return "StructType"; case Type::DICTIONARY: - return r6(type, "DictionaryType"); + return "DictionaryType"; default: break; } - return r6(type, "DataType"); + return "DataType"; // switch(names(Type)[self$id + 1], // @@ -114,67 +112,66 @@ R6 r6_DataType(const std::shared_ptr& type) { } // namespace cpp11 // [[arrow::export]] -R6 Int8__initialize() { return cpp11::r6(arrow::int8(), "Int8"); } +R6 Int8__initialize() { return arrow::int8(); } // [[arrow::export]] -R6 Int16__initialize() { return cpp11::r6(arrow::int16(), "Int16"); } +R6 Int16__initialize() { return arrow::int16(); } // [[arrow::export]] -R6 Int32__initialize() { return cpp11::r6(arrow::int32(), "Int32"); } +R6 Int32__initialize() { return arrow::int32(); } // [[arrow::export]] -R6 Int64__initialize() { return cpp11::r6(arrow::int64(), "Int64"); } +R6 Int64__initialize() { return arrow::int64(); } // [[arrow::export]] -R6 UInt8__initialize() { return cpp11::r6(arrow::uint8(), "UInt8"); } +R6 UInt8__initialize() { return arrow::uint8(); } // [[arrow::export]] -R6 UInt16__initialize() { return cpp11::r6(arrow::uint16(), "UInt16"); } +R6 UInt16__initialize() { return arrow::uint16(); } // [[arrow::export]] -R6 UInt32__initialize() { return cpp11::r6(arrow::uint32(), "UInt32"); } +R6 UInt32__initialize() { return arrow::uint32(); } // [[arrow::export]] -R6 UInt64__initialize() { return cpp11::r6(arrow::uint64(), "UInt64"); } +R6 UInt64__initialize() { return arrow::uint64(); } // [[arrow::export]] -R6 Float16__initialize() { return cpp11::r6(arrow::float16(), "Float16"); } +R6 Float16__initialize() { return arrow::float16(); } // [[arrow::export]] -R6 Float32__initialize() { return cpp11::r6(arrow::float32(), "Float32"); } +R6 Float32__initialize() { return arrow::float32(); } // [[arrow::export]] -R6 Float64__initialize() { return cpp11::r6(arrow::float64(), "Float64"); } +R6 Float64__initialize() { return arrow::float64(); } // [[arrow::export]] -R6 Boolean__initialize() { return cpp11::r6(arrow::boolean(), "Boolean"); } +R6 Boolean__initialize() { return arrow::boolean(); } // [[arrow::export]] -R6 Utf8__initialize() { return cpp11::r6(arrow::utf8(), "Utf8"); } +R6 Utf8__initialize() { return arrow::utf8(); } // [[arrow::export]] -R6 LargeUtf8__initialize() { return cpp11::r6(arrow::large_utf8(), "LargeUtf8"); } +R6 LargeUtf8__initialize() { return arrow::large_utf8(); } // [[arrow::export]] -R6 Binary__initialize() { return cpp11::r6(arrow::binary(), "Binary"); } +R6 Binary__initialize() { return arrow::binary(); } // [[arrow::export]] -R6 LargeBinary__initialize() { return cpp11::r6(arrow::large_binary(), "LargeBinary"); } +R6 LargeBinary__initialize() { return arrow::large_binary(); } // [[arrow::export]] -R6 Date32__initialize() { return cpp11::r6(arrow::date32(), "Date32"); } +R6 Date32__initialize() { return arrow::date32(); } // [[arrow::export]] -R6 Date64__initialize() { return cpp11::r6(arrow::date64(), "Date64"); } +R6 Date64__initialize() { return arrow::date64(); } // [[arrow::export]] -R6 Null__initialize() { return cpp11::r6(arrow::null(), "Null"); } +R6 Null__initialize() { return arrow::null(); } // [[arrow::export]] R6 Decimal128Type__initialize(int32_t precision, int32_t scale) { // Use the builder that validates inputs - return cpp11::r6(ValueOrStop(arrow::Decimal128Type::Make(precision, scale)), - "Decimal128Type"); + return ValueOrStop(arrow::Decimal128Type::Make(precision, scale)); } // [[arrow::export]] @@ -185,34 +182,34 @@ R6 FixedSizeBinary__initialize(R_xlen_t byte_width) { if (byte_width < 1) { cpp11::stop("'byte_width' must be > 0"); } - return cpp11::r6(arrow::fixed_size_binary(byte_width), "FixedSizeBinary"); + return arrow::fixed_size_binary(byte_width); } // [[arrow::export]] R6 Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone) { - return cpp11::r6(arrow::timestamp(unit, timezone), "Timestamp"); + return arrow::timestamp(unit, timezone); } // [[arrow::export]] R6 Time32__initialize(arrow::TimeUnit::type unit) { - return cpp11::r6(arrow::time32(unit), "Time32"); + return arrow::time32(unit); } // [[arrow::export]] R6 Time64__initialize(arrow::TimeUnit::type unit) { - return cpp11::r6(arrow::time64(unit), "Time64"); + return arrow::time64(unit); } // [[arrow::export]] R6 list__(SEXP x) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); - return cpp11::r6(arrow::list(field), "ListType"); + return arrow::list(field); } if (Rf_inherits(x, "DataType")) { auto type = cpp11::as_cpp>(x); - return cpp11::r6(arrow::list(type), "ListType"); + return arrow::list(type); } cpp11::stop("incompatible"); @@ -223,12 +220,12 @@ R6 list__(SEXP x) { R6 large_list__(SEXP x) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); - return cpp11::r6(arrow::large_list(field), "LargeListType"); + return arrow::large_list(field); } if (Rf_inherits(x, "DataType")) { auto type = cpp11::as_cpp>(x); - return cpp11::r6(arrow::large_list(type), "LargeListType"); + return arrow::large_list(type); } cpp11::stop("incompatible"); @@ -239,12 +236,12 @@ R6 large_list__(SEXP x) { R6 fixed_size_list__(SEXP x, int list_size) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); - return cpp11::r6(arrow::fixed_size_list(field, list_size), "FixedSizeListType"); + return arrow::fixed_size_list(field, list_size); } if (Rf_inherits(x, "DataType")) { auto type = cpp11::as_cpp>(x); - return cpp11::r6(arrow::fixed_size_list(type, list_size), "FixedSizeListType"); + return arrow::fixed_size_list(type, list_size); } cpp11::stop("incompatible"); @@ -253,7 +250,7 @@ R6 fixed_size_list__(SEXP x, int list_size) { // [[arrow::export]] R6 struct__(const std::vector>& fields) { - return cpp11::r6(arrow::struct_(fields), "StructType"); + return arrow::struct_(fields); } // [[arrow::export]] @@ -279,7 +276,7 @@ int DataType__num_fields(const std::shared_ptr& type) { // [[arrow::export]] cpp11::list DataType__fields(const std::shared_ptr& type) { - return arrow::r::to_r_list(type->fields(), cpp11::r6_Field); + return arrow::r::to_r_list(type->fields(), cpp11::to_r6); } // [[arrow::export]] @@ -332,18 +329,17 @@ arrow::TimeUnit::type TimestampType__unit( R6 DictionaryType__initialize(const std::shared_ptr& index_type, const std::shared_ptr& value_type, bool ordered) { - auto type = ValueOrStop(arrow::DictionaryType::Make(index_type, value_type, ordered)); - return cpp11::r6(type, "DictionaryType"); + return ValueOrStop(arrow::DictionaryType::Make(index_type, value_type, ordered)); } // [[arrow::export]] R6 DictionaryType__index_type(const std::shared_ptr& type) { - return cpp11::r6_DataType(type->index_type()); + return type->index_type(); } // [[arrow::export]] R6 DictionaryType__value_type(const std::shared_ptr& type) { - return cpp11::r6_DataType(type->value_type()); + return type->value_type(); } // [[arrow::export]] @@ -359,7 +355,7 @@ bool DictionaryType__ordered(const std::shared_ptr& type) // [[arrow::export]] R6 StructType__GetFieldByName(const std::shared_ptr& type, const std::string& name) { - return cpp11::r6(type->GetFieldByName(name), "Field"); + return type->GetFieldByName(name); } // [[arrow::export]] @@ -370,32 +366,32 @@ int StructType__GetFieldIndex(const std::shared_ptr& type, // [[arrow::export]] R6 ListType__value_field(const std::shared_ptr& type) { - return cpp11::r6(type->value_field(), "Field"); + return type->value_field(); } // [[arrow::export]] R6 ListType__value_type(const std::shared_ptr& type) { - return cpp11::r6_DataType(type->value_type()); + return type->value_type(); } // [[arrow::export]] R6 LargeListType__value_field(const std::shared_ptr& type) { - return cpp11::r6(type->value_field(), "Field"); + return type->value_field(); } // [[arrow::export]] R6 LargeListType__value_type(const std::shared_ptr& type) { - return cpp11::r6_DataType(type->value_type()); + return type->value_type(); } // [[arrow::export]] R6 FixedSizeListType__value_field(const std::shared_ptr& type) { - return cpp11::r6(type->value_field(), "Field"); + return type->value_field(); } // [[arrow::export]] R6 FixedSizeListType__value_type(const std::shared_ptr& type) { - return cpp11::r6_DataType(type->value_type()); + return type->value_type(); } // [[arrow::export]] diff --git a/r/src/expression.cpp b/r/src/expression.cpp index 7443589aa3c..4c2eec5dc5b 100644 --- a/r/src/expression.cpp +++ b/r/src/expression.cpp @@ -22,78 +22,87 @@ #include namespace ds = ::arrow::dataset; +namespace cpp11 { +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "Expression"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "Expression"; +} +} + // [[arrow::export]] R6 dataset___expr__field_ref(std::string name) { - return cpp11::r6(ds::field_ref(std::move(name)), "Expression"); + return ds::field_ref(std::move(name)); } // [[arrow::export]] R6 dataset___expr__equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::equal(lhs, rhs), "Expression"); + return ds::equal(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__not_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::not_equal(lhs, rhs), "Expression"); + return ds::not_equal(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__greater(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::greater(lhs, rhs), "Expression"); + return ds::greater(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__greater_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::greater_equal(lhs, rhs), "Expression"); + return ds::greater_equal(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__less(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::less(lhs, rhs), "Expression"); + return ds::less(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__less_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::less_equal(lhs, rhs), "Expression"); + return ds::less_equal(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__in(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(lhs->In(rhs).Copy(), "Expression"); + return lhs->In(rhs).Copy(); } // [[arrow::export]] R6 dataset___expr__and(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::and_(lhs, rhs), "Expression"); + return ds::and_(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__or(const std::shared_ptr& lhs, const std::shared_ptr& rhs) { - return cpp11::r6(ds::or_(lhs, rhs), "Expression"); + return ds::or_(lhs, rhs); } // [[arrow::export]] R6 dataset___expr__not(const std::shared_ptr& lhs) { - return cpp11::r6(ds::not_(lhs), "Expression"); + return ds::not_(lhs); } // [[arrow::export]] R6 dataset___expr__is_valid(const std::shared_ptr& lhs) { - return cpp11::r6(lhs->IsValid().Copy(), "Expression"); + return lhs->IsValid().Copy(); } // [[arrow::export]] R6 dataset___expr__scalar(const std::shared_ptr& x) { - return cpp11::r6(ds::scalar(x), "Expression"); + return ds::scalar(x); } // [[arrow::export]] diff --git a/r/src/feather.cpp b/r/src/feather.cpp index 0edf4708002..4b16830d106 100644 --- a/r/src/feather.cpp +++ b/r/src/feather.cpp @@ -21,6 +21,12 @@ #include #include +namespace cpp11 { +template <> inline std::string r6_class_name(const std::shared_ptr& codec) { + return "FeatherReader"; +} +} + // ---------- WriteFeather // [[arrow::export]] @@ -69,14 +75,13 @@ R6 ipc___feather___Reader__Read( break; } - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] R6 ipc___feather___Reader__Open( const std::shared_ptr& stream) { - return cpp11::r6(ValueOrStop(arrow::ipc::feather::Reader::Open(stream)), - "FeatherReader"); + return ValueOrStop(arrow::ipc::feather::Reader::Open(stream)); } // [[arrow::export]] diff --git a/r/src/field.cpp b/r/src/field.cpp index 3057d8218ff..da18c2aab6d 100644 --- a/r/src/field.cpp +++ b/r/src/field.cpp @@ -20,15 +20,11 @@ #if defined(ARROW_R_WITH_ARROW) #include -namespace cpp11 { -R6 r6_Field(const std::shared_ptr& field) { return r6(field, "Field"); } -} // namespace cpp11 - // [[arrow::export]] R6 Field__initialize(const std::string& name, const std::shared_ptr& field, bool nullable = true) { - return cpp11::r6(arrow::field(name, field, nullable), "Field"); + return arrow::field(name, field, nullable); } // [[arrow::export]] @@ -54,7 +50,7 @@ bool Field__nullable(const std::shared_ptr& field) { // [[arrow::export]] R6 Field__type(const std::shared_ptr& field) { - return cpp11::r6_DataType(field->type()); + return field->type(); } #endif diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 623554fbc0c..39037163b04 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -24,7 +24,29 @@ namespace fs = ::arrow::fs; -// FileInfo +namespace cpp11 { +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "FileSelector"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "FileInfo"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "InputStream"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "OutputStream"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "RandomAccessFile"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "LocalFileSystem"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "SubTreeFileSystem"; +} +} // [[arrow::export]] fs::FileType fs___FileInfo__type(const std::shared_ptr& x) { @@ -108,7 +130,7 @@ R6 fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, selector->base_dir = base_dir; selector->allow_not_found = allow_not_found; selector->recursive = recursive; - return cpp11::r6(selector, "FileSelector"); + return selector; } // FileSystem @@ -126,10 +148,7 @@ cpp11::list fs___FileSystem__GetTargetInfos_Paths( const std::shared_ptr& file_system, const std::vector& paths) { auto results = ValueOrStop(file_system->GetFileInfo(paths)); - return arrow::r::to_r_list(shared_ptr_vector(results), - [](const std::shared_ptr& info) { - return cpp11::r6(info, "FileInfo"); - }); + return arrow::r::to_r_list(shared_ptr_vector(results), cpp11::to_r6); } // [[arrow::export]] @@ -138,10 +157,7 @@ cpp11::list fs___FileSystem__GetTargetInfos_FileSelector( const std::shared_ptr& selector) { auto results = ValueOrStop(file_system->GetFileInfo(*selector)); - return arrow::r::to_r_list(shared_ptr_vector(results), - [](const std::shared_ptr& info) { - return cpp11::r6(info, "FileInfo"); - }); + return arrow::r::to_r_list(shared_ptr_vector(results), cpp11::to_r6); } // [[arrow::export]] @@ -189,25 +205,25 @@ void fs___FileSystem__CopyFile(const std::shared_ptr& file_syste // [[arrow::export]] R6 fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, const std::string& path) { - return cpp11::r6(ValueOrStop(file_system->OpenInputStream(path)), "InputStream"); + return ValueOrStop(file_system->OpenInputStream(path)); } // [[arrow::export]] R6 fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, const std::string& path) { - return cpp11::r6(ValueOrStop(file_system->OpenInputFile(path)), "RandomAccessFile"); + return ValueOrStop(file_system->OpenInputFile(path)); } // [[arrow::export]] R6 fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, const std::string& path) { - return cpp11::r6(ValueOrStop(file_system->OpenOutputStream(path)), "OutputStream"); + return ValueOrStop(file_system->OpenOutputStream(path)); } // [[arrow::export]] R6 fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, const std::string& path) { - return cpp11::r6(ValueOrStop(file_system->OpenAppendStream(path)), "OutputStream"); + return ValueOrStop(file_system->OpenAppendStream(path)); } // [[arrow::export]] @@ -218,20 +234,19 @@ std::string fs___FileSystem__type_name( // [[arrow::export]] R6 fs___LocalFileSystem__create() { - return cpp11::r6(std::make_shared(), "LocalFileSystem"); + return std::make_shared(); } // [[arrow::export]] R6 fs___SubTreeFileSystem__create(const std::string& base_path, const std::shared_ptr& base_fs) { - return cpp11::r6(std::make_shared(base_path, base_fs), - "SubTreeFileSystem"); + return std::make_shared(base_path, base_fs); } // [[arrow::export]] R6 fs___SubTreeFileSystem__base_fs( const std::shared_ptr& file_system) { - return cpp11::r6_FileSystem(file_system->base_fs()); + return file_system->base_fs(); } // [[arrow::export]] @@ -245,8 +260,7 @@ cpp11::writable::list fs___FileSystemFromUri(const std::string& path) { using cpp11::literals::operator"" _nm; std::string out_path; - cpp11::sexp out_fs = - cpp11::r6_FileSystem(ValueOrStop(fs::FileSystemFromUri(path, &out_path))); + R6 out_fs = ValueOrStop(fs::FileSystemFromUri(path, &out_path)); return cpp11::writable::list({"fs"_nm = out_fs, "path"_nm = out_path}); } diff --git a/r/src/io.cpp b/r/src/io.cpp index c67627120eb..505a9a11aff 100644 --- a/r/src/io.cpp +++ b/r/src/io.cpp @@ -21,11 +21,29 @@ #include #include +namespace cpp11 { +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "MemoryMappedFile"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "ReadableFile"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "BufferReader"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "FileOutputStream"; +} +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "BufferOutputStream"; +} +} + // ------ arrow::io::Readable // [[arrow::export]] R6 io___Readable__Read(const std::shared_ptr& x, int64_t nbytes) { - return cpp11::r6(ValueOrStop(x->Read(nbytes)), "Buffer"); + return ValueOrStop(x->Read(nbytes)); } // ------ arrow::io::InputStream @@ -74,27 +92,25 @@ R6 io___RandomAccessFile__Read0(const std::shared_ptrGetSize()); - return cpp11::r6(ValueOrStop(x->Read(n - current)), "Buffer"); + return ValueOrStop(x->Read(n - current)); } // [[arrow::export]] R6 io___RandomAccessFile__ReadAt(const std::shared_ptr& x, int64_t position, int64_t nbytes) { - return cpp11::r6(ValueOrStop(x->ReadAt(position, nbytes)), "Buffer"); + return ValueOrStop(x->ReadAt(position, nbytes)); } // ------ arrow::io::MemoryMappedFile // [[arrow::export]] R6 io___MemoryMappedFile__Create(const std::string& path, int64_t size) { - auto out = ValueOrStop(arrow::io::MemoryMappedFile::Create(path, size)); - return cpp11::r6(out, "MemoryMappedFile"); + return ValueOrStop(arrow::io::MemoryMappedFile::Create(path, size)); } // [[arrow::export]] R6 io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode) { - auto out = ValueOrStop(arrow::io::MemoryMappedFile::Open(path, mode)); - return cpp11::r6(out, "MemoryMappedFile"); + return ValueOrStop(arrow::io::MemoryMappedFile::Open(path, mode)); } // [[arrow::export]] @@ -107,16 +123,14 @@ void io___MemoryMappedFile__Resize(const std::shared_ptr& buffer) { - auto reader = std::make_shared(buffer); - return cpp11::r6(reader, "BufferReader"); + return std::make_shared(buffer); } // ------- arrow::io::Writable @@ -138,17 +152,15 @@ int64_t io___OutputStream__Tell(const std::shared_ptr& // [[arrow::export]] R6 io___FileOutputStream__Open(const std::string& path) { - return cpp11::r6(ValueOrStop(arrow::io::FileOutputStream::Open(path)), - "FileOutputStream"); + return ValueOrStop(arrow::io::FileOutputStream::Open(path)); } // ------ arrow::BufferOutputStream // [[arrow::export]] R6 io___BufferOutputStream__Create(int64_t initial_capacity) { - auto stream = ValueOrStop( + return ValueOrStop( arrow::io::BufferOutputStream::Create(initial_capacity, gc_memory_pool())); - return cpp11::r6(stream, "BufferOutputStream"); } // [[arrow::export]] @@ -160,7 +172,7 @@ int64_t io___BufferOutputStream__capacity( // [[arrow::export]] R6 io___BufferOutputStream__Finish( const std::shared_ptr& stream) { - return cpp11::r6(ValueOrStop(stream->Finish()), "Buffer"); + return ValueOrStop(stream->Finish()); } // [[arrow::export]] diff --git a/r/src/json.cpp b/r/src/json.cpp index 51c76b5ad47..56dc37c6add 100644 --- a/r/src/json.cpp +++ b/r/src/json.cpp @@ -20,13 +20,26 @@ #include +namespace cpp11 { +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "JsonReadOptions"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "JsonParseOptions"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "JsonTableReader"; +} +} + + // [[arrow::export]] R6 json___ReadOptions__initialize(bool use_threads, int block_size) { auto res = std::make_shared(arrow::json::ReadOptions::Defaults()); res->use_threads = use_threads; res->block_size = block_size; - return cpp11::r6(res, "JsonReadOptions"); + return res; } // [[arrow::export]] @@ -34,7 +47,7 @@ R6 json___ParseOptions__initialize(bool newlines_in_values) { auto res = std::make_shared(arrow::json::ParseOptions::Defaults()); res->newlines_in_values = newlines_in_values; - return cpp11::r6(res, "JsonParseOptions"); + return res; } // [[arrow::export]] @@ -42,15 +55,14 @@ R6 json___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options) { - auto reader = ValueOrStop(arrow::json::TableReader::Make( + return ValueOrStop(arrow::json::TableReader::Make( gc_memory_pool(), input, *read_options, *parse_options)); - return cpp11::r6(reader, "JsonTableReader"); } // [[arrow::export]] R6 json___TableReader__Read( const std::shared_ptr& table_reader) { - return cpp11::r6(ValueOrStop(table_reader->Read()), "Table"); + return ValueOrStop(table_reader->Read()); } #endif diff --git a/r/src/memorypool.cpp b/r/src/memorypool.cpp index db8f46c5254..b7db62a9682 100644 --- a/r/src/memorypool.cpp +++ b/r/src/memorypool.cpp @@ -66,8 +66,7 @@ arrow::MemoryPool* gc_memory_pool() { return &g_pool; } // [[arrow::export]] R6 MemoryPool__default() { - auto pool = std::shared_ptr(&g_pool, [](...) {}); - return cpp11::r6(pool, "MemoryPool"); + return std::shared_ptr(&g_pool, [](...) {}); } // [[arrow::export]] diff --git a/r/src/message.cpp b/r/src/message.cpp index dd69e7b249b..1fbd0db0378 100644 --- a/r/src/message.cpp +++ b/r/src/message.cpp @@ -21,6 +21,15 @@ #include #include +namespace cpp11 { +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "MessageReader"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "Message"; +} +} + // [[arrow::export]] int64_t ipc___Message__body_length(const std::unique_ptr& message) { return message->body_length(); @@ -28,12 +37,12 @@ int64_t ipc___Message__body_length(const std::unique_ptr& m // [[arrow::export]] R6 ipc___Message__metadata(const std::unique_ptr& message) { - return cpp11::r6(message->metadata(), "Buffer"); + return message->metadata(); } // [[arrow::export]] R6 ipc___Message__body(const std::unique_ptr& message) { - return cpp11::r6(message->body(), "Buffer"); + return message->body(); } // [[arrow::export]] @@ -61,43 +70,39 @@ R6 ipc___ReadRecordBatch__Message__Schema( arrow::ipc::DictionaryMemo memo; auto batch = ValueOrStop(arrow::ipc::ReadRecordBatch( *message, schema, &memo, arrow::ipc::IpcReadOptions::Defaults())); - return cpp11::r6(batch, "RecordBatch"); + return batch; } // [[arrow::export]] R6 ipc___ReadSchema_InputStream(const std::shared_ptr& stream) { // TODO: promote to function argument arrow::ipc::DictionaryMemo memo; - return cpp11::r6(ValueOrStop(arrow::ipc::ReadSchema(stream.get(), &memo)), "Schema"); + return ValueOrStop(arrow::ipc::ReadSchema(stream.get(), &memo)); } // [[arrow::export]] R6 ipc___ReadSchema_Message(const std::unique_ptr& message) { arrow::ipc::DictionaryMemo empty_memo; - return cpp11::r6(ValueOrStop(arrow::ipc::ReadSchema(*message, &empty_memo)), "Schema"); + return ValueOrStop(arrow::ipc::ReadSchema(*message, &empty_memo)); } //--------- MessageReader // [[arrow::export]] R6 ipc___MessageReader__Open(const std::shared_ptr& stream) { - std::shared_ptr reader( + return std::shared_ptr( arrow::ipc::MessageReader::Open(stream)); - return cpp11::r6(reader, "MessageReader"); } // [[arrow::export]] R6 ipc___MessageReader__ReadNextMessage( const std::unique_ptr& reader) { - std::shared_ptr msg = ValueOrStop(reader->ReadNextMessage()); - return cpp11::r6(msg, "Message"); + return ValueOrStop(reader->ReadNextMessage()); } // [[arrow::export]] R6 ipc___ReadMessage(const std::shared_ptr& stream) { - std::shared_ptr msg = - ValueOrStop(arrow::ipc::ReadMessage(stream.get())); - return cpp11::r6(msg, "Message"); + return ValueOrStop(arrow::ipc::ReadMessage(stream.get())); } #endif diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index ea33624680e..c04191d47aa 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -24,10 +24,46 @@ #include #include +namespace parquet { + +class WriterPropertiesBuilder : public WriterProperties::Builder { +public: + using WriterProperties::Builder::Builder; +}; + +class ArrowWriterPropertiesBuilder : public ArrowWriterProperties::Builder { +public: + using ArrowWriterProperties::Builder::Builder; +}; + +} // namespace parquet + +namespace cpp11 { +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetArrowReaderProperties"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetArrowWriterProperties"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetWriterProperties"; +} + +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetFileReader"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetWriterPropertiesBuilder"; +} + +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "ParquetFileWriter"; +} +} + // [[arrow::export]] R6 parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { - return cpp11::r6(std::make_shared(use_threads), - "ParquetReaderProperties"); + return std::make_shared(use_threads); } // [[arrow::export]] @@ -64,8 +100,7 @@ R6 parquet___arrow___FileReader__OpenFile( PARQUET_THROW_NOT_OK(builder.Open(file)); PARQUET_THROW_NOT_OK( builder.memory_pool(gc_memory_pool())->properties(*props)->Build(&reader)); - return cpp11::r6(std::shared_ptr(std::move(reader)), - "ParquetFileReader"); + return std::move(reader); } // [[arrow::export]] @@ -73,7 +108,7 @@ R6 parquet___arrow___FileReader__ReadTable1( const std::shared_ptr& reader) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadTable(&table)); - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] @@ -82,7 +117,7 @@ R6 parquet___arrow___FileReader__ReadTable2( const std::vector& column_indices) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadTable(column_indices, &table)); - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] @@ -90,7 +125,7 @@ R6 parquet___arrow___FileReader__ReadRowGroup1( const std::shared_ptr& reader, int i) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, &table)); - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] @@ -99,7 +134,7 @@ R6 parquet___arrow___FileReader__ReadRowGroup2( const std::vector& column_indices) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, column_indices, &table)); - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] @@ -108,7 +143,7 @@ R6 parquet___arrow___FileReader__ReadRowGroups1( const std::vector& row_groups) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, &table)); - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] @@ -117,7 +152,7 @@ R6 parquet___arrow___FileReader__ReadRowGroups2( const std::vector& row_groups, const std::vector& column_indices) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroups(row_groups, column_indices, &table)); - return cpp11::r6(table, "Table"); + return table; } // [[arrow::export]] @@ -143,23 +178,9 @@ R6 parquet___arrow___FileReader__ReadColumn( const std::shared_ptr& reader, int i) { std::shared_ptr array; PARQUET_THROW_NOT_OK(reader->ReadColumn(i - 1, &array)); - return cpp11::r6(array, "ChunkedArray"); + return array; } -namespace parquet { - -class WriterPropertiesBuilder : public WriterProperties::Builder { - public: - using WriterProperties::Builder::Builder; -}; - -class ArrowWriterPropertiesBuilder : public ArrowWriterProperties::Builder { - public: - using ArrowWriterProperties::Builder::Builder; -}; - -} // namespace parquet - // [[arrow::export]] R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, @@ -178,13 +199,12 @@ R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, builder->coerce_timestamps(static_cast(timestamp_unit)); } - return cpp11::r6(builder->build(), "ParquetArrowWriterProperties"); + return builder->build(); } // [[arrow::export]] R6 parquet___WriterProperties___Builder__create() { - return cpp11::r6(std::make_shared(), - "ParquetWriterPropertiesBuilder"); + return std::make_shared(); } // [[arrow::export]] @@ -278,7 +298,7 @@ void parquet___ArrowWriterProperties___Builder__data_page_size( // [[arrow::export]] R6 parquet___WriterProperties___Builder__build( const std::shared_ptr& builder) { - return cpp11::r6(builder->build(), "ParquetWriterProperties"); + return builder->build(); } // [[arrow::export]] @@ -290,8 +310,7 @@ R6 parquet___arrow___ParquetFileWriter__Open( std::unique_ptr writer; PARQUET_THROW_NOT_OK(parquet::arrow::FileWriter::Open( *schema, gc_memory_pool(), sink, properties, arrow_properties, &writer)); - return cpp11::r6(std::shared_ptr(std::move(writer)), - "ParquetFileWriter"); + return std::shared_ptr(std::move(writer)); } // [[arrow::export]] @@ -322,7 +341,7 @@ R6 parquet___arrow___FileReader__GetSchema( const std::shared_ptr& reader) { std::shared_ptr schema; StopIfNotOk(reader->GetSchema(&schema)); - return cpp11::r6(schema, "Schema"); + return schema; } #endif diff --git a/r/src/py-to-r.cpp b/r/src/py-to-r.cpp index 1c41139b292..e9f5cd91a06 100644 --- a/r/src/py-to-r.cpp +++ b/r/src/py-to-r.cpp @@ -22,13 +22,13 @@ // [[arrow::export]] R6 ImportArray(arrow::r::Pointer array, arrow::r::Pointer schema) { - return cpp11::r6_Array(ValueOrStop(arrow::ImportArray(array, schema))); + return ValueOrStop(arrow::ImportArray(array, schema)); } // [[arrow::export]] R6 ImportRecordBatch(arrow::r::Pointer array, arrow::r::Pointer schema) { - return cpp11::r6(ValueOrStop(arrow::ImportRecordBatch(array, schema)), "RecordBatch"); + return ValueOrStop(arrow::ImportRecordBatch(array, schema)); } // [[arrow::export]] diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp index f17896a11f6..85f08606da9 100644 --- a/r/src/recordbatch.cpp +++ b/r/src/recordbatch.cpp @@ -26,12 +26,6 @@ #include #include -namespace cpp11 { -R6 r6_RecordBatch(const std::shared_ptr& batch) { - return r6(batch, "RecordBatch"); -} -} // namespace cpp11 - // [[arrow::export]] int RecordBatch__num_columns(const std::shared_ptr& x) { return x->num_columns(); @@ -44,7 +38,7 @@ int RecordBatch__num_rows(const std::shared_ptr& x) { // [[arrow::export]] R6 RecordBatch__schema(const std::shared_ptr& x) { - return cpp11::r6(x->schema(), "Schema"); + return x->schema(); } // [[arrow::export]] @@ -54,7 +48,7 @@ R6 RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& auto names_metadata = cpp11::as_cpp>(metadata.names()); auto kv = std::shared_ptr( new arrow::KeyValueMetadata(names_metadata, vec_metadata)); - return cpp11::r6(x->ReplaceSchemaMetadata(kv), "RecordBatch"); + return x->ReplaceSchemaMetadata(kv); } // [[arrow::export]] @@ -64,20 +58,19 @@ cpp11::list RecordBatch__columns(const std::shared_ptr& batc for (int i = 0; i < nc; i++) { res[i] = batch->column(i); } - return arrow::r::to_r_list(res, cpp11::r6_Array); + return arrow::r::to_r_list(res, cpp11::to_r6); } // [[arrow::export]] R6 RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i) { arrow::r::validate_index(i, batch->num_columns()); - return cpp11::r6_Array(batch->column(i)); + return batch->column(i); } // [[arrow::export]] R6 RecordBatch__GetColumnByName(const std::shared_ptr& batch, const std::string& name) { - auto array = batch->GetColumnByName(name); - return cpp11::r6_Array(array); + return batch->GetColumnByName(name); } // [[arrow::export]] @@ -96,7 +89,7 @@ R6 RecordBatch__SelectColumns(const std::shared_ptr& batch, } auto schema = std::make_shared(std::move(fields)); - return cpp11::r6(arrow::RecordBatch::Make(schema, nrows, columns), "RecordBatch"); + return arrow::RecordBatch::Make(schema, nrows, columns); } // [[arrow::export]] @@ -110,7 +103,7 @@ bool RecordBatch__Equals(const std::shared_ptr& self, R6 RecordBatch__RemoveColumn(const std::shared_ptr& batch, R_xlen_t i) { arrow::r::validate_index(i, batch->num_columns()); - return cpp11::r6(ValueOrStop(batch->RemoveColumn(i)), "RecordBatch"); + return ValueOrStop(batch->RemoveColumn(i)); } // [[arrow::export]] @@ -134,7 +127,7 @@ cpp11::writable::strings RecordBatch__names( // [[arrow::export]] R6 RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, self->num_rows()); - return cpp11::r6(self->Slice(offset), "RecordBatch"); + return self->Slice(offset); } // [[arrow::export]] @@ -142,7 +135,7 @@ R6 RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t R_xlen_t length) { arrow::r::validate_slice_offset(offset, self->num_rows()); arrow::r::validate_slice_length(length, self->num_rows() - offset); - return cpp11::r6(self->Slice(offset, length), "RecordBatch"); + return self->Slice(offset, length); } // [[arrow::export]] @@ -172,9 +165,8 @@ R6 ipc___ReadRecordBatch__InputStream__Schema( // TODO: promote to function arg arrow::ipc::DictionaryMemo memo; StopIfNotOk(memo.fields().AddSchemaFields(*schema)); - auto batch = ValueOrStop(arrow::ipc::ReadRecordBatch( + return ValueOrStop(arrow::ipc::ReadRecordBatch( schema, &memo, arrow::ipc::IpcReadOptions::Defaults(), stream.get())); - return cpp11::r6(batch, "RecordBatch"); } namespace arrow { @@ -277,7 +269,7 @@ R6 RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) { // RecordBatch if (!infer_schema) { - return cpp11::r6(RecordBatch__from_arrays__known_schema(schema, lst), "RecordBatch"); + return RecordBatch__from_arrays__known_schema(schema, lst); } // RecordBatch @@ -290,7 +282,7 @@ R6 RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) { StopIfNotOk(arrow::r::check_consistent_array_size(arrays, &num_rows)); auto out = arrow::RecordBatch::Make(schema, num_rows, arrays); - return cpp11::r6(out, "RecordBatch"); + return out; } #endif diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp index 9c1fdc0e507..807e74305fe 100644 --- a/r/src/recordbatchreader.cpp +++ b/r/src/recordbatchreader.cpp @@ -21,16 +21,25 @@ #include #include +namespace cpp11 { +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "RecordBatchStreamReader"; +} +template <> std::string r6_class_name(const std::shared_ptr& x) { + return "RecordBatchFileReader"; +} +} + // [[arrow::export]] R6 RecordBatchReader__schema(const std::shared_ptr& reader) { - return cpp11::r6(reader->schema(), "Schema"); + return reader->schema(); } // [[arrow::export]] R6 RecordBatchReader__ReadNext(const std::shared_ptr& reader) { std::shared_ptr batch; StopIfNotOk(reader->ReadNext(&batch)); - return cpp11::r6(batch, "RecordBatch"); + return batch; } // -------- RecordBatchStreamReader @@ -38,8 +47,7 @@ R6 RecordBatchReader__ReadNext(const std::shared_ptr& // [[arrow::export]] R6 ipc___RecordBatchStreamReader__Open( const std::shared_ptr& stream) { - auto reader = ValueOrStop(arrow::ipc::RecordBatchStreamReader::Open(stream)); - return cpp11::r6(reader, "RecordBatchStreamReader"); + return ValueOrStop(arrow::ipc::RecordBatchStreamReader::Open(stream)); } // [[arrow::export]] @@ -55,7 +63,7 @@ cpp11::list ipc___RecordBatchStreamReader__batches( res.push_back(batch); } - return arrow::r::to_r_list(res, cpp11::r6_RecordBatch); + return arrow::r::to_r_list(res, cpp11::to_r6); } // -------- RecordBatchFileReader @@ -63,7 +71,7 @@ cpp11::list ipc___RecordBatchStreamReader__batches( // [[arrow::export]] R6 ipc___RecordBatchFileReader__schema( const std::shared_ptr& reader) { - return cpp11::r6(reader->schema(), "Schema"); + return reader->schema(); } // [[arrow::export]] @@ -78,14 +86,13 @@ R6 ipc___RecordBatchFileReader__ReadRecordBatch( if (i < 0 && i >= reader->num_record_batches()) { cpp11::stop("Record batch index out of bounds"); } - return cpp11::r6(ValueOrStop(reader->ReadRecordBatch(i)), "RecordBatch"); + return ValueOrStop(reader->ReadRecordBatch(i)); } // [[arrow::export]] -SEXP ipc___RecordBatchFileReader__Open( +R6 ipc___RecordBatchFileReader__Open( const std::shared_ptr& file) { - auto reader = ValueOrStop(arrow::ipc::RecordBatchFileReader::Open(file)); - return cpp11::r6(reader, "RecordBatchFileReader"); + return ValueOrStop(arrow::ipc::RecordBatchFileReader::Open(file)); } // [[arrow::export]] @@ -97,8 +104,7 @@ R6 Table__from_RecordBatchFileReader( batches[i] = ValueOrStop(reader->ReadRecordBatch(i)); } - auto table = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); - return cpp11::r6(table, "Table"); + return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); } // [[arrow::export]] @@ -112,8 +118,7 @@ R6 Table__from_RecordBatchStreamReader( batches.push_back(batch); } - auto table = ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); - return cpp11::r6(table, "Table"); + return ValueOrStop(arrow::Table::FromRecordBatches(std::move(batches))); } // [[arrow::export]] @@ -126,7 +131,7 @@ cpp11::list ipc___RecordBatchFileReader__batches( res[i] = ValueOrStop(reader->ReadRecordBatch(i)); } - return arrow::r::to_r_list(res, cpp11::r6_RecordBatch); + return arrow::r::to_r_list(res, cpp11::to_r6); } #endif diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp index 9a5b2e31f0e..17a8e672376 100644 --- a/r/src/recordbatchwriter.cpp +++ b/r/src/recordbatchwriter.cpp @@ -20,6 +20,12 @@ #if defined(ARROW_R_WITH_ARROW) #include +namespace cpp11 { +template <> inline std::string r6_class_name(const std::shared_ptr& x) { + return "RecordBatchWriter"; +} +} + // [[arrow::export]] void ipc___RecordBatchWriter__WriteRecordBatch( const std::shared_ptr& batch_writer, @@ -49,8 +55,7 @@ R6 ipc___RecordBatchFileWriter__Open( options.write_legacy_ipc_format = use_legacy_format; options.metadata_version = metadata_version; - auto writer = ValueOrStop(arrow::ipc::MakeFileWriter(stream, schema, options)); - return cpp11::r6(writer, "RecordBatchFileWriter"); + return ValueOrStop(arrow::ipc::MakeFileWriter(stream, schema, options)); } // [[arrow::export]] @@ -62,8 +67,7 @@ R6 ipc___RecordBatchStreamWriter__Open( options.write_legacy_ipc_format = use_legacy_format; options.metadata_version = metadata_version; - auto writer = ValueOrStop(MakeStreamWriter(stream, schema, options)); - return cpp11::r6(writer, "RecordBatchStreamWriter"); + return ValueOrStop(MakeStreamWriter(stream, schema, options)); } #endif diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index 1ea8886252a..357174ace0c 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -26,21 +26,18 @@ namespace cpp11 { -R6 r6_Scalar(const std::shared_ptr& ptr) { - if (ptr == nullptr) return R_NilValue; - - std::string type = "Scalar"; +template <> std::string r6_class_name(const std::shared_ptr& ptr) { if (ptr->type->id() == arrow::Type::STRUCT) { - type = "StructScalar"; + return "StructScalar"; } - return r6(ptr, type); + return "Scalar"; } } // namespace cpp11 // [[arrow::export]] R6 Array__GetScalar(const std::shared_ptr& x, int64_t i) { - return cpp11::r6_Scalar(ValueOrStop(x->GetScalar(i))); + return ValueOrStop(x->GetScalar(i)); } // [[arrow::export]] @@ -51,18 +48,18 @@ std::string Scalar__ToString(const std::shared_ptr& s) { // [[arrow::export]] R6 Scalar__CastTo(const std::shared_ptr& s, const std::shared_ptr& t) { - return cpp11::r6_Scalar(ValueOrStop(s->CastTo(t))); + return ValueOrStop(s->CastTo(t)); } // [[arrow::export]] R6 StructScalar__field(const std::shared_ptr& s, int i) { - return cpp11::r6_Scalar(ValueOrStop(s->field(i))); + return ValueOrStop(s->field(i)); } // [[arrow::export]] R6 StructScalar__GetFieldByName(const std::shared_ptr& s, const std::string& name) { - return cpp11::r6_Scalar(ValueOrStop(s->field(name))); + return ValueOrStop(s->field(name)); } // [[arrow::export]] @@ -79,7 +76,7 @@ bool Scalar__is_valid(const std::shared_ptr& s) { return s->is_va // [[arrow::export]] R6 Scalar__type(const std::shared_ptr& s) { - return cpp11::r6_DataType(s->type); + return s->type; } #endif diff --git a/r/src/schema.cpp b/r/src/schema.cpp index f1bf958902f..153da88f8fe 100644 --- a/r/src/schema.cpp +++ b/r/src/schema.cpp @@ -24,7 +24,7 @@ // [[arrow::export]] R6 schema_(const std::vector>& fields) { - return cpp11::r6(arrow::schema(fields), "Schema"); + return arrow::schema(fields); } // [[arrow::export]] @@ -43,17 +43,17 @@ R6 Schema__field(const std::shared_ptr& s, int i) { cpp11::stop("Invalid field index for schema."); } - return cpp11::r6(s->field(i), "Field"); + return s->field(i); } // [[arrow::export]] R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x) { - return cpp11::r6(s->GetFieldByName(x), "Field"); + return s->GetFieldByName(x); } // [[arrow::export]] cpp11::list Schema__fields(const std::shared_ptr& schema) { - return arrow::r::to_r_list(schema->fields(), cpp11::r6_Field); + return arrow::r::to_r_list(schema->fields(), cpp11::to_r6); } // [[arrow::export]] @@ -98,7 +98,7 @@ R6 Schema__WithMetadata(const std::shared_ptr& schema, auto kv = std::make_shared(std::move(names), std::move(values)); - return cpp11::r6(schema->WithMetadata(std::move(kv)), "Schema"); + return schema->WithMetadata(std::move(kv)); } // [[arrow::export]] @@ -116,7 +116,7 @@ bool Schema__Equals(const std::shared_ptr& schema, // [[arrow::export]] R6 arrow__UnifySchemas(const std::vector>& schemas) { - return cpp11::r6(ValueOrStop(arrow::UnifySchemas(schemas)), "Schema"); + return ValueOrStop(arrow::UnifySchemas(schemas)); } #endif diff --git a/r/src/table.cpp b/r/src/table.cpp index f007470e8ad..9a6d4e78e83 100644 --- a/r/src/table.cpp +++ b/r/src/table.cpp @@ -32,7 +32,7 @@ int Table__num_rows(const std::shared_ptr& x) { return x->num_rows // [[arrow::export]] R6 Table__schema(const std::shared_ptr& x) { - return cpp11::r6(x->schema(), "Schema"); + return x->schema(); } // [[arrow::export]] @@ -42,19 +42,19 @@ R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, auto names_metadata = cpp11::as_cpp>(metadata.names()); auto kv = std::shared_ptr( new arrow::KeyValueMetadata(names_metadata, vec_metadata)); - return cpp11::r6(x->ReplaceSchemaMetadata(kv), "Table"); + return x->ReplaceSchemaMetadata(kv); } // [[arrow::export]] R6 Table__column(const std::shared_ptr& table, R_xlen_t i) { arrow::r::validate_index(i, table->num_columns()); - return cpp11::r6(table->column(i), "ChunkedArray"); + return table->column(i); } // [[arrow::export]] R6 Table__field(const std::shared_ptr& table, R_xlen_t i) { arrow::r::validate_index(i, table->num_columns()); - return cpp11::r6(table->field(i), "Field"); + return table->field(i); } // [[arrow::export]] @@ -64,7 +64,7 @@ cpp11::list Table__columns(const std::shared_ptr& table) { for (int i = 0; i < nc; i++) { res[i] = table->column(i); } - return arrow::r::to_r_list(res, cpp11::r6_ChunkedArray); + return arrow::r::to_r_list(res, cpp11::to_r6); } // [[arrow::export]] @@ -75,7 +75,7 @@ std::vector Table__ColumnNames(const std::shared_ptr& // [[arrow::export]] R6 Table__Slice1(const std::shared_ptr& table, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, table->num_rows()); - return cpp11::r6(table->Slice(offset), "Table"); + return table->Slice(offset); } // [[arrow::export]] @@ -83,7 +83,7 @@ R6 Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, table->num_rows()); arrow::r::validate_slice_length(length, table->num_rows() - offset); - return cpp11::r6(table->Slice(offset, length), "Table"); + return table->Slice(offset, length); } // [[arrow::export]] @@ -107,13 +107,13 @@ bool Table__ValidateFull(const std::shared_ptr& table) { // [[arrow::export]] R6 Table__GetColumnByName(const std::shared_ptr& table, const std::string& name) { - return cpp11::r6(table->GetColumnByName(name), "ChunkedArray"); + return table->GetColumnByName(name); } // [[arrow::export]] R6 Table__SelectColumns(const std::shared_ptr& table, const std::vector& indices) { - return cpp11::r6(ValueOrStop(table->SelectColumns(indices)), "Table"); + return ValueOrStop(table->SelectColumns(indices)); } namespace arrow { @@ -268,7 +268,7 @@ R6 Table__from_record_batches( tab = ValueOrStop(arrow::Table::FromRecordBatches(schema, std::move(batches))); } - return cpp11::r6(tab, "Table"); + return tab; } // [[arrow::export]] @@ -288,7 +288,7 @@ R6 Table__from_dots(SEXP lst, SEXP schema_sxp) { StopIfNotOk( arrow::r::CollectTableColumns(lst, schema, num_fields, infer_schema, columns)); - return cpp11::r6(arrow::Table::Make(schema, columns), "Table"); + return arrow::Table::Make(schema, columns); } #endif diff --git a/r/tests/testthat/test-dataset.R b/r/tests/testthat/test-dataset.R index 73d654eb5a1..b545aabdd46 100644 --- a/r/tests/testthat/test-dataset.R +++ b/r/tests/testthat/test-dataset.R @@ -694,7 +694,7 @@ test_that("Assembling a Dataset manually and getting a Table", { fmt <- FileFormat$create("parquet") factory <- FileSystemDatasetFactory$create(fs, selector, fmt, partitioning = partitioning) - expect_is(factory, "FileSystemDatasetFactory") + expect_is(factory, "DatasetFactory") schm <- factory$Inspect() expect_is(schm, "Schema") @@ -716,9 +716,9 @@ test_that("Assembling a Dataset manually and getting a Table", { test_that("Assembling multiple DatasetFactories with DatasetFactory", { factory1 <- dataset_factory(file.path(dataset_dir, 1), format = "parquet") - expect_is(factory1, "FileSystemDatasetFactory") + expect_is(factory1, "DatasetFactory") factory2 <- dataset_factory(file.path(dataset_dir, 2), format = "parquet") - expect_is(factory2, "FileSystemDatasetFactory") + expect_is(factory2, "DatasetFactory") factory <- DatasetFactory$create(list(factory1, factory2)) expect_is(factory, "DatasetFactory") diff --git a/r/tests/testthat/test-read-record-batch.R b/r/tests/testthat/test-read-record-batch.R index 8eb196a1eab..9383c476588 100644 --- a/r/tests/testthat/test-read-record-batch.R +++ b/r/tests/testthat/test-read-record-batch.R @@ -34,7 +34,7 @@ test_that("RecordBatchFileWriter / RecordBatchFileReader roundtrips", { stream <- FileOutputStream$create(tf) writer <- RecordBatchFileWriter$create(stream, tab$schema) - expect_is(writer, "RecordBatchFileWriter") + expect_is(writer, "RecordBatchWriter") writer$write_table(tab) writer$close() stream$close() diff --git a/r/tests/testthat/test-record-batch-reader.R b/r/tests/testthat/test-record-batch-reader.R index d9c34068425..533d53e7ffb 100644 --- a/r/tests/testthat/test-record-batch-reader.R +++ b/r/tests/testthat/test-record-batch-reader.R @@ -28,7 +28,7 @@ test_that("RecordBatchStreamReader / Writer", { sink <- BufferOutputStream$create() expect_equal(sink$tell(), 0) writer <- RecordBatchStreamWriter$create(sink, batch$schema) - expect_is(writer, "RecordBatchStreamWriter") + expect_is(writer, "RecordBatchWriter") writer$write(batch) writer$write(tab) writer$write(tbl) @@ -56,7 +56,7 @@ test_that("RecordBatchStreamReader / Writer", { test_that("RecordBatchFileReader / Writer", { sink <- BufferOutputStream$create() writer <- RecordBatchFileWriter$create(sink, batch$schema) - expect_is(writer, "RecordBatchFileWriter") + expect_is(writer, "RecordBatchWriter") writer$write(batch) writer$write(tab) writer$write(tbl) diff --git a/r/tests/testthat/test-schema.R b/r/tests/testthat/test-schema.R index 23b08da5457..2730cb50839 100644 --- a/r/tests/testthat/test-schema.R +++ b/r/tests/testthat/test-schema.R @@ -76,7 +76,7 @@ test_that("reading schema from Buffer", { stream <- BufferOutputStream$create() writer <- RecordBatchStreamWriter$create(stream, batch$schema) - expect_is(writer, "RecordBatchStreamWriter") + expect_is(writer, "RecordBatchWriter") writer$close() buffer <- stream$finish() From ac96d76eee3e3d86f4fdbfc5e156ae87628cfabb Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Mon, 2 Nov 2020 11:07:20 +0100 Subject: [PATCH 26/43] simplified to_r_list() for the most used case --- r/src/array.cpp | 39 ++++++++---------- r/src/arraydata.cpp | 6 +-- r/src/arrow_cpp11.h | 32 ++++++++++----- r/src/arrow_types.h | 55 ++++++++++++++++++------- r/src/buffer.cpp | 3 +- r/src/chunkedarray.cpp | 2 +- r/src/compute.cpp | 6 ++- r/src/csv.cpp | 30 +++++++++----- r/src/dataset.cpp | 82 +++++++++++++++++++++++++------------ r/src/datatype.cpp | 13 +++--- r/src/expression.cpp | 14 ++++--- r/src/feather.cpp | 6 ++- r/src/field.cpp | 4 +- r/src/filesystem.cpp | 36 ++++++++++------ r/src/io.cpp | 22 +++++++--- r/src/json.cpp | 19 +++++---- r/src/message.cpp | 10 +++-- r/src/parquet.cpp | 30 ++++++++++---- r/src/recordbatch.cpp | 2 +- r/src/recordbatchreader.cpp | 14 ++++--- r/src/recordbatchwriter.cpp | 6 ++- r/src/scalar.cpp | 7 ++-- r/src/schema.cpp | 2 +- r/src/table.cpp | 6 +-- 24 files changed, 281 insertions(+), 165 deletions(-) diff --git a/r/src/array.cpp b/r/src/array.cpp index 3ca0184fdec..39d0c524bb2 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -24,22 +24,23 @@ namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& array) { +template <> +std::string r6_class_name(const std::shared_ptr& array) { auto type = array->type_id(); switch (type) { - case arrow::Type::DICTIONARY: - return "DictionaryArray"; - case arrow::Type::STRUCT: - return "StructArray"; - case arrow::Type::LIST: - return "ListArray"; - case arrow::Type::LARGE_LIST: - return "LargeListArray"; - case arrow::Type::FIXED_SIZE_LIST: - return "FixedSizeListArray"; - - default: - return "Array"; + case arrow::Type::DICTIONARY: + return "DictionaryArray"; + case arrow::Type::STRUCT: + return "StructArray"; + case arrow::Type::LIST: + return "ListArray"; + case arrow::Type::LARGE_LIST: + return "LargeListArray"; + case arrow::Type::FIXED_SIZE_LIST: + return "FixedSizeListArray"; + + default: + return "Array"; } } @@ -114,9 +115,7 @@ int Array__offset(const std::shared_ptr& x) { return x->offset(); int Array__null_count(const std::shared_ptr& x) { return x->null_count(); } // [[arrow::export]] -R6 Array__type(const std::shared_ptr& x) { - return x->type(); -} +R6 Array__type(const std::shared_ptr& x) { return x->type(); } // [[arrow::export]] std::string Array__ToString(const std::shared_ptr& x) { @@ -141,9 +140,7 @@ bool Array__ApproxEquals(const std::shared_ptr& lhs, } // [[arrow::export]] -R6 Array__data(const std::shared_ptr& array) { - return array->data(); -} +R6 Array__data(const std::shared_ptr& array) { return array->data(); } // [[arrow::export]] bool Array__RangeEquals(const std::shared_ptr& self, @@ -195,7 +192,7 @@ R6 StructArray__GetFieldByName(const std::shared_ptr& array, // [[arrow::export]] cpp11::list StructArray__Flatten(const std::shared_ptr& array) { - return arrow::r::to_r_list(ValueOrStop(array->Flatten()), cpp11::to_r6); + return arrow::r::to_r_list(ValueOrStop(array->Flatten())); } // [[arrow::export]] diff --git a/r/src/arraydata.cpp b/r/src/arraydata.cpp index 0e3c2892f87..80f42fde6df 100644 --- a/r/src/arraydata.cpp +++ b/r/src/arraydata.cpp @@ -21,9 +21,7 @@ #include // [[arrow::export]] -R6 ArrayData__get_type(const std::shared_ptr& x) { - return x->type; -} +R6 ArrayData__get_type(const std::shared_ptr& x) { return x->type; } // [[arrow::export]] int ArrayData__get_length(const std::shared_ptr& x) { @@ -42,7 +40,7 @@ int ArrayData__get_offset(const std::shared_ptr& x) { // [[arrow::export]] cpp11::list ArrayData__buffers(const std::shared_ptr& x) { - return arrow::r::to_r_list(x->buffers, cpp11::to_r6); + return arrow::r::to_r_list(x->buffers); } #endif diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 10d0e607d58..fc2c11291ed 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -274,6 +274,9 @@ cpp11::writable::list to_r_list(const std::vector>& x, return to_r_vector(x, as_sexp); } +template +cpp11::writable::list to_r_list(const std::vector>& x); + inline cpp11::writable::integers short_row_names(int n) { return {NA_INTEGER, -n}; } template @@ -294,7 +297,7 @@ bool GetBoolOption(const std::string& name, bool default_); namespace cpp11 { template -std::string r6_class_name(const std::shared_ptr& x) ; +std::string r6_class_name(const std::shared_ptr& x); template SEXP to_r6(const std::shared_ptr& x) { @@ -314,24 +317,33 @@ SEXP to_r6(const std::shared_ptr& x) { UNPROTECT(3); return r6; } +} // namespace cpp11 + +namespace arrow { +namespace r { + +template +cpp11::writable::list to_r_list(const std::vector>& x) { + auto as_sexp = [&](const std::shared_ptr& t) { return cpp11::to_r6(t); }; + return to_r_vector(x, as_sexp); } -class R6 { -public: +} // namespace r +} // namespace arrow +class R6 { + public: template - R6(const std::shared_ptr& x) : data_(cpp11::to_r6(x)){} + R6(const std::shared_ptr& x) : data_(cpp11::to_r6(x)) {} template - R6(std::unique_ptr x) : data_(cpp11::to_r6(std::shared_ptr(x.release()))){} + R6(std::unique_ptr x) : data_(cpp11::to_r6(std::shared_ptr(x.release()))) {} - R6(SEXP data) : data_(data){} + R6(SEXP data) : data_(data) {} - operator SEXP() const { - return data_; - } + operator SEXP() const { return data_; } -private: + private: SEXP data_; }; diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index 5072a763730..502c1ca2465 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -122,41 +122,66 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& array); -template <> std::string r6_class_name(const std::shared_ptr& type); -template <> std::string r6_class_name(const std::shared_ptr& ptr); - -template <> inline std::string r6_class_name(const std::shared_ptr& array_data) { +template <> +std::string r6_class_name(const std::shared_ptr& array); +template <> +std::string r6_class_name(const std::shared_ptr& type); +template <> +std::string r6_class_name(const std::shared_ptr& ptr); + +template <> +inline std::string r6_class_name( + const std::shared_ptr& array_data) { return "Field"; } -template <> inline std::string r6_class_name(const std::shared_ptr& array_data) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& array_data) { return "ArrayData"; } -template <> inline std::string r6_class_name(const std::shared_ptr& array) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& array) { return "ChunkedArray"; } -template <> inline std::string r6_class_name(const std::shared_ptr& array) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& array) { return "Buffer"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "Codec"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CompressedOutputStream"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CompressedInputStream"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "RecordBatch"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "Table"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "Schema"; } -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "MemoryPool"; } diff --git a/r/src/buffer.cpp b/r/src/buffer.cpp index 3182c9a7357..e270efd48a1 100644 --- a/r/src/buffer.cpp +++ b/r/src/buffer.cpp @@ -53,7 +53,8 @@ R6 r___RBuffer__initialize(SEXP x) { out = std::make_shared>(x); break; case CPLXSXP: - out = std::make_shared>(arrow::r::complexs(x)); + out = + std::make_shared>(arrow::r::complexs(x)); break; default: cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x))); diff --git a/r/src/chunkedarray.cpp b/r/src/chunkedarray.cpp index 0763475e8f6..eda55a5483a 100644 --- a/r/src/chunkedarray.cpp +++ b/r/src/chunkedarray.cpp @@ -45,7 +45,7 @@ R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array // [[arrow::export]] cpp11::list ChunkedArray__chunks( const std::shared_ptr& chunked_array) { - return arrow::r::to_r_list(chunked_array->chunks(), cpp11::to_r6); + return arrow::r::to_r_list(chunked_array->chunks()); } // [[arrow::export]] diff --git a/r/src/compute.cpp b/r/src/compute.cpp index ee0c0f324d6..1e8850fe24b 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -24,10 +24,12 @@ #include namespace cpp11 { -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CastOptions"; } -} +} // namespace cpp11 arrow::compute::ExecContext* gc_context() { static arrow::compute::ExecContext context(gc_memory_pool()); diff --git a/r/src/csv.cpp b/r/src/csv.cpp index 3aebaa032df..cd85179f079 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -23,22 +23,32 @@ #include namespace cpp11 { -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CsvReadOptions"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CsvParseOptions"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CsvConvertOptions"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "CsvTableReader"; } -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "TimestampParser"; } -} +} // namespace cpp11 // [[arrow::export]] R6 csv___ReadOptions__initialize(cpp11::list options) { @@ -156,8 +166,8 @@ R6 csv___TableReader__Make( const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options) { - return ValueOrStop(arrow::csv::TableReader::Make( - gc_memory_pool(), input, *read_options, *parse_options, *convert_options)); + return ValueOrStop(arrow::csv::TableReader::Make(gc_memory_pool(), input, *read_options, + *parse_options, *convert_options)); } // [[arrow::export]] @@ -182,8 +192,6 @@ R6 TimestampParser__MakeStrptime(std::string format) { } // [[arrow::export]] -R6 TimestampParser__MakeISO8601() { - return arrow::TimestampParser::MakeISO8601(); -} +R6 TimestampParser__MakeISO8601() { return arrow::TimestampParser::MakeISO8601(); } #endif diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 69a1470cfb2..9247d6f6ef0 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -30,31 +30,39 @@ namespace fs = ::arrow::fs; namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& dataset) { +template <> +std::string r6_class_name(const std::shared_ptr& dataset) { auto type_name = dataset->type_name(); if (type_name == "union") { return "UnionDataset"; } else if (type_name == "filesystem") { return "FileSystemDataset"; - } else if(type_name == "in-memory"){ + } else if (type_name == "in-memory") { return "InMemoryDataset"; } else { return "Dataset"; } } -template <> std::string r6_class_name(const std::shared_ptr& dataset) { +template <> +std::string r6_class_name( + const std::shared_ptr& dataset) { return "UnionDataset"; } -template <> std::string r6_class_name(const std::shared_ptr& dataset) { +template <> +std::string r6_class_name( + const std::shared_ptr& dataset) { return "InMemoryDataset"; } -template <> std::string r6_class_name(const std::shared_ptr& dataset) { +template <> +std::string r6_class_name( + const std::shared_ptr& dataset) { return "FileSystemDataset"; } - -template <> std::string r6_class_name(const std::shared_ptr& file_system) { +template <> +std::string r6_class_name( + const std::shared_ptr& file_system) { auto type_name = file_system->type_name(); if (type_name == "local") { @@ -68,7 +76,9 @@ template <> std::string r6_class_name(const std::shared_ptr std::string r6_class_name(const std::shared_ptr& file_format) { +template <> +std::string r6_class_name( + const std::shared_ptr& file_format) { auto type_name = file_format->type_name(); if (type_name == "parquet") { return "ParquetFileFormat"; @@ -80,41 +90,63 @@ template <> std::string r6_class_name(const std::shared_ptr std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ScannerBuilder"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "DatasetFactory"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "FileSystemDatasetFactory"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "PartitioningFactory"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetFileFormat"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "IpcFileFormat"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "CsvFileFormat"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "DirectoryPartitioning"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "HivePartitioning"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name(const std::shared_ptr& x) { return "Scanner"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name(const std::shared_ptr& x) { return "ScanTask"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "FileWriteOptions"; } @@ -159,7 +191,7 @@ R6 dataset___InMemoryDataset__create(const std::shared_ptr& table) // [[arrow::export]] cpp11::list dataset___UnionDataset__children( const std::shared_ptr& ds) { - return arrow::r::to_r_list(ds->children(), cpp11::to_r6); + return arrow::r::to_r_list(ds->children()); } // [[arrow::export]] @@ -315,9 +347,7 @@ void dataset___IpcFileWriteOptions__update1( } // [[arrow::export]] -R6 dataset___IpcFileFormat__Make() { - return std::make_shared(); -} +R6 dataset___IpcFileFormat__Make() { return std::make_shared(); } // [[arrow::export]] R6 dataset___CsvFileFormat__Make( @@ -423,7 +453,7 @@ cpp11::list dataset___Scanner__Scan(const std::shared_ptr& scanner) out.push_back(scan_task); } - return arrow::r::to_r_list(out, cpp11::to_r6); + return arrow::r::to_r_list(out); } // [[arrow::export]] @@ -442,7 +472,7 @@ cpp11::list dataset___ScanTask__get_batches( batch = ValueOrStop(b); out.push_back(batch); } - return arrow::r::to_r_list(out, cpp11::to_r6); + return arrow::r::to_r_list(out); } // [[arrow::export]] diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index 157b3da3187..721090dcc11 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -21,7 +21,8 @@ #include namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& type) { +template <> +std::string r6_class_name(const std::shared_ptr& type) { using arrow::Type; switch (type->id()) { @@ -191,14 +192,10 @@ R6 Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone } // [[arrow::export]] -R6 Time32__initialize(arrow::TimeUnit::type unit) { - return arrow::time32(unit); -} +R6 Time32__initialize(arrow::TimeUnit::type unit) { return arrow::time32(unit); } // [[arrow::export]] -R6 Time64__initialize(arrow::TimeUnit::type unit) { - return arrow::time64(unit); -} +R6 Time64__initialize(arrow::TimeUnit::type unit) { return arrow::time64(unit); } // [[arrow::export]] R6 list__(SEXP x) { @@ -276,7 +273,7 @@ int DataType__num_fields(const std::shared_ptr& type) { // [[arrow::export]] cpp11::list DataType__fields(const std::shared_ptr& type) { - return arrow::r::to_r_list(type->fields(), cpp11::to_r6); + return arrow::r::to_r_list(type->fields()); } // [[arrow::export]] diff --git a/r/src/expression.cpp b/r/src/expression.cpp index 4c2eec5dc5b..03d190cac14 100644 --- a/r/src/expression.cpp +++ b/r/src/expression.cpp @@ -23,18 +23,20 @@ namespace ds = ::arrow::dataset; namespace cpp11 { -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "Expression"; } -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "Expression"; } -} +} // namespace cpp11 // [[arrow::export]] -R6 dataset___expr__field_ref(std::string name) { - return ds::field_ref(std::move(name)); -} +R6 dataset___expr__field_ref(std::string name) { return ds::field_ref(std::move(name)); } // [[arrow::export]] R6 dataset___expr__equal(const std::shared_ptr& lhs, diff --git a/r/src/feather.cpp b/r/src/feather.cpp index 4b16830d106..60a77183aec 100644 --- a/r/src/feather.cpp +++ b/r/src/feather.cpp @@ -22,10 +22,12 @@ #include namespace cpp11 { -template <> inline std::string r6_class_name(const std::shared_ptr& codec) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& codec) { return "FeatherReader"; } -} +} // namespace cpp11 // ---------- WriteFeather diff --git a/r/src/field.cpp b/r/src/field.cpp index da18c2aab6d..e7f24fb5a28 100644 --- a/r/src/field.cpp +++ b/r/src/field.cpp @@ -49,8 +49,6 @@ bool Field__nullable(const std::shared_ptr& field) { } // [[arrow::export]] -R6 Field__type(const std::shared_ptr& field) { - return field->type(); -} +R6 Field__type(const std::shared_ptr& field) { return field->type(); } #endif diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 39037163b04..8141b47478c 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -25,28 +25,40 @@ namespace fs = ::arrow::fs; namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name(const std::shared_ptr& x) { return "FileSelector"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name(const std::shared_ptr& x) { return "FileInfo"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "InputStream"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "OutputStream"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "RandomAccessFile"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "LocalFileSystem"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "SubTreeFileSystem"; } -} +} // namespace cpp11 // [[arrow::export]] fs::FileType fs___FileInfo__type(const std::shared_ptr& x) { @@ -148,7 +160,7 @@ cpp11::list fs___FileSystem__GetTargetInfos_Paths( const std::shared_ptr& file_system, const std::vector& paths) { auto results = ValueOrStop(file_system->GetFileInfo(paths)); - return arrow::r::to_r_list(shared_ptr_vector(results), cpp11::to_r6); + return arrow::r::to_r_list(shared_ptr_vector(results)); } // [[arrow::export]] @@ -157,7 +169,7 @@ cpp11::list fs___FileSystem__GetTargetInfos_FileSelector( const std::shared_ptr& selector) { auto results = ValueOrStop(file_system->GetFileInfo(*selector)); - return arrow::r::to_r_list(shared_ptr_vector(results), cpp11::to_r6); + return arrow::r::to_r_list(shared_ptr_vector(results)); } // [[arrow::export]] @@ -233,9 +245,7 @@ std::string fs___FileSystem__type_name( } // [[arrow::export]] -R6 fs___LocalFileSystem__create() { - return std::make_shared(); -} +R6 fs___LocalFileSystem__create() { return std::make_shared(); } // [[arrow::export]] R6 fs___SubTreeFileSystem__create(const std::string& base_path, diff --git a/r/src/io.cpp b/r/src/io.cpp index 505a9a11aff..f8e002670a5 100644 --- a/r/src/io.cpp +++ b/r/src/io.cpp @@ -22,22 +22,32 @@ #include namespace cpp11 { -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "MemoryMappedFile"; } -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "ReadableFile"; } -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "BufferReader"; } -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "FileOutputStream"; } -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "BufferOutputStream"; } -} +} // namespace cpp11 // ------ arrow::io::Readable diff --git a/r/src/json.cpp b/r/src/json.cpp index 56dc37c6add..5164541d394 100644 --- a/r/src/json.cpp +++ b/r/src/json.cpp @@ -21,17 +21,22 @@ #include namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "JsonReadOptions"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "JsonParseOptions"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "JsonTableReader"; } -} - +} // namespace cpp11 // [[arrow::export]] R6 json___ReadOptions__initialize(bool use_threads, int block_size) { @@ -55,8 +60,8 @@ R6 json___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options) { - return ValueOrStop(arrow::json::TableReader::Make( - gc_memory_pool(), input, *read_options, *parse_options)); + return ValueOrStop(arrow::json::TableReader::Make(gc_memory_pool(), input, + *read_options, *parse_options)); } // [[arrow::export]] diff --git a/r/src/message.cpp b/r/src/message.cpp index 1fbd0db0378..c64418bf573 100644 --- a/r/src/message.cpp +++ b/r/src/message.cpp @@ -22,13 +22,17 @@ #include namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "MessageReader"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "Message"; } -} +} // namespace cpp11 // [[arrow::export]] int64_t ipc___Message__body_length(const std::unique_ptr& message) { diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index c04191d47aa..971b16fe444 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -27,39 +27,51 @@ namespace parquet { class WriterPropertiesBuilder : public WriterProperties::Builder { -public: + public: using WriterProperties::Builder::Builder; }; class ArrowWriterPropertiesBuilder : public ArrowWriterProperties::Builder { -public: + public: using ArrowWriterProperties::Builder::Builder; }; } // namespace parquet namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetArrowReaderProperties"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetArrowWriterProperties"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetWriterProperties"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetFileReader"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetWriterPropertiesBuilder"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "ParquetFileWriter"; } -} +} // namespace cpp11 // [[arrow::export]] R6 parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp index 85f08606da9..8b7a4a781ba 100644 --- a/r/src/recordbatch.cpp +++ b/r/src/recordbatch.cpp @@ -58,7 +58,7 @@ cpp11::list RecordBatch__columns(const std::shared_ptr& batc for (int i = 0; i < nc; i++) { res[i] = batch->column(i); } - return arrow::r::to_r_list(res, cpp11::to_r6); + return arrow::r::to_r_list(res); } // [[arrow::export]] diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp index 807e74305fe..e6aefdd3b56 100644 --- a/r/src/recordbatchreader.cpp +++ b/r/src/recordbatchreader.cpp @@ -22,13 +22,17 @@ #include namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "RecordBatchStreamReader"; } -template <> std::string r6_class_name(const std::shared_ptr& x) { +template <> +std::string r6_class_name( + const std::shared_ptr& x) { return "RecordBatchFileReader"; } -} +} // namespace cpp11 // [[arrow::export]] R6 RecordBatchReader__schema(const std::shared_ptr& reader) { @@ -63,7 +67,7 @@ cpp11::list ipc___RecordBatchStreamReader__batches( res.push_back(batch); } - return arrow::r::to_r_list(res, cpp11::to_r6); + return arrow::r::to_r_list(res); } // -------- RecordBatchFileReader @@ -131,7 +135,7 @@ cpp11::list ipc___RecordBatchFileReader__batches( res[i] = ValueOrStop(reader->ReadRecordBatch(i)); } - return arrow::r::to_r_list(res, cpp11::to_r6); + return arrow::r::to_r_list(res); } #endif diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp index 17a8e672376..efdc4df7c9a 100644 --- a/r/src/recordbatchwriter.cpp +++ b/r/src/recordbatchwriter.cpp @@ -21,10 +21,12 @@ #include namespace cpp11 { -template <> inline std::string r6_class_name(const std::shared_ptr& x) { +template <> +inline std::string r6_class_name( + const std::shared_ptr& x) { return "RecordBatchWriter"; } -} +} // namespace cpp11 // [[arrow::export]] void ipc___RecordBatchWriter__WriteRecordBatch( diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index 357174ace0c..c309e65bfd6 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -26,7 +26,8 @@ namespace cpp11 { -template <> std::string r6_class_name(const std::shared_ptr& ptr) { +template <> +std::string r6_class_name(const std::shared_ptr& ptr) { if (ptr->type->id() == arrow::Type::STRUCT) { return "StructScalar"; } @@ -75,8 +76,6 @@ SEXP Scalar__as_vector(const std::shared_ptr& scalar) { bool Scalar__is_valid(const std::shared_ptr& s) { return s->is_valid; } // [[arrow::export]] -R6 Scalar__type(const std::shared_ptr& s) { - return s->type; -} +R6 Scalar__type(const std::shared_ptr& s) { return s->type; } #endif diff --git a/r/src/schema.cpp b/r/src/schema.cpp index 153da88f8fe..d219c8d5942 100644 --- a/r/src/schema.cpp +++ b/r/src/schema.cpp @@ -53,7 +53,7 @@ R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x // [[arrow::export]] cpp11::list Schema__fields(const std::shared_ptr& schema) { - return arrow::r::to_r_list(schema->fields(), cpp11::to_r6); + return arrow::r::to_r_list(schema->fields()); } // [[arrow::export]] diff --git a/r/src/table.cpp b/r/src/table.cpp index 9a6d4e78e83..4611395cb13 100644 --- a/r/src/table.cpp +++ b/r/src/table.cpp @@ -31,9 +31,7 @@ int Table__num_columns(const std::shared_ptr& x) { int Table__num_rows(const std::shared_ptr& x) { return x->num_rows(); } // [[arrow::export]] -R6 Table__schema(const std::shared_ptr& x) { - return x->schema(); -} +R6 Table__schema(const std::shared_ptr& x) { return x->schema(); } // [[arrow::export]] R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, @@ -64,7 +62,7 @@ cpp11::list Table__columns(const std::shared_ptr& table) { for (int i = 0; i < nc; i++) { res[i] = table->column(i); } - return arrow::r::to_r_list(res, cpp11::to_r6); + return arrow::r::to_r_list(res); } // [[arrow::export]] From 65eae80ea9755dcb5add11f4f547378dce0a0074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Fran=C3=A7ois?= Date: Tue, 10 Nov 2020 09:39:08 +0100 Subject: [PATCH 27/43] Update r/src/arrow_cpp11.h Co-authored-by: Benjamin Kietzman --- r/src/arrow_cpp11.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index fc2c11291ed..a783ed99cdb 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -24,8 +24,6 @@ #include "./nameof.h" -// TODO: move this include up once we can resolve this issue in cpp11 -// https://github.com/apache/arrow/pull/7819#discussion_r471664878 #include // borrowed from enc package From 200940321b8fb970c34d0c8e58d071b1d627091a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Fran=C3=A7ois?= Date: Tue, 10 Nov 2020 09:39:39 +0100 Subject: [PATCH 28/43] Update r/src/arrow_cpp11.h Co-authored-by: Benjamin Kietzman --- r/src/arrow_cpp11.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index a783ed99cdb..fb4c4dca090 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -335,7 +335,7 @@ class R6 { R6(const std::shared_ptr& x) : data_(cpp11::to_r6(x)) {} template - R6(std::unique_ptr x) : data_(cpp11::to_r6(std::shared_ptr(x.release()))) {} + R6(std::unique_ptr x) : data_(cpp11::to_r6(std::move(x))) {} R6(SEXP data) : data_(data) {} From ea30dab47d1c9a0396bfffe728cb46b6d65b035e Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 10 Nov 2020 14:03:03 +0100 Subject: [PATCH 29/43] back to returning the real class, std::shared_ptr<...> instead of the catch-allo R6 --- r/src/array.cpp | 47 ++-- r/src/array_from_vector.cpp | 16 +- r/src/arraydata.cpp | 5 +- r/src/arrowExports.cpp | 418 ++++++++++++++++++------------------ r/src/arrow_cpp11.h | 38 +++- r/src/arrow_exports.h | 5 + r/src/arrow_types.h | 66 +----- r/src/buffer.cpp | 2 +- r/src/chunkedarray.cpp | 20 +- r/src/compression.cpp | 10 +- r/src/compute.cpp | 40 ++-- r/src/csv.cpp | 53 ++--- r/src/dataset.cpp | 177 ++++++--------- r/src/datatype.cpp | 145 +++++++------ r/src/expression.cpp | 72 ++++--- r/src/feather.cpp | 12 +- r/src/field.cpp | 10 +- r/src/filesystem.cpp | 87 +++----- r/src/io.cpp | 63 +++--- r/src/json.cpp | 30 +-- r/src/memorypool.cpp | 2 +- r/src/message.cpp | 36 ++-- r/src/parquet.cpp | 76 +++---- r/src/py-to-r.cpp | 9 +- r/src/recordbatch.cpp | 33 +-- r/src/recordbatchreader.cpp | 32 ++- r/src/recordbatchwriter.cpp | 12 +- r/src/scalar.cpp | 22 +- r/src/schema.cpp | 16 +- r/src/table.cpp | 45 ++-- 30 files changed, 741 insertions(+), 858 deletions(-) diff --git a/r/src/array.cpp b/r/src/array.cpp index 39d0c524bb2..f2344ae18b7 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -25,7 +25,7 @@ namespace cpp11 { template <> -std::string r6_class_name(const std::shared_ptr& array) { +const char* r6_class_name(const std::shared_ptr& array) { auto type = array->type_id(); switch (type) { case arrow::Type::DICTIONARY: @@ -71,14 +71,15 @@ void arrow::r::validate_slice_length(R_xlen_t length, int64_t available) { } // [[arrow::export]] -R6 Array__Slice1(const std::shared_ptr& array, R_xlen_t offset) { +std::shared_ptr Array__Slice1(const std::shared_ptr& array, + R_xlen_t offset) { arrow::r::validate_slice_offset(offset, array->length()); return array->Slice(offset); } // [[arrow::export]] -R6 Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, - R_xlen_t length) { +std::shared_ptr Array__Slice2(const std::shared_ptr& array, + R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, array->length()); arrow::r::validate_slice_length(length, array->length() - offset); return array->Slice(offset, length); @@ -115,7 +116,9 @@ int Array__offset(const std::shared_ptr& x) { return x->offset(); int Array__null_count(const std::shared_ptr& x) { return x->null_count(); } // [[arrow::export]] -R6 Array__type(const std::shared_ptr& x) { return x->type(); } +std::shared_ptr Array__type(const std::shared_ptr& x) { + return x->type(); +} // [[arrow::export]] std::string Array__ToString(const std::shared_ptr& x) { @@ -140,7 +143,10 @@ bool Array__ApproxEquals(const std::shared_ptr& lhs, } // [[arrow::export]] -R6 Array__data(const std::shared_ptr& array) { return array->data(); } +std::shared_ptr Array__data( + const std::shared_ptr& array) { + return array->data(); +} // [[arrow::export]] bool Array__RangeEquals(const std::shared_ptr& self, @@ -159,8 +165,8 @@ bool Array__RangeEquals(const std::shared_ptr& self, } // [[arrow::export]] -R6 Array__View(const std::shared_ptr& array, - const std::shared_ptr& type) { +std::shared_ptr Array__View(const std::shared_ptr& array, + const std::shared_ptr& type) { return ValueOrStop(array->View(type)); } @@ -170,23 +176,26 @@ void Array__Validate(const std::shared_ptr& array) { } // [[arrow::export]] -R6 DictionaryArray__indices(const std::shared_ptr& array) { +std::shared_ptr DictionaryArray__indices( + const std::shared_ptr& array) { return array->indices(); } // [[arrow::export]] -R6 DictionaryArray__dictionary(const std::shared_ptr& array) { +std::shared_ptr DictionaryArray__dictionary( + const std::shared_ptr& array) { return array->dictionary(); } // [[arrow::export]] -R6 StructArray__field(const std::shared_ptr& array, int i) { +std::shared_ptr StructArray__field( + const std::shared_ptr& array, int i) { return array->field(i); } // [[arrow::export]] -R6 StructArray__GetFieldByName(const std::shared_ptr& array, - const std::string& name) { +std::shared_ptr StructArray__GetFieldByName( + const std::shared_ptr& array, const std::string& name) { return array->GetFieldByName(name); } @@ -196,22 +205,26 @@ cpp11::list StructArray__Flatten(const std::shared_ptr& arra } // [[arrow::export]] -R6 ListArray__value_type(const std::shared_ptr& array) { +std::shared_ptr ListArray__value_type( + const std::shared_ptr& array) { return array->value_type(); } // [[arrow::export]] -R6 LargeListArray__value_type(const std::shared_ptr& array) { +std::shared_ptr LargeListArray__value_type( + const std::shared_ptr& array) { return array->value_type(); } // [[arrow::export]] -R6 ListArray__values(const std::shared_ptr& array) { +std::shared_ptr ListArray__values( + const std::shared_ptr& array) { return array->values(); } // [[arrow::export]] -R6 LargeListArray__values(const std::shared_ptr& array) { +std::shared_ptr LargeListArray__values( + const std::shared_ptr& array) { return array->values(); } diff --git a/r/src/array_from_vector.cpp b/r/src/array_from_vector.cpp index 6523d102a12..c2d22868535 100644 --- a/r/src/array_from_vector.cpp +++ b/r/src/array_from_vector.cpp @@ -1528,10 +1528,12 @@ std::shared_ptr Array__from_vector( } // namespace arrow // [[arrow::export]] -R6 Array__infer_type(SEXP x) { return arrow::r::InferArrowType(x); } +std::shared_ptr Array__infer_type(SEXP x) { + return arrow::r::InferArrowType(x); +} // [[arrow::export]] -R6 Array__from_vector(SEXP x, SEXP s_type) { +std::shared_ptr Array__from_vector(SEXP x, SEXP s_type) { // the type might be NULL, in which case we need to infer it from the data // we keep track of whether it was inferred or supplied bool type_inferred = Rf_isNull(s_type); @@ -1546,7 +1548,8 @@ R6 Array__from_vector(SEXP x, SEXP s_type) { } // [[arrow::export]] -R6 ChunkedArray__from_list(cpp11::list chunks, SEXP s_type) { +std::shared_ptr ChunkedArray__from_list(cpp11::list chunks, + SEXP s_type) { std::vector> vec; // the type might be NULL, in which case we need to infer it from the data @@ -1586,9 +1589,10 @@ R6 ChunkedArray__from_list(cpp11::list chunks, SEXP s_type) { } // [[arrow::export]] -R6 DictionaryArray__FromArrays(const std::shared_ptr& type, - const std::shared_ptr& indices, - const std::shared_ptr& dict) { +std::shared_ptr DictionaryArray__FromArrays( + const std::shared_ptr& type, + const std::shared_ptr& indices, + const std::shared_ptr& dict) { return ValueOrStop(arrow::DictionaryArray::FromArrays(type, indices, dict)); } diff --git a/r/src/arraydata.cpp b/r/src/arraydata.cpp index 80f42fde6df..179532a6437 100644 --- a/r/src/arraydata.cpp +++ b/r/src/arraydata.cpp @@ -21,7 +21,10 @@ #include // [[arrow::export]] -R6 ArrayData__get_type(const std::shared_ptr& x) { return x->type; } +std::shared_ptr ArrayData__get_type( + const std::shared_ptr& x) { + return x->type; +} // [[arrow::export]] int ArrayData__get_length(const std::shared_ptr& x) { diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index bc36001cea7..df694f1a276 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -6,7 +6,7 @@ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__Slice1(const std::shared_ptr& array, R_xlen_t offset); +std::shared_ptr Array__Slice1(const std::shared_ptr& array, R_xlen_t offset); extern "C" SEXP _arrow_Array__Slice1(SEXP array_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -22,7 +22,7 @@ extern "C" SEXP _arrow_Array__Slice1(SEXP array_sexp, SEXP offset_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, R_xlen_t length); +std::shared_ptr Array__Slice2(const std::shared_ptr& array, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_Array__Slice2(SEXP array_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -116,7 +116,7 @@ extern "C" SEXP _arrow_Array__null_count(SEXP x_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__type(const std::shared_ptr& x); +std::shared_ptr Array__type(const std::shared_ptr& x); extern "C" SEXP _arrow_Array__type(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -193,7 +193,7 @@ extern "C" SEXP _arrow_Array__ApproxEquals(SEXP lhs_sexp, SEXP rhs_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__data(const std::shared_ptr& array); +std::shared_ptr Array__data(const std::shared_ptr& array); extern "C" SEXP _arrow_Array__data(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -227,7 +227,7 @@ extern "C" SEXP _arrow_Array__RangeEquals(SEXP self_sexp, SEXP other_sexp, SEXP // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__View(const std::shared_ptr& array, const std::shared_ptr& type); +std::shared_ptr Array__View(const std::shared_ptr& array, const std::shared_ptr& type); extern "C" SEXP _arrow_Array__View(SEXP array_sexp, SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -259,7 +259,7 @@ extern "C" SEXP _arrow_Array__Validate(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 DictionaryArray__indices(const std::shared_ptr& array); +std::shared_ptr DictionaryArray__indices(const std::shared_ptr& array); extern "C" SEXP _arrow_DictionaryArray__indices(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -274,7 +274,7 @@ extern "C" SEXP _arrow_DictionaryArray__indices(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 DictionaryArray__dictionary(const std::shared_ptr& array); +std::shared_ptr DictionaryArray__dictionary(const std::shared_ptr& array); extern "C" SEXP _arrow_DictionaryArray__dictionary(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -289,7 +289,7 @@ extern "C" SEXP _arrow_DictionaryArray__dictionary(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 StructArray__field(const std::shared_ptr& array, int i); +std::shared_ptr StructArray__field(const std::shared_ptr& array, int i); extern "C" SEXP _arrow_StructArray__field(SEXP array_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -305,7 +305,7 @@ extern "C" SEXP _arrow_StructArray__field(SEXP array_sexp, SEXP i_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 StructArray__GetFieldByName(const std::shared_ptr& array, const std::string& name); +std::shared_ptr StructArray__GetFieldByName(const std::shared_ptr& array, const std::string& name); extern "C" SEXP _arrow_StructArray__GetFieldByName(SEXP array_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -336,7 +336,7 @@ extern "C" SEXP _arrow_StructArray__Flatten(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ListArray__value_type(const std::shared_ptr& array); +std::shared_ptr ListArray__value_type(const std::shared_ptr& array); extern "C" SEXP _arrow_ListArray__value_type(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -351,7 +351,7 @@ extern "C" SEXP _arrow_ListArray__value_type(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 LargeListArray__value_type(const std::shared_ptr& array); +std::shared_ptr LargeListArray__value_type(const std::shared_ptr& array); extern "C" SEXP _arrow_LargeListArray__value_type(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -366,7 +366,7 @@ extern "C" SEXP _arrow_LargeListArray__value_type(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ListArray__values(const std::shared_ptr& array); +std::shared_ptr ListArray__values(const std::shared_ptr& array); extern "C" SEXP _arrow_ListArray__values(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -381,7 +381,7 @@ extern "C" SEXP _arrow_ListArray__values(SEXP array_sexp){ // array.cpp #if defined(ARROW_R_WITH_ARROW) -R6 LargeListArray__values(const std::shared_ptr& array); +std::shared_ptr LargeListArray__values(const std::shared_ptr& array); extern "C" SEXP _arrow_LargeListArray__values(SEXP array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -522,7 +522,7 @@ extern "C" SEXP _arrow_LargeListArray__raw_value_offsets(SEXP array_sexp){ // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__infer_type(SEXP x); +std::shared_ptr Array__infer_type(SEXP x); extern "C" SEXP _arrow_Array__infer_type(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -537,7 +537,7 @@ extern "C" SEXP _arrow_Array__infer_type(SEXP x_sexp){ // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__from_vector(SEXP x, SEXP s_type); +std::shared_ptr Array__from_vector(SEXP x, SEXP s_type); extern "C" SEXP _arrow_Array__from_vector(SEXP x_sexp, SEXP s_type_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -553,7 +553,7 @@ extern "C" SEXP _arrow_Array__from_vector(SEXP x_sexp, SEXP s_type_sexp){ // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__from_list(cpp11::list chunks, SEXP s_type); +std::shared_ptr ChunkedArray__from_list(cpp11::list chunks, SEXP s_type); extern "C" SEXP _arrow_ChunkedArray__from_list(SEXP chunks_sexp, SEXP s_type_sexp){ BEGIN_CPP11 arrow::r::Input::type chunks(chunks_sexp); @@ -569,7 +569,7 @@ extern "C" SEXP _arrow_ChunkedArray__from_list(SEXP chunks_sexp, SEXP s_type_sex // array_from_vector.cpp #if defined(ARROW_R_WITH_ARROW) -R6 DictionaryArray__FromArrays(const std::shared_ptr& type, const std::shared_ptr& indices, const std::shared_ptr& dict); +std::shared_ptr DictionaryArray__FromArrays(const std::shared_ptr& type, const std::shared_ptr& indices, const std::shared_ptr& dict); extern "C" SEXP _arrow_DictionaryArray__FromArrays(SEXP type_sexp, SEXP indices_sexp, SEXP dict_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -648,7 +648,7 @@ extern "C" SEXP _arrow_Table__to_dataframe(SEXP table_sexp, SEXP use_threads_sex // arraydata.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ArrayData__get_type(const std::shared_ptr& x); +std::shared_ptr ArrayData__get_type(const std::shared_ptr& x); extern "C" SEXP _arrow_ArrayData__get_type(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -784,7 +784,7 @@ extern "C" SEXP _arrow_Buffer__size(SEXP buffer_sexp){ // buffer.cpp #if defined(ARROW_R_WITH_ARROW) -R6 r___RBuffer__initialize(SEXP x); +std::shared_ptr r___RBuffer__initialize(SEXP x); extern "C" SEXP _arrow_r___RBuffer__initialize(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -875,7 +875,7 @@ extern "C" SEXP _arrow_ChunkedArray__num_chunks(SEXP chunked_array_sexp){ // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i); +std::shared_ptr ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i); extern "C" SEXP _arrow_ChunkedArray__chunk(SEXP chunked_array_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -906,7 +906,7 @@ extern "C" SEXP _arrow_ChunkedArray__chunks(SEXP chunked_array_sexp){ // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__type(const std::shared_ptr& chunked_array); +std::shared_ptr ChunkedArray__type(const std::shared_ptr& chunked_array); extern "C" SEXP _arrow_ChunkedArray__type(SEXP chunked_array_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -921,7 +921,7 @@ extern "C" SEXP _arrow_ChunkedArray__type(SEXP chunked_array_sexp){ // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__Slice1(const std::shared_ptr& chunked_array, R_xlen_t offset); +std::shared_ptr ChunkedArray__Slice1(const std::shared_ptr& chunked_array, R_xlen_t offset); extern "C" SEXP _arrow_ChunkedArray__Slice1(SEXP chunked_array_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -937,7 +937,7 @@ extern "C" SEXP _arrow_ChunkedArray__Slice1(SEXP chunked_array_sexp, SEXP offset // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__Slice2(const std::shared_ptr& chunked_array, R_xlen_t offset, R_xlen_t length); +std::shared_ptr ChunkedArray__Slice2(const std::shared_ptr& chunked_array, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_ChunkedArray__Slice2(SEXP chunked_array_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -954,7 +954,7 @@ extern "C" SEXP _arrow_ChunkedArray__Slice2(SEXP chunked_array_sexp, SEXP offset // chunkedarray.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__View(const std::shared_ptr& array, const std::shared_ptr& type); +std::shared_ptr ChunkedArray__View(const std::shared_ptr& array, const std::shared_ptr& type); extern "C" SEXP _arrow_ChunkedArray__View(SEXP array_sexp, SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -1017,7 +1017,7 @@ extern "C" SEXP _arrow_ChunkedArray__ToString(SEXP x_sexp){ // compression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level); +std::shared_ptr util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level); extern "C" SEXP _arrow_util___Codec__Create(SEXP codec_sexp, SEXP compression_level_sexp){ BEGIN_CPP11 arrow::r::Input::type codec(codec_sexp); @@ -1063,7 +1063,7 @@ extern "C" SEXP _arrow_util___Codec__IsAvailable(SEXP codec_sexp){ // compression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___CompressedOutputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); +std::shared_ptr io___CompressedOutputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); extern "C" SEXP _arrow_io___CompressedOutputStream__Make(SEXP codec_sexp, SEXP raw_sexp){ BEGIN_CPP11 arrow::r::Input&>::type codec(codec_sexp); @@ -1079,7 +1079,7 @@ extern "C" SEXP _arrow_io___CompressedOutputStream__Make(SEXP codec_sexp, SEXP r // compression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___CompressedInputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); +std::shared_ptr io___CompressedInputStream__Make(const std::shared_ptr& codec, const std::shared_ptr& raw); extern "C" SEXP _arrow_io___CompressedInputStream__Make(SEXP codec_sexp, SEXP raw_sexp){ BEGIN_CPP11 arrow::r::Input&>::type codec(codec_sexp); @@ -1095,7 +1095,7 @@ extern "C" SEXP _arrow_io___CompressedInputStream__Make(SEXP codec_sexp, SEXP ra // compute.cpp #if defined(ARROW_R_WITH_ARROW) -R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_truncate, bool allow_float_truncate); +std::shared_ptr compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_truncate, bool allow_float_truncate); extern "C" SEXP _arrow_compute___CastOptions__initialize(SEXP allow_int_overflow_sexp, SEXP allow_time_truncate_sexp, SEXP allow_float_truncate_sexp){ BEGIN_CPP11 arrow::r::Input::type allow_int_overflow(allow_int_overflow_sexp); @@ -1112,7 +1112,7 @@ extern "C" SEXP _arrow_compute___CastOptions__initialize(SEXP allow_int_overflow // compute.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__cast(const std::shared_ptr& array, const std::shared_ptr& target_type, const std::shared_ptr& options); +std::shared_ptr Array__cast(const std::shared_ptr& array, const std::shared_ptr& target_type, const std::shared_ptr& options); extern "C" SEXP _arrow_Array__cast(SEXP array_sexp, SEXP target_type_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type array(array_sexp); @@ -1129,7 +1129,7 @@ extern "C" SEXP _arrow_Array__cast(SEXP array_sexp, SEXP target_type_sexp, SEXP // compute.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, const std::shared_ptr& target_type, const std::shared_ptr& options); +std::shared_ptr ChunkedArray__cast(const std::shared_ptr& chunked_array, const std::shared_ptr& target_type, const std::shared_ptr& options); extern "C" SEXP _arrow_ChunkedArray__cast(SEXP chunked_array_sexp, SEXP target_type_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type chunked_array(chunked_array_sexp); @@ -1146,7 +1146,7 @@ extern "C" SEXP _arrow_ChunkedArray__cast(SEXP chunked_array_sexp, SEXP target_t // compute.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__cast(const std::shared_ptr& batch, const std::shared_ptr& schema, const std::shared_ptr& options); +std::shared_ptr RecordBatch__cast(const std::shared_ptr& batch, const std::shared_ptr& schema, const std::shared_ptr& options); extern "C" SEXP _arrow_RecordBatch__cast(SEXP batch_sexp, SEXP schema_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -1163,7 +1163,7 @@ extern "C" SEXP _arrow_RecordBatch__cast(SEXP batch_sexp, SEXP schema_sexp, SEXP // compute.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__cast(const std::shared_ptr& table, const std::shared_ptr& schema, const std::shared_ptr& options); +std::shared_ptr Table__cast(const std::shared_ptr& table, const std::shared_ptr& schema, const std::shared_ptr& options); extern "C" SEXP _arrow_Table__cast(SEXP table_sexp, SEXP schema_sexp, SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -1197,7 +1197,7 @@ extern "C" SEXP _arrow_compute__CallFunction(SEXP func_name_sexp, SEXP args_sexp // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 csv___ReadOptions__initialize(cpp11::list options); +std::shared_ptr csv___ReadOptions__initialize(cpp11::list options); extern "C" SEXP _arrow_csv___ReadOptions__initialize(SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input::type options(options_sexp); @@ -1212,7 +1212,7 @@ extern "C" SEXP _arrow_csv___ReadOptions__initialize(SEXP options_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 csv___ParseOptions__initialize(cpp11::list options); +std::shared_ptr csv___ParseOptions__initialize(cpp11::list options); extern "C" SEXP _arrow_csv___ParseOptions__initialize(SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input::type options(options_sexp); @@ -1242,7 +1242,7 @@ extern "C" SEXP _arrow_csv___ReadOptions__column_names(SEXP options_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 csv___ConvertOptions__initialize(cpp11::list options); +std::shared_ptr csv___ConvertOptions__initialize(cpp11::list options); extern "C" SEXP _arrow_csv___ConvertOptions__initialize(SEXP options_sexp){ BEGIN_CPP11 arrow::r::Input::type options(options_sexp); @@ -1257,7 +1257,7 @@ extern "C" SEXP _arrow_csv___ConvertOptions__initialize(SEXP options_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 csv___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options); +std::shared_ptr csv___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options, const std::shared_ptr& convert_options); extern "C" SEXP _arrow_csv___TableReader__Make(SEXP input_sexp, SEXP read_options_sexp, SEXP parse_options_sexp, SEXP convert_options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type input(input_sexp); @@ -1275,7 +1275,7 @@ extern "C" SEXP _arrow_csv___TableReader__Make(SEXP input_sexp, SEXP read_option // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 csv___TableReader__Read(const std::shared_ptr& table_reader); +std::shared_ptr csv___TableReader__Read(const std::shared_ptr& table_reader); extern "C" SEXP _arrow_csv___TableReader__Read(SEXP table_reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table_reader(table_reader_sexp); @@ -1320,7 +1320,7 @@ extern "C" SEXP _arrow_TimestampParser__format(SEXP parser_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 TimestampParser__MakeStrptime(std::string format); +std::shared_ptr TimestampParser__MakeStrptime(std::string format); extern "C" SEXP _arrow_TimestampParser__MakeStrptime(SEXP format_sexp){ BEGIN_CPP11 arrow::r::Input::type format(format_sexp); @@ -1335,7 +1335,7 @@ extern "C" SEXP _arrow_TimestampParser__MakeStrptime(SEXP format_sexp){ // csv.cpp #if defined(ARROW_R_WITH_ARROW) -R6 TimestampParser__MakeISO8601(); +std::shared_ptr TimestampParser__MakeISO8601(); extern "C" SEXP _arrow_TimestampParser__MakeISO8601(){ BEGIN_CPP11 return cpp11::as_sexp(TimestampParser__MakeISO8601()); @@ -1349,7 +1349,7 @@ extern "C" SEXP _arrow_TimestampParser__MakeISO8601(){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___Dataset__NewScan(const std::shared_ptr& ds); +std::shared_ptr dataset___Dataset__NewScan(const std::shared_ptr& ds); extern "C" SEXP _arrow_dataset___Dataset__NewScan(SEXP ds_sexp){ BEGIN_CPP11 arrow::r::Input&>::type ds(ds_sexp); @@ -1364,7 +1364,7 @@ extern "C" SEXP _arrow_dataset___Dataset__NewScan(SEXP ds_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___Dataset__schema(const std::shared_ptr& dataset); +std::shared_ptr dataset___Dataset__schema(const std::shared_ptr& dataset); extern "C" SEXP _arrow_dataset___Dataset__schema(SEXP dataset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1394,7 +1394,7 @@ extern "C" SEXP _arrow_dataset___Dataset__type_name(SEXP dataset_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, const std::shared_ptr& schm); +std::shared_ptr dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___Dataset__ReplaceSchema(SEXP dataset_sexp, SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1410,7 +1410,7 @@ extern "C" SEXP _arrow_dataset___Dataset__ReplaceSchema(SEXP dataset_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___UnionDataset__create(const ds::DatasetVector& datasets, const std::shared_ptr& schm); +std::shared_ptr dataset___UnionDataset__create(const ds::DatasetVector& datasets, const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___UnionDataset__create(SEXP datasets_sexp, SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input::type datasets(datasets_sexp); @@ -1426,7 +1426,7 @@ extern "C" SEXP _arrow_dataset___UnionDataset__create(SEXP datasets_sexp, SEXP s // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___InMemoryDataset__create(const std::shared_ptr& table); +std::shared_ptr dataset___InMemoryDataset__create(const std::shared_ptr& table); extern "C" SEXP _arrow_dataset___InMemoryDataset__create(SEXP table_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -1456,7 +1456,7 @@ extern "C" SEXP _arrow_dataset___UnionDataset__children(SEXP ds_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___FileSystemDataset__format(const std::shared_ptr& dataset); +std::shared_ptr dataset___FileSystemDataset__format(const std::shared_ptr& dataset); extern "C" SEXP _arrow_dataset___FileSystemDataset__format(SEXP dataset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1471,7 +1471,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDataset__format(SEXP dataset_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___FileSystemDataset__filesystem(const std::shared_ptr& dataset); +std::shared_ptr dataset___FileSystemDataset__filesystem(const std::shared_ptr& dataset); extern "C" SEXP _arrow_dataset___FileSystemDataset__filesystem(SEXP dataset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type dataset(dataset_sexp); @@ -1501,7 +1501,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDataset__files(SEXP dataset_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___DatasetFactory__Finish1(const std::shared_ptr& factory, bool unify_schemas); +std::shared_ptr dataset___DatasetFactory__Finish1(const std::shared_ptr& factory, bool unify_schemas); extern "C" SEXP _arrow_dataset___DatasetFactory__Finish1(SEXP factory_sexp, SEXP unify_schemas_sexp){ BEGIN_CPP11 arrow::r::Input&>::type factory(factory_sexp); @@ -1517,7 +1517,7 @@ extern "C" SEXP _arrow_dataset___DatasetFactory__Finish1(SEXP factory_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, const std::shared_ptr& schema); +std::shared_ptr dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, const std::shared_ptr& schema); extern "C" SEXP _arrow_dataset___DatasetFactory__Finish2(SEXP factory_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type factory(factory_sexp); @@ -1533,7 +1533,7 @@ extern "C" SEXP _arrow_dataset___DatasetFactory__Finish2(SEXP factory_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___DatasetFactory__Inspect(const std::shared_ptr& factory, bool unify_schemas); +std::shared_ptr dataset___DatasetFactory__Inspect(const std::shared_ptr& factory, bool unify_schemas); extern "C" SEXP _arrow_dataset___DatasetFactory__Inspect(SEXP factory_sexp, SEXP unify_schemas_sexp){ BEGIN_CPP11 arrow::r::Input&>::type factory(factory_sexp); @@ -1549,7 +1549,7 @@ extern "C" SEXP _arrow_dataset___DatasetFactory__Inspect(SEXP factory_sexp, SEXP // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___UnionDatasetFactory__Make(const std::vector>& children); +std::shared_ptr dataset___UnionDatasetFactory__Make(const std::vector>& children); extern "C" SEXP _arrow_dataset___UnionDatasetFactory__Make(SEXP children_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type children(children_sexp); @@ -1564,7 +1564,7 @@ extern "C" SEXP _arrow_dataset___UnionDatasetFactory__Make(SEXP children_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___FileSystemDatasetFactory__Make2(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& partitioning); +std::shared_ptr dataset___FileSystemDatasetFactory__Make2(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& partitioning); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make2(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp, SEXP partitioning_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1582,7 +1582,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make2(SEXP fs_sexp, S // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___FileSystemDatasetFactory__Make1(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format); +std::shared_ptr dataset___FileSystemDatasetFactory__Make1(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make1(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1599,7 +1599,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make1(SEXP fs_sexp, S // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___FileSystemDatasetFactory__Make3(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& factory); +std::shared_ptr dataset___FileSystemDatasetFactory__Make3(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& factory); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make3(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp, SEXP factory_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1632,7 +1632,7 @@ extern "C" SEXP _arrow_dataset___FileFormat__type_name(SEXP format_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt); +std::shared_ptr dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt); extern "C" SEXP _arrow_dataset___FileFormat__DefaultWriteOptions(SEXP fmt_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fmt(fmt_sexp); @@ -1647,7 +1647,7 @@ extern "C" SEXP _arrow_dataset___FileFormat__DefaultWriteOptions(SEXP fmt_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___ParquetFileFormat__Make(bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns); +std::shared_ptr dataset___ParquetFileFormat__Make(bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns); extern "C" SEXP _arrow_dataset___ParquetFileFormat__Make(SEXP use_buffered_stream_sexp, SEXP buffer_size_sexp, SEXP dict_columns_sexp){ BEGIN_CPP11 arrow::r::Input::type use_buffered_stream(use_buffered_stream_sexp); @@ -1734,7 +1734,7 @@ extern "C" SEXP _arrow_dataset___IpcFileWriteOptions__update1(SEXP ipc_options_s // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___IpcFileFormat__Make(); +std::shared_ptr dataset___IpcFileFormat__Make(); extern "C" SEXP _arrow_dataset___IpcFileFormat__Make(){ BEGIN_CPP11 return cpp11::as_sexp(dataset___IpcFileFormat__Make()); @@ -1748,7 +1748,7 @@ extern "C" SEXP _arrow_dataset___IpcFileFormat__Make(){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___CsvFileFormat__Make(const std::shared_ptr& parse_options); +std::shared_ptr dataset___CsvFileFormat__Make(const std::shared_ptr& parse_options); extern "C" SEXP _arrow_dataset___CsvFileFormat__Make(SEXP parse_options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type parse_options(parse_options_sexp); @@ -1763,7 +1763,7 @@ extern "C" SEXP _arrow_dataset___CsvFileFormat__Make(SEXP parse_options_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___DirectoryPartitioning(const std::shared_ptr& schm); +std::shared_ptr dataset___DirectoryPartitioning(const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___DirectoryPartitioning(SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schm(schm_sexp); @@ -1778,7 +1778,7 @@ extern "C" SEXP _arrow_dataset___DirectoryPartitioning(SEXP schm_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___DirectoryPartitioning__MakeFactory(const std::vector& field_names); +std::shared_ptr dataset___DirectoryPartitioning__MakeFactory(const std::vector& field_names); extern "C" SEXP _arrow_dataset___DirectoryPartitioning__MakeFactory(SEXP field_names_sexp){ BEGIN_CPP11 arrow::r::Input&>::type field_names(field_names_sexp); @@ -1793,7 +1793,7 @@ extern "C" SEXP _arrow_dataset___DirectoryPartitioning__MakeFactory(SEXP field_n // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___HivePartitioning(const std::shared_ptr& schm); +std::shared_ptr dataset___HivePartitioning(const std::shared_ptr& schm); extern "C" SEXP _arrow_dataset___HivePartitioning(SEXP schm_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schm(schm_sexp); @@ -1808,7 +1808,7 @@ extern "C" SEXP _arrow_dataset___HivePartitioning(SEXP schm_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___HivePartitioning__MakeFactory(); +std::shared_ptr dataset___HivePartitioning__MakeFactory(); extern "C" SEXP _arrow_dataset___HivePartitioning__MakeFactory(){ BEGIN_CPP11 return cpp11::as_sexp(dataset___HivePartitioning__MakeFactory()); @@ -1890,7 +1890,7 @@ extern "C" SEXP _arrow_dataset___ScannerBuilder__BatchSize(SEXP sb_sexp, SEXP ba // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___ScannerBuilder__schema(const std::shared_ptr& sb); +std::shared_ptr dataset___ScannerBuilder__schema(const std::shared_ptr& sb); extern "C" SEXP _arrow_dataset___ScannerBuilder__schema(SEXP sb_sexp){ BEGIN_CPP11 arrow::r::Input&>::type sb(sb_sexp); @@ -1905,7 +1905,7 @@ extern "C" SEXP _arrow_dataset___ScannerBuilder__schema(SEXP sb_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___ScannerBuilder__Finish(const std::shared_ptr& sb); +std::shared_ptr dataset___ScannerBuilder__Finish(const std::shared_ptr& sb); extern "C" SEXP _arrow_dataset___ScannerBuilder__Finish(SEXP sb_sexp){ BEGIN_CPP11 arrow::r::Input&>::type sb(sb_sexp); @@ -1920,7 +1920,7 @@ extern "C" SEXP _arrow_dataset___ScannerBuilder__Finish(SEXP sb_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___Scanner__ToTable(const std::shared_ptr& scanner); +std::shared_ptr dataset___Scanner__ToTable(const std::shared_ptr& scanner); extern "C" SEXP _arrow_dataset___Scanner__ToTable(SEXP scanner_sexp){ BEGIN_CPP11 arrow::r::Input&>::type scanner(scanner_sexp); @@ -1935,7 +1935,7 @@ extern "C" SEXP _arrow_dataset___Scanner__ToTable(SEXP scanner_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___Scanner__head(const std::shared_ptr& scanner, int n); +std::shared_ptr dataset___Scanner__head(const std::shared_ptr& scanner, int n); extern "C" SEXP _arrow_dataset___Scanner__head(SEXP scanner_sexp, SEXP n_sexp){ BEGIN_CPP11 arrow::r::Input&>::type scanner(scanner_sexp); @@ -1966,7 +1966,7 @@ extern "C" SEXP _arrow_dataset___Scanner__Scan(SEXP scanner_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___Scanner__schema(const std::shared_ptr& sc); +std::shared_ptr dataset___Scanner__schema(const std::shared_ptr& sc); extern "C" SEXP _arrow_dataset___Scanner__schema(SEXP sc_sexp){ BEGIN_CPP11 arrow::r::Input&>::type sc(sc_sexp); @@ -2017,7 +2017,7 @@ extern "C" SEXP _arrow_dataset___Dataset__Write(SEXP file_write_options_sexp, SE // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Int8__initialize(); +std::shared_ptr Int8__initialize(); extern "C" SEXP _arrow_Int8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int8__initialize()); @@ -2031,7 +2031,7 @@ extern "C" SEXP _arrow_Int8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Int16__initialize(); +std::shared_ptr Int16__initialize(); extern "C" SEXP _arrow_Int16__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int16__initialize()); @@ -2045,7 +2045,7 @@ extern "C" SEXP _arrow_Int16__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Int32__initialize(); +std::shared_ptr Int32__initialize(); extern "C" SEXP _arrow_Int32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int32__initialize()); @@ -2059,7 +2059,7 @@ extern "C" SEXP _arrow_Int32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Int64__initialize(); +std::shared_ptr Int64__initialize(); extern "C" SEXP _arrow_Int64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Int64__initialize()); @@ -2073,7 +2073,7 @@ extern "C" SEXP _arrow_Int64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 UInt8__initialize(); +std::shared_ptr UInt8__initialize(); extern "C" SEXP _arrow_UInt8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt8__initialize()); @@ -2087,7 +2087,7 @@ extern "C" SEXP _arrow_UInt8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 UInt16__initialize(); +std::shared_ptr UInt16__initialize(); extern "C" SEXP _arrow_UInt16__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt16__initialize()); @@ -2101,7 +2101,7 @@ extern "C" SEXP _arrow_UInt16__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 UInt32__initialize(); +std::shared_ptr UInt32__initialize(); extern "C" SEXP _arrow_UInt32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt32__initialize()); @@ -2115,7 +2115,7 @@ extern "C" SEXP _arrow_UInt32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 UInt64__initialize(); +std::shared_ptr UInt64__initialize(); extern "C" SEXP _arrow_UInt64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(UInt64__initialize()); @@ -2129,7 +2129,7 @@ extern "C" SEXP _arrow_UInt64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Float16__initialize(); +std::shared_ptr Float16__initialize(); extern "C" SEXP _arrow_Float16__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Float16__initialize()); @@ -2143,7 +2143,7 @@ extern "C" SEXP _arrow_Float16__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Float32__initialize(); +std::shared_ptr Float32__initialize(); extern "C" SEXP _arrow_Float32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Float32__initialize()); @@ -2157,7 +2157,7 @@ extern "C" SEXP _arrow_Float32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Float64__initialize(); +std::shared_ptr Float64__initialize(); extern "C" SEXP _arrow_Float64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Float64__initialize()); @@ -2171,7 +2171,7 @@ extern "C" SEXP _arrow_Float64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Boolean__initialize(); +std::shared_ptr Boolean__initialize(); extern "C" SEXP _arrow_Boolean__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Boolean__initialize()); @@ -2185,7 +2185,7 @@ extern "C" SEXP _arrow_Boolean__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Utf8__initialize(); +std::shared_ptr Utf8__initialize(); extern "C" SEXP _arrow_Utf8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Utf8__initialize()); @@ -2199,7 +2199,7 @@ extern "C" SEXP _arrow_Utf8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 LargeUtf8__initialize(); +std::shared_ptr LargeUtf8__initialize(); extern "C" SEXP _arrow_LargeUtf8__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(LargeUtf8__initialize()); @@ -2213,7 +2213,7 @@ extern "C" SEXP _arrow_LargeUtf8__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Binary__initialize(); +std::shared_ptr Binary__initialize(); extern "C" SEXP _arrow_Binary__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Binary__initialize()); @@ -2227,7 +2227,7 @@ extern "C" SEXP _arrow_Binary__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 LargeBinary__initialize(); +std::shared_ptr LargeBinary__initialize(); extern "C" SEXP _arrow_LargeBinary__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(LargeBinary__initialize()); @@ -2241,7 +2241,7 @@ extern "C" SEXP _arrow_LargeBinary__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Date32__initialize(); +std::shared_ptr Date32__initialize(); extern "C" SEXP _arrow_Date32__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Date32__initialize()); @@ -2255,7 +2255,7 @@ extern "C" SEXP _arrow_Date32__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Date64__initialize(); +std::shared_ptr Date64__initialize(); extern "C" SEXP _arrow_Date64__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Date64__initialize()); @@ -2269,7 +2269,7 @@ extern "C" SEXP _arrow_Date64__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Null__initialize(); +std::shared_ptr Null__initialize(); extern "C" SEXP _arrow_Null__initialize(){ BEGIN_CPP11 return cpp11::as_sexp(Null__initialize()); @@ -2283,7 +2283,7 @@ extern "C" SEXP _arrow_Null__initialize(){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Decimal128Type__initialize(int32_t precision, int32_t scale); +std::shared_ptr Decimal128Type__initialize(int32_t precision, int32_t scale); extern "C" SEXP _arrow_Decimal128Type__initialize(SEXP precision_sexp, SEXP scale_sexp){ BEGIN_CPP11 arrow::r::Input::type precision(precision_sexp); @@ -2299,7 +2299,7 @@ extern "C" SEXP _arrow_Decimal128Type__initialize(SEXP precision_sexp, SEXP scal // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 FixedSizeBinary__initialize(R_xlen_t byte_width); +std::shared_ptr FixedSizeBinary__initialize(R_xlen_t byte_width); extern "C" SEXP _arrow_FixedSizeBinary__initialize(SEXP byte_width_sexp){ BEGIN_CPP11 arrow::r::Input::type byte_width(byte_width_sexp); @@ -2314,7 +2314,7 @@ extern "C" SEXP _arrow_FixedSizeBinary__initialize(SEXP byte_width_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone); +std::shared_ptr Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone); extern "C" SEXP _arrow_Timestamp__initialize(SEXP unit_sexp, SEXP timezone_sexp){ BEGIN_CPP11 arrow::r::Input::type unit(unit_sexp); @@ -2330,7 +2330,7 @@ extern "C" SEXP _arrow_Timestamp__initialize(SEXP unit_sexp, SEXP timezone_sexp) // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Time32__initialize(arrow::TimeUnit::type unit); +std::shared_ptr Time32__initialize(arrow::TimeUnit::type unit); extern "C" SEXP _arrow_Time32__initialize(SEXP unit_sexp){ BEGIN_CPP11 arrow::r::Input::type unit(unit_sexp); @@ -2345,7 +2345,7 @@ extern "C" SEXP _arrow_Time32__initialize(SEXP unit_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Time64__initialize(arrow::TimeUnit::type unit); +std::shared_ptr Time64__initialize(arrow::TimeUnit::type unit); extern "C" SEXP _arrow_Time64__initialize(SEXP unit_sexp){ BEGIN_CPP11 arrow::r::Input::type unit(unit_sexp); @@ -2360,7 +2360,7 @@ extern "C" SEXP _arrow_Time64__initialize(SEXP unit_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 list__(SEXP x); +std::shared_ptr list__(SEXP x); extern "C" SEXP _arrow_list__(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -2375,7 +2375,7 @@ extern "C" SEXP _arrow_list__(SEXP x_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 large_list__(SEXP x); +std::shared_ptr large_list__(SEXP x); extern "C" SEXP _arrow_large_list__(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -2390,7 +2390,7 @@ extern "C" SEXP _arrow_large_list__(SEXP x_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fixed_size_list__(SEXP x, int list_size); +std::shared_ptr fixed_size_list__(SEXP x, int list_size); extern "C" SEXP _arrow_fixed_size_list__(SEXP x_sexp, SEXP list_size_sexp){ BEGIN_CPP11 arrow::r::Input::type x(x_sexp); @@ -2406,7 +2406,7 @@ extern "C" SEXP _arrow_fixed_size_list__(SEXP x_sexp, SEXP list_size_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 struct__(const std::vector>& fields); +std::shared_ptr struct__(const std::vector>& fields); extern "C" SEXP _arrow_struct__(SEXP fields_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type fields(fields_sexp); @@ -2632,7 +2632,7 @@ extern "C" SEXP _arrow_TimestampType__unit(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 DictionaryType__initialize(const std::shared_ptr& index_type, const std::shared_ptr& value_type, bool ordered); +std::shared_ptr DictionaryType__initialize(const std::shared_ptr& index_type, const std::shared_ptr& value_type, bool ordered); extern "C" SEXP _arrow_DictionaryType__initialize(SEXP index_type_sexp, SEXP value_type_sexp, SEXP ordered_sexp){ BEGIN_CPP11 arrow::r::Input&>::type index_type(index_type_sexp); @@ -2649,7 +2649,7 @@ extern "C" SEXP _arrow_DictionaryType__initialize(SEXP index_type_sexp, SEXP val // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 DictionaryType__index_type(const std::shared_ptr& type); +std::shared_ptr DictionaryType__index_type(const std::shared_ptr& type); extern "C" SEXP _arrow_DictionaryType__index_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2664,7 +2664,7 @@ extern "C" SEXP _arrow_DictionaryType__index_type(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 DictionaryType__value_type(const std::shared_ptr& type); +std::shared_ptr DictionaryType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_DictionaryType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2709,7 +2709,7 @@ extern "C" SEXP _arrow_DictionaryType__ordered(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 StructType__GetFieldByName(const std::shared_ptr& type, const std::string& name); +std::shared_ptr StructType__GetFieldByName(const std::shared_ptr& type, const std::string& name); extern "C" SEXP _arrow_StructType__GetFieldByName(SEXP type_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2741,7 +2741,7 @@ extern "C" SEXP _arrow_StructType__GetFieldIndex(SEXP type_sexp, SEXP name_sexp) // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ListType__value_field(const std::shared_ptr& type); +std::shared_ptr ListType__value_field(const std::shared_ptr& type); extern "C" SEXP _arrow_ListType__value_field(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2756,7 +2756,7 @@ extern "C" SEXP _arrow_ListType__value_field(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ListType__value_type(const std::shared_ptr& type); +std::shared_ptr ListType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_ListType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2771,7 +2771,7 @@ extern "C" SEXP _arrow_ListType__value_type(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 LargeListType__value_field(const std::shared_ptr& type); +std::shared_ptr LargeListType__value_field(const std::shared_ptr& type); extern "C" SEXP _arrow_LargeListType__value_field(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2786,7 +2786,7 @@ extern "C" SEXP _arrow_LargeListType__value_field(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 LargeListType__value_type(const std::shared_ptr& type); +std::shared_ptr LargeListType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_LargeListType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2801,7 +2801,7 @@ extern "C" SEXP _arrow_LargeListType__value_type(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 FixedSizeListType__value_field(const std::shared_ptr& type); +std::shared_ptr FixedSizeListType__value_field(const std::shared_ptr& type); extern "C" SEXP _arrow_FixedSizeListType__value_field(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2816,7 +2816,7 @@ extern "C" SEXP _arrow_FixedSizeListType__value_field(SEXP type_sexp){ // datatype.cpp #if defined(ARROW_R_WITH_ARROW) -R6 FixedSizeListType__value_type(const std::shared_ptr& type); +std::shared_ptr FixedSizeListType__value_type(const std::shared_ptr& type); extern "C" SEXP _arrow_FixedSizeListType__value_type(SEXP type_sexp){ BEGIN_CPP11 arrow::r::Input&>::type type(type_sexp); @@ -2846,7 +2846,7 @@ extern "C" SEXP _arrow_FixedSizeListType__list_size(SEXP type_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__field_ref(std::string name); +std::shared_ptr dataset___expr__field_ref(std::string name); extern "C" SEXP _arrow_dataset___expr__field_ref(SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input::type name(name_sexp); @@ -2861,7 +2861,7 @@ extern "C" SEXP _arrow_dataset___expr__field_ref(SEXP name_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2877,7 +2877,7 @@ extern "C" SEXP _arrow_dataset___expr__equal(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__not_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__not_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__not_equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2893,7 +2893,7 @@ extern "C" SEXP _arrow_dataset___expr__not_equal(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__greater(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__greater(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__greater(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2909,7 +2909,7 @@ extern "C" SEXP _arrow_dataset___expr__greater(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__greater_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__greater_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__greater_equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2925,7 +2925,7 @@ extern "C" SEXP _arrow_dataset___expr__greater_equal(SEXP lhs_sexp, SEXP rhs_sex // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__less(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__less(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__less(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2941,7 +2941,7 @@ extern "C" SEXP _arrow_dataset___expr__less(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__less_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__less_equal(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__less_equal(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2957,7 +2957,7 @@ extern "C" SEXP _arrow_dataset___expr__less_equal(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__in(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__in(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__in(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2973,7 +2973,7 @@ extern "C" SEXP _arrow_dataset___expr__in(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__and(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__and(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__and(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -2989,7 +2989,7 @@ extern "C" SEXP _arrow_dataset___expr__and(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__or(const std::shared_ptr& lhs, const std::shared_ptr& rhs); +std::shared_ptr dataset___expr__or(const std::shared_ptr& lhs, const std::shared_ptr& rhs); extern "C" SEXP _arrow_dataset___expr__or(SEXP lhs_sexp, SEXP rhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3005,7 +3005,7 @@ extern "C" SEXP _arrow_dataset___expr__or(SEXP lhs_sexp, SEXP rhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__not(const std::shared_ptr& lhs); +std::shared_ptr dataset___expr__not(const std::shared_ptr& lhs); extern "C" SEXP _arrow_dataset___expr__not(SEXP lhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3020,7 +3020,7 @@ extern "C" SEXP _arrow_dataset___expr__not(SEXP lhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__is_valid(const std::shared_ptr& lhs); +std::shared_ptr dataset___expr__is_valid(const std::shared_ptr& lhs); extern "C" SEXP _arrow_dataset___expr__is_valid(SEXP lhs_sexp){ BEGIN_CPP11 arrow::r::Input&>::type lhs(lhs_sexp); @@ -3035,7 +3035,7 @@ extern "C" SEXP _arrow_dataset___expr__is_valid(SEXP lhs_sexp){ // expression.cpp #if defined(ARROW_R_WITH_ARROW) -R6 dataset___expr__scalar(const std::shared_ptr& x); +std::shared_ptr dataset___expr__scalar(const std::shared_ptr& x); extern "C" SEXP _arrow_dataset___expr__scalar(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3101,7 +3101,7 @@ extern "C" SEXP _arrow_ipc___feather___Reader__version(SEXP reader_sexp){ // feather.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___feather___Reader__Read(const std::shared_ptr& reader, SEXP columns); +std::shared_ptr ipc___feather___Reader__Read(const std::shared_ptr& reader, SEXP columns); extern "C" SEXP _arrow_ipc___feather___Reader__Read(SEXP reader_sexp, SEXP columns_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -3117,7 +3117,7 @@ extern "C" SEXP _arrow_ipc___feather___Reader__Read(SEXP reader_sexp, SEXP colum // feather.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___feather___Reader__Open(const std::shared_ptr& stream); +std::shared_ptr ipc___feather___Reader__Open(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___feather___Reader__Open(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -3147,7 +3147,7 @@ extern "C" SEXP _arrow_ipc___feather___Reader__column_names(SEXP reader_sexp){ // field.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Field__initialize(const std::string& name, const std::shared_ptr& field, bool nullable); +std::shared_ptr Field__initialize(const std::string& name, const std::shared_ptr& field, bool nullable); extern "C" SEXP _arrow_Field__initialize(SEXP name_sexp, SEXP field_sexp, SEXP nullable_sexp){ BEGIN_CPP11 arrow::r::Input::type name(name_sexp); @@ -3225,7 +3225,7 @@ extern "C" SEXP _arrow_Field__nullable(SEXP field_sexp){ // field.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Field__type(const std::shared_ptr& field); +std::shared_ptr Field__type(const std::shared_ptr& field); extern "C" SEXP _arrow_Field__type(SEXP field_sexp){ BEGIN_CPP11 arrow::r::Input&>::type field(field_sexp); @@ -3443,7 +3443,7 @@ extern "C" SEXP _arrow_fs___FileSelector__recursive(SEXP selector_sexp){ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, bool recursive); +std::shared_ptr fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, bool recursive); extern "C" SEXP _arrow_fs___FileSelector__create(SEXP base_dir_sexp, SEXP allow_not_found_sexp, SEXP recursive_sexp){ BEGIN_CPP11 arrow::r::Input::type base_dir(base_dir_sexp); @@ -3614,7 +3614,7 @@ extern "C" SEXP _arrow_fs___FileSystem__CopyFile(SEXP file_system_sexp, SEXP src // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, const std::string& path); +std::shared_ptr fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenInputStream(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3630,7 +3630,7 @@ extern "C" SEXP _arrow_fs___FileSystem__OpenInputStream(SEXP file_system_sexp, S // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, const std::string& path); +std::shared_ptr fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenInputFile(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3646,7 +3646,7 @@ extern "C" SEXP _arrow_fs___FileSystem__OpenInputFile(SEXP file_system_sexp, SEX // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, const std::string& path); +std::shared_ptr fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenOutputStream(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3662,7 +3662,7 @@ extern "C" SEXP _arrow_fs___FileSystem__OpenOutputStream(SEXP file_system_sexp, // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, const std::string& path); +std::shared_ptr fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, const std::string& path); extern "C" SEXP _arrow_fs___FileSystem__OpenAppendStream(SEXP file_system_sexp, SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3693,7 +3693,7 @@ extern "C" SEXP _arrow_fs___FileSystem__type_name(SEXP file_system_sexp){ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___LocalFileSystem__create(); +std::shared_ptr fs___LocalFileSystem__create(); extern "C" SEXP _arrow_fs___LocalFileSystem__create(){ BEGIN_CPP11 return cpp11::as_sexp(fs___LocalFileSystem__create()); @@ -3707,7 +3707,7 @@ extern "C" SEXP _arrow_fs___LocalFileSystem__create(){ // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___SubTreeFileSystem__create(const std::string& base_path, const std::shared_ptr& base_fs); +std::shared_ptr fs___SubTreeFileSystem__create(const std::string& base_path, const std::shared_ptr& base_fs); extern "C" SEXP _arrow_fs___SubTreeFileSystem__create(SEXP base_path_sexp, SEXP base_fs_sexp){ BEGIN_CPP11 arrow::r::Input::type base_path(base_path_sexp); @@ -3723,7 +3723,7 @@ extern "C" SEXP _arrow_fs___SubTreeFileSystem__create(SEXP base_path_sexp, SEXP // filesystem.cpp #if defined(ARROW_R_WITH_ARROW) -R6 fs___SubTreeFileSystem__base_fs(const std::shared_ptr& file_system); +std::shared_ptr fs___SubTreeFileSystem__base_fs(const std::shared_ptr& file_system); extern "C" SEXP _arrow_fs___SubTreeFileSystem__base_fs(SEXP file_system_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file_system(file_system_sexp); @@ -3789,7 +3789,7 @@ extern "C" SEXP _arrow_fs___CopyFiles(SEXP source_fs_sexp, SEXP source_sel_sexp, // filesystem.cpp #if defined(ARROW_R_WITH_S3) -R6 fs___S3FileSystem__create(bool anonymous, std::string access_key, std::string secret_key, std::string session_token, std::string role_arn, std::string session_name, std::string external_id, int load_frequency, std::string region, std::string endpoint_override, std::string scheme, bool background_writes); +std::shared_ptr fs___S3FileSystem__create(bool anonymous, std::string access_key, std::string secret_key, std::string session_token, std::string role_arn, std::string session_name, std::string external_id, int load_frequency, std::string region, std::string endpoint_override, std::string scheme, bool background_writes); extern "C" SEXP _arrow_fs___S3FileSystem__create(SEXP anonymous_sexp, SEXP access_key_sexp, SEXP secret_key_sexp, SEXP session_token_sexp, SEXP role_arn_sexp, SEXP session_name_sexp, SEXP external_id_sexp, SEXP load_frequency_sexp, SEXP region_sexp, SEXP endpoint_override_sexp, SEXP scheme_sexp, SEXP background_writes_sexp){ BEGIN_CPP11 arrow::r::Input::type anonymous(anonymous_sexp); @@ -3830,7 +3830,7 @@ extern "C" SEXP _arrow_fs___S3FileSystem__region(SEXP fs_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___Readable__Read(const std::shared_ptr& x, int64_t nbytes); +std::shared_ptr io___Readable__Read(const std::shared_ptr& x, int64_t nbytes); extern "C" SEXP _arrow_io___Readable__Read(SEXP x_sexp, SEXP nbytes_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3940,7 +3940,7 @@ extern "C" SEXP _arrow_io___RandomAccessFile__Tell(SEXP x_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___RandomAccessFile__Read0(const std::shared_ptr& x); +std::shared_ptr io___RandomAccessFile__Read0(const std::shared_ptr& x); extern "C" SEXP _arrow_io___RandomAccessFile__Read0(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3955,7 +3955,7 @@ extern "C" SEXP _arrow_io___RandomAccessFile__Read0(SEXP x_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___RandomAccessFile__ReadAt(const std::shared_ptr& x, int64_t position, int64_t nbytes); +std::shared_ptr io___RandomAccessFile__ReadAt(const std::shared_ptr& x, int64_t position, int64_t nbytes); extern "C" SEXP _arrow_io___RandomAccessFile__ReadAt(SEXP x_sexp, SEXP position_sexp, SEXP nbytes_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -3972,7 +3972,7 @@ extern "C" SEXP _arrow_io___RandomAccessFile__ReadAt(SEXP x_sexp, SEXP position_ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___MemoryMappedFile__Create(const std::string& path, int64_t size); +std::shared_ptr io___MemoryMappedFile__Create(const std::string& path, int64_t size); extern "C" SEXP _arrow_io___MemoryMappedFile__Create(SEXP path_sexp, SEXP size_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -3988,7 +3988,7 @@ extern "C" SEXP _arrow_io___MemoryMappedFile__Create(SEXP path_sexp, SEXP size_s // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode); +std::shared_ptr io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode); extern "C" SEXP _arrow_io___MemoryMappedFile__Open(SEXP path_sexp, SEXP mode_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4021,7 +4021,7 @@ extern "C" SEXP _arrow_io___MemoryMappedFile__Resize(SEXP x_sexp, SEXP size_sexp // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___ReadableFile__Open(const std::string& path); +std::shared_ptr io___ReadableFile__Open(const std::string& path); extern "C" SEXP _arrow_io___ReadableFile__Open(SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4036,7 +4036,7 @@ extern "C" SEXP _arrow_io___ReadableFile__Open(SEXP path_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___BufferReader__initialize(const std::shared_ptr& buffer); +std::shared_ptr io___BufferReader__initialize(const std::shared_ptr& buffer); extern "C" SEXP _arrow_io___BufferReader__initialize(SEXP buffer_sexp){ BEGIN_CPP11 arrow::r::Input&>::type buffer(buffer_sexp); @@ -4083,7 +4083,7 @@ extern "C" SEXP _arrow_io___OutputStream__Tell(SEXP stream_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___FileOutputStream__Open(const std::string& path); +std::shared_ptr io___FileOutputStream__Open(const std::string& path); extern "C" SEXP _arrow_io___FileOutputStream__Open(SEXP path_sexp){ BEGIN_CPP11 arrow::r::Input::type path(path_sexp); @@ -4098,7 +4098,7 @@ extern "C" SEXP _arrow_io___FileOutputStream__Open(SEXP path_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___BufferOutputStream__Create(int64_t initial_capacity); +std::shared_ptr io___BufferOutputStream__Create(int64_t initial_capacity); extern "C" SEXP _arrow_io___BufferOutputStream__Create(SEXP initial_capacity_sexp){ BEGIN_CPP11 arrow::r::Input::type initial_capacity(initial_capacity_sexp); @@ -4128,7 +4128,7 @@ extern "C" SEXP _arrow_io___BufferOutputStream__capacity(SEXP stream_sexp){ // io.cpp #if defined(ARROW_R_WITH_ARROW) -R6 io___BufferOutputStream__Finish(const std::shared_ptr& stream); +std::shared_ptr io___BufferOutputStream__Finish(const std::shared_ptr& stream); extern "C" SEXP _arrow_io___BufferOutputStream__Finish(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4175,7 +4175,7 @@ extern "C" SEXP _arrow_io___BufferOutputStream__Write(SEXP stream_sexp, SEXP byt // json.cpp #if defined(ARROW_R_WITH_ARROW) -R6 json___ReadOptions__initialize(bool use_threads, int block_size); +std::shared_ptr json___ReadOptions__initialize(bool use_threads, int block_size); extern "C" SEXP _arrow_json___ReadOptions__initialize(SEXP use_threads_sexp, SEXP block_size_sexp){ BEGIN_CPP11 arrow::r::Input::type use_threads(use_threads_sexp); @@ -4191,7 +4191,7 @@ extern "C" SEXP _arrow_json___ReadOptions__initialize(SEXP use_threads_sexp, SEX // json.cpp #if defined(ARROW_R_WITH_ARROW) -R6 json___ParseOptions__initialize(bool newlines_in_values); +std::shared_ptr json___ParseOptions__initialize(bool newlines_in_values); extern "C" SEXP _arrow_json___ParseOptions__initialize(SEXP newlines_in_values_sexp){ BEGIN_CPP11 arrow::r::Input::type newlines_in_values(newlines_in_values_sexp); @@ -4206,7 +4206,7 @@ extern "C" SEXP _arrow_json___ParseOptions__initialize(SEXP newlines_in_values_s // json.cpp #if defined(ARROW_R_WITH_ARROW) -R6 json___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options); +std::shared_ptr json___TableReader__Make(const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options); extern "C" SEXP _arrow_json___TableReader__Make(SEXP input_sexp, SEXP read_options_sexp, SEXP parse_options_sexp){ BEGIN_CPP11 arrow::r::Input&>::type input(input_sexp); @@ -4223,7 +4223,7 @@ extern "C" SEXP _arrow_json___TableReader__Make(SEXP input_sexp, SEXP read_optio // json.cpp #if defined(ARROW_R_WITH_ARROW) -R6 json___TableReader__Read(const std::shared_ptr& table_reader); +std::shared_ptr json___TableReader__Read(const std::shared_ptr& table_reader); extern "C" SEXP _arrow_json___TableReader__Read(SEXP table_reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table_reader(table_reader_sexp); @@ -4238,7 +4238,7 @@ extern "C" SEXP _arrow_json___TableReader__Read(SEXP table_reader_sexp){ // memorypool.cpp #if defined(ARROW_R_WITH_ARROW) -R6 MemoryPool__default(); +std::shared_ptr MemoryPool__default(); extern "C" SEXP _arrow_MemoryPool__default(){ BEGIN_CPP11 return cpp11::as_sexp(MemoryPool__default()); @@ -4297,7 +4297,7 @@ extern "C" SEXP _arrow_ipc___Message__body_length(SEXP message_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___Message__metadata(const std::unique_ptr& message); +std::shared_ptr ipc___Message__metadata(const std::unique_ptr& message); extern "C" SEXP _arrow_ipc___Message__metadata(SEXP message_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4312,7 +4312,7 @@ extern "C" SEXP _arrow_ipc___Message__metadata(SEXP message_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___Message__body(const std::unique_ptr& message); +std::shared_ptr ipc___Message__body(const std::unique_ptr& message); extern "C" SEXP _arrow_ipc___Message__body(SEXP message_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4373,7 +4373,7 @@ extern "C" SEXP _arrow_ipc___Message__Equals(SEXP x_sexp, SEXP y_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___ReadRecordBatch__Message__Schema(const std::unique_ptr& message, const std::shared_ptr& schema); +std::shared_ptr ipc___ReadRecordBatch__Message__Schema(const std::unique_ptr& message, const std::shared_ptr& schema); extern "C" SEXP _arrow_ipc___ReadRecordBatch__Message__Schema(SEXP message_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4389,7 +4389,7 @@ extern "C" SEXP _arrow_ipc___ReadRecordBatch__Message__Schema(SEXP message_sexp, // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___ReadSchema_InputStream(const std::shared_ptr& stream); +std::shared_ptr ipc___ReadSchema_InputStream(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___ReadSchema_InputStream(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4404,7 +4404,7 @@ extern "C" SEXP _arrow_ipc___ReadSchema_InputStream(SEXP stream_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___ReadSchema_Message(const std::unique_ptr& message); +std::shared_ptr ipc___ReadSchema_Message(const std::unique_ptr& message); extern "C" SEXP _arrow_ipc___ReadSchema_Message(SEXP message_sexp){ BEGIN_CPP11 arrow::r::Input&>::type message(message_sexp); @@ -4419,7 +4419,7 @@ extern "C" SEXP _arrow_ipc___ReadSchema_Message(SEXP message_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___MessageReader__Open(const std::shared_ptr& stream); +std::shared_ptr ipc___MessageReader__Open(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___MessageReader__Open(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4434,7 +4434,7 @@ extern "C" SEXP _arrow_ipc___MessageReader__Open(SEXP stream_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___MessageReader__ReadNextMessage(const std::unique_ptr& reader); +std::shared_ptr ipc___MessageReader__ReadNextMessage(const std::unique_ptr& reader); extern "C" SEXP _arrow_ipc___MessageReader__ReadNextMessage(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4449,7 +4449,7 @@ extern "C" SEXP _arrow_ipc___MessageReader__ReadNextMessage(SEXP reader_sexp){ // message.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___ReadMessage(const std::shared_ptr& stream); +std::shared_ptr ipc___ReadMessage(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___ReadMessage(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -4464,7 +4464,7 @@ extern "C" SEXP _arrow_ipc___ReadMessage(SEXP stream_sexp){ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___ArrowReaderProperties__Make(bool use_threads); +std::shared_ptr parquet___arrow___ArrowReaderProperties__Make(bool use_threads); extern "C" SEXP _arrow_parquet___arrow___ArrowReaderProperties__Make(SEXP use_threads_sexp){ BEGIN_CPP11 arrow::r::Input::type use_threads(use_threads_sexp); @@ -4546,7 +4546,7 @@ extern "C" SEXP _arrow_parquet___arrow___ArrowReaderProperties__set_read_diction // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__OpenFile(const std::shared_ptr& file, const std::shared_ptr& props); +std::shared_ptr parquet___arrow___FileReader__OpenFile(const std::shared_ptr& file, const std::shared_ptr& props); extern "C" SEXP _arrow_parquet___arrow___FileReader__OpenFile(SEXP file_sexp, SEXP props_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file(file_sexp); @@ -4562,7 +4562,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__OpenFile(SEXP file_sexp, SE // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadTable1(const std::shared_ptr& reader); +std::shared_ptr parquet___arrow___FileReader__ReadTable1(const std::shared_ptr& reader); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable1(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4577,7 +4577,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable1(SEXP reader_sexp // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadTable2(const std::shared_ptr& reader, const std::vector& column_indices); +std::shared_ptr parquet___arrow___FileReader__ReadTable2(const std::shared_ptr& reader, const std::vector& column_indices); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable2(SEXP reader_sexp, SEXP column_indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4593,7 +4593,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadTable2(SEXP reader_sexp // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadRowGroup1(const std::shared_ptr& reader, int i); +std::shared_ptr parquet___arrow___FileReader__ReadRowGroup1(const std::shared_ptr& reader, int i); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup1(SEXP reader_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4609,7 +4609,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup1(SEXP reader_s // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadRowGroup2(const std::shared_ptr& reader, int i, const std::vector& column_indices); +std::shared_ptr parquet___arrow___FileReader__ReadRowGroup2(const std::shared_ptr& reader, int i, const std::vector& column_indices); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup2(SEXP reader_sexp, SEXP i_sexp, SEXP column_indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4626,7 +4626,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroup2(SEXP reader_s // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadRowGroups1(const std::shared_ptr& reader, const std::vector& row_groups); +std::shared_ptr parquet___arrow___FileReader__ReadRowGroups1(const std::shared_ptr& reader, const std::vector& row_groups); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroups1(SEXP reader_sexp, SEXP row_groups_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4642,7 +4642,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroups1(SEXP reader_ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadRowGroups2(const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices); +std::shared_ptr parquet___arrow___FileReader__ReadRowGroups2(const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadRowGroups2(SEXP reader_sexp, SEXP row_groups_sexp, SEXP column_indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4704,7 +4704,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__num_row_groups(SEXP reader_ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__ReadColumn(const std::shared_ptr& reader, int i); +std::shared_ptr parquet___arrow___FileReader__ReadColumn(const std::shared_ptr& reader, int i); extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadColumn(SEXP reader_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4720,7 +4720,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__ReadColumn(SEXP reader_sexp // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, int timestamp_unit); +std::shared_ptr parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, int timestamp_unit); extern "C" SEXP _arrow_parquet___ArrowWriterProperties___create(SEXP allow_truncated_timestamps_sexp, SEXP use_deprecated_int96_timestamps_sexp, SEXP timestamp_unit_sexp){ BEGIN_CPP11 arrow::r::Input::type allow_truncated_timestamps(allow_truncated_timestamps_sexp); @@ -4737,7 +4737,7 @@ extern "C" SEXP _arrow_parquet___ArrowWriterProperties___create(SEXP allow_trunc // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___WriterProperties___Builder__create(); +std::shared_ptr parquet___WriterProperties___Builder__create(); extern "C" SEXP _arrow_parquet___WriterProperties___Builder__create(){ BEGIN_CPP11 return cpp11::as_sexp(parquet___WriterProperties___Builder__create()); @@ -4857,7 +4857,7 @@ extern "C" SEXP _arrow_parquet___ArrowWriterProperties___Builder__data_page_size // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___WriterProperties___Builder__build(const std::shared_ptr& builder); +std::shared_ptr parquet___WriterProperties___Builder__build(const std::shared_ptr& builder); extern "C" SEXP _arrow_parquet___WriterProperties___Builder__build(SEXP builder_sexp){ BEGIN_CPP11 arrow::r::Input&>::type builder(builder_sexp); @@ -4872,7 +4872,7 @@ extern "C" SEXP _arrow_parquet___WriterProperties___Builder__build(SEXP builder_ // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___ParquetFileWriter__Open(const std::shared_ptr& schema, const std::shared_ptr& sink, const std::shared_ptr& properties, const std::shared_ptr& arrow_properties); +std::shared_ptr parquet___arrow___ParquetFileWriter__Open(const std::shared_ptr& schema, const std::shared_ptr& sink, const std::shared_ptr& properties, const std::shared_ptr& arrow_properties); extern "C" SEXP _arrow_parquet___arrow___ParquetFileWriter__Open(SEXP schema_sexp, SEXP sink_sexp, SEXP properties_sexp, SEXP arrow_properties_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schema(schema_sexp); @@ -4943,7 +4943,7 @@ extern "C" SEXP _arrow_parquet___arrow___WriteTable(SEXP table_sexp, SEXP sink_s // parquet.cpp #if defined(ARROW_R_WITH_ARROW) -R6 parquet___arrow___FileReader__GetSchema(const std::shared_ptr& reader); +std::shared_ptr parquet___arrow___FileReader__GetSchema(const std::shared_ptr& reader); extern "C" SEXP _arrow_parquet___arrow___FileReader__GetSchema(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -4958,7 +4958,7 @@ extern "C" SEXP _arrow_parquet___arrow___FileReader__GetSchema(SEXP reader_sexp) // py-to-r.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ImportArray(arrow::r::Pointer array, arrow::r::Pointer schema); +std::shared_ptr ImportArray(arrow::r::Pointer array, arrow::r::Pointer schema); extern "C" SEXP _arrow_ImportArray(SEXP array_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input>::type array(array_sexp); @@ -4974,7 +4974,7 @@ extern "C" SEXP _arrow_ImportArray(SEXP array_sexp, SEXP schema_sexp){ // py-to-r.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ImportRecordBatch(arrow::r::Pointer array, arrow::r::Pointer schema); +std::shared_ptr ImportRecordBatch(arrow::r::Pointer array, arrow::r::Pointer schema); extern "C" SEXP _arrow_ImportRecordBatch(SEXP array_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input>::type array(array_sexp); @@ -5150,7 +5150,7 @@ extern "C" SEXP _arrow_RecordBatch__num_rows(SEXP x_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__schema(const std::shared_ptr& x); +std::shared_ptr RecordBatch__schema(const std::shared_ptr& x); extern "C" SEXP _arrow_RecordBatch__schema(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -5165,7 +5165,7 @@ extern "C" SEXP _arrow_RecordBatch__schema(SEXP x_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); +std::shared_ptr RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); extern "C" SEXP _arrow_RecordBatch__ReplaceSchemaMetadata(SEXP x_sexp, SEXP metadata_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -5196,7 +5196,7 @@ extern "C" SEXP _arrow_RecordBatch__columns(SEXP batch_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i); +std::shared_ptr RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i); extern "C" SEXP _arrow_RecordBatch__column(SEXP batch_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5212,7 +5212,7 @@ extern "C" SEXP _arrow_RecordBatch__column(SEXP batch_sexp, SEXP i_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__GetColumnByName(const std::shared_ptr& batch, const std::string& name); +std::shared_ptr RecordBatch__GetColumnByName(const std::shared_ptr& batch, const std::string& name); extern "C" SEXP _arrow_RecordBatch__GetColumnByName(SEXP batch_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5228,7 +5228,7 @@ extern "C" SEXP _arrow_RecordBatch__GetColumnByName(SEXP batch_sexp, SEXP name_s // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__SelectColumns(const std::shared_ptr& batch, cpp11::integers indices); +std::shared_ptr RecordBatch__SelectColumns(const std::shared_ptr& batch, cpp11::integers indices); extern "C" SEXP _arrow_RecordBatch__SelectColumns(SEXP batch_sexp, SEXP indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5261,7 +5261,7 @@ extern "C" SEXP _arrow_RecordBatch__Equals(SEXP self_sexp, SEXP other_sexp, SEXP // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__RemoveColumn(const std::shared_ptr& batch, R_xlen_t i); +std::shared_ptr RecordBatch__RemoveColumn(const std::shared_ptr& batch, R_xlen_t i); extern "C" SEXP _arrow_RecordBatch__RemoveColumn(SEXP batch_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); @@ -5308,7 +5308,7 @@ extern "C" SEXP _arrow_RecordBatch__names(SEXP batch_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset); +std::shared_ptr RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset); extern "C" SEXP _arrow_RecordBatch__Slice1(SEXP self_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type self(self_sexp); @@ -5324,7 +5324,7 @@ extern "C" SEXP _arrow_RecordBatch__Slice1(SEXP self_sexp, SEXP offset_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t offset, R_xlen_t length); +std::shared_ptr RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_RecordBatch__Slice2(SEXP self_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type self(self_sexp); @@ -5356,7 +5356,7 @@ extern "C" SEXP _arrow_ipc___SerializeRecordBatch__Raw(SEXP batch_sexp){ // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___ReadRecordBatch__InputStream__Schema(const std::shared_ptr& stream, const std::shared_ptr& schema); +std::shared_ptr ipc___ReadRecordBatch__InputStream__Schema(const std::shared_ptr& stream, const std::shared_ptr& schema); extern "C" SEXP _arrow_ipc___ReadRecordBatch__InputStream__Schema(SEXP stream_sexp, SEXP schema_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5372,7 +5372,7 @@ extern "C" SEXP _arrow_ipc___ReadRecordBatch__InputStream__Schema(SEXP stream_se // recordbatch.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst); +std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst); extern "C" SEXP _arrow_RecordBatch__from_arrays(SEXP schema_sxp_sexp, SEXP lst_sexp){ BEGIN_CPP11 arrow::r::Input::type schema_sxp(schema_sxp_sexp); @@ -5388,7 +5388,7 @@ extern "C" SEXP _arrow_RecordBatch__from_arrays(SEXP schema_sxp_sexp, SEXP lst_s // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatchReader__schema(const std::shared_ptr& reader); +std::shared_ptr RecordBatchReader__schema(const std::shared_ptr& reader); extern "C" SEXP _arrow_RecordBatchReader__schema(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5403,7 +5403,7 @@ extern "C" SEXP _arrow_RecordBatchReader__schema(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 RecordBatchReader__ReadNext(const std::shared_ptr& reader); +std::shared_ptr RecordBatchReader__ReadNext(const std::shared_ptr& reader); extern "C" SEXP _arrow_RecordBatchReader__ReadNext(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5418,7 +5418,7 @@ extern "C" SEXP _arrow_RecordBatchReader__ReadNext(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___RecordBatchStreamReader__Open(const std::shared_ptr& stream); +std::shared_ptr ipc___RecordBatchStreamReader__Open(const std::shared_ptr& stream); extern "C" SEXP _arrow_ipc___RecordBatchStreamReader__Open(SEXP stream_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5448,7 +5448,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchStreamReader__batches(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___RecordBatchFileReader__schema(const std::shared_ptr& reader); +std::shared_ptr ipc___RecordBatchFileReader__schema(const std::shared_ptr& reader); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__schema(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5478,7 +5478,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__num_record_batches(SEXP read // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___RecordBatchFileReader__ReadRecordBatch(const std::shared_ptr& reader, int i); +std::shared_ptr ipc___RecordBatchFileReader__ReadRecordBatch(const std::shared_ptr& reader, int i); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__ReadRecordBatch(SEXP reader_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5494,7 +5494,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__ReadRecordBatch(SEXP reader_ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___RecordBatchFileReader__Open(const std::shared_ptr& file); +std::shared_ptr ipc___RecordBatchFileReader__Open(const std::shared_ptr& file); extern "C" SEXP _arrow_ipc___RecordBatchFileReader__Open(SEXP file_sexp){ BEGIN_CPP11 arrow::r::Input&>::type file(file_sexp); @@ -5509,7 +5509,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileReader__Open(SEXP file_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__from_RecordBatchFileReader(const std::shared_ptr& reader); +std::shared_ptr Table__from_RecordBatchFileReader(const std::shared_ptr& reader); extern "C" SEXP _arrow_Table__from_RecordBatchFileReader(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5524,7 +5524,7 @@ extern "C" SEXP _arrow_Table__from_RecordBatchFileReader(SEXP reader_sexp){ // recordbatchreader.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__from_RecordBatchStreamReader(const std::shared_ptr& reader); +std::shared_ptr Table__from_RecordBatchStreamReader(const std::shared_ptr& reader); extern "C" SEXP _arrow_Table__from_RecordBatchStreamReader(SEXP reader_sexp){ BEGIN_CPP11 arrow::r::Input&>::type reader(reader_sexp); @@ -5604,7 +5604,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchWriter__Close(SEXP batch_writer_sexp){ // recordbatchwriter.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___RecordBatchFileWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); +std::shared_ptr ipc___RecordBatchFileWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); extern "C" SEXP _arrow_ipc___RecordBatchFileWriter__Open(SEXP stream_sexp, SEXP schema_sexp, SEXP use_legacy_format_sexp, SEXP metadata_version_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5622,7 +5622,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchFileWriter__Open(SEXP stream_sexp, SEXP // recordbatchwriter.cpp #if defined(ARROW_R_WITH_ARROW) -R6 ipc___RecordBatchStreamWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); +std::shared_ptr ipc___RecordBatchStreamWriter__Open(const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version); extern "C" SEXP _arrow_ipc___RecordBatchStreamWriter__Open(SEXP stream_sexp, SEXP schema_sexp, SEXP use_legacy_format_sexp, SEXP metadata_version_sexp){ BEGIN_CPP11 arrow::r::Input&>::type stream(stream_sexp); @@ -5640,7 +5640,7 @@ extern "C" SEXP _arrow_ipc___RecordBatchStreamWriter__Open(SEXP stream_sexp, SEX // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Array__GetScalar(const std::shared_ptr& x, int64_t i); +std::shared_ptr Array__GetScalar(const std::shared_ptr& x, int64_t i); extern "C" SEXP _arrow_Array__GetScalar(SEXP x_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -5671,7 +5671,7 @@ extern "C" SEXP _arrow_Scalar__ToString(SEXP s_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Scalar__CastTo(const std::shared_ptr& s, const std::shared_ptr& t); +std::shared_ptr Scalar__CastTo(const std::shared_ptr& s, const std::shared_ptr& t); extern "C" SEXP _arrow_Scalar__CastTo(SEXP s_sexp, SEXP t_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5687,7 +5687,7 @@ extern "C" SEXP _arrow_Scalar__CastTo(SEXP s_sexp, SEXP t_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -R6 StructScalar__field(const std::shared_ptr& s, int i); +std::shared_ptr StructScalar__field(const std::shared_ptr& s, int i); extern "C" SEXP _arrow_StructScalar__field(SEXP s_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5703,7 +5703,7 @@ extern "C" SEXP _arrow_StructScalar__field(SEXP s_sexp, SEXP i_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -R6 StructScalar__GetFieldByName(const std::shared_ptr& s, const std::string& name); +std::shared_ptr StructScalar__GetFieldByName(const std::shared_ptr& s, const std::string& name); extern "C" SEXP _arrow_StructScalar__GetFieldByName(SEXP s_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5749,7 +5749,7 @@ extern "C" SEXP _arrow_Scalar__is_valid(SEXP s_sexp){ // scalar.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Scalar__type(const std::shared_ptr& s); +std::shared_ptr Scalar__type(const std::shared_ptr& s); extern "C" SEXP _arrow_Scalar__type(SEXP s_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5764,7 +5764,7 @@ extern "C" SEXP _arrow_Scalar__type(SEXP s_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -R6 schema_(const std::vector>& fields); +std::shared_ptr schema_(const std::vector>& fields); extern "C" SEXP _arrow_schema_(SEXP fields_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type fields(fields_sexp); @@ -5809,7 +5809,7 @@ extern "C" SEXP _arrow_Schema__num_fields(SEXP s_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Schema__field(const std::shared_ptr& s, int i); +std::shared_ptr Schema__field(const std::shared_ptr& s, int i); extern "C" SEXP _arrow_Schema__field(SEXP s_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5825,7 +5825,7 @@ extern "C" SEXP _arrow_Schema__field(SEXP s_sexp, SEXP i_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x); +std::shared_ptr Schema__GetFieldByName(const std::shared_ptr& s, std::string x); extern "C" SEXP _arrow_Schema__GetFieldByName(SEXP s_sexp, SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type s(s_sexp); @@ -5901,7 +5901,7 @@ extern "C" SEXP _arrow_Schema__metadata(SEXP schema_sexp){ // schema.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Schema__WithMetadata(const std::shared_ptr& schema, cpp11::strings metadata); +std::shared_ptr Schema__WithMetadata(const std::shared_ptr& schema, cpp11::strings metadata); extern "C" SEXP _arrow_Schema__WithMetadata(SEXP schema_sexp, SEXP metadata_sexp){ BEGIN_CPP11 arrow::r::Input&>::type schema(schema_sexp); @@ -5949,7 +5949,7 @@ extern "C" SEXP _arrow_Schema__Equals(SEXP schema_sexp, SEXP other_sexp, SEXP ch // schema.cpp #if defined(ARROW_R_WITH_ARROW) -R6 arrow__UnifySchemas(const std::vector>& schemas); +std::shared_ptr arrow__UnifySchemas(const std::vector>& schemas); extern "C" SEXP _arrow_arrow__UnifySchemas(SEXP schemas_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type schemas(schemas_sexp); @@ -5994,7 +5994,7 @@ extern "C" SEXP _arrow_Table__num_rows(SEXP x_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__schema(const std::shared_ptr& x); +std::shared_ptr Table__schema(const std::shared_ptr& x); extern "C" SEXP _arrow_Table__schema(SEXP x_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -6009,7 +6009,7 @@ extern "C" SEXP _arrow_Table__schema(SEXP x_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); +std::shared_ptr Table__ReplaceSchemaMetadata(const std::shared_ptr& x, cpp11::strings metadata); extern "C" SEXP _arrow_Table__ReplaceSchemaMetadata(SEXP x_sexp, SEXP metadata_sexp){ BEGIN_CPP11 arrow::r::Input&>::type x(x_sexp); @@ -6025,7 +6025,7 @@ extern "C" SEXP _arrow_Table__ReplaceSchemaMetadata(SEXP x_sexp, SEXP metadata_s // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__column(const std::shared_ptr& table, R_xlen_t i); +std::shared_ptr Table__column(const std::shared_ptr& table, R_xlen_t i); extern "C" SEXP _arrow_Table__column(SEXP table_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6041,7 +6041,7 @@ extern "C" SEXP _arrow_Table__column(SEXP table_sexp, SEXP i_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__field(const std::shared_ptr& table, R_xlen_t i); +std::shared_ptr Table__field(const std::shared_ptr& table, R_xlen_t i); extern "C" SEXP _arrow_Table__field(SEXP table_sexp, SEXP i_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6087,7 +6087,7 @@ extern "C" SEXP _arrow_Table__ColumnNames(SEXP table_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__Slice1(const std::shared_ptr& table, R_xlen_t offset); +std::shared_ptr Table__Slice1(const std::shared_ptr& table, R_xlen_t offset); extern "C" SEXP _arrow_Table__Slice1(SEXP table_sexp, SEXP offset_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6103,7 +6103,7 @@ extern "C" SEXP _arrow_Table__Slice1(SEXP table_sexp, SEXP offset_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, R_xlen_t length); +std::shared_ptr Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, R_xlen_t length); extern "C" SEXP _arrow_Table__Slice2(SEXP table_sexp, SEXP offset_sexp, SEXP length_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6167,7 +6167,7 @@ extern "C" SEXP _arrow_Table__ValidateFull(SEXP table_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__GetColumnByName(const std::shared_ptr& table, const std::string& name); +std::shared_ptr Table__GetColumnByName(const std::shared_ptr& table, const std::string& name); extern "C" SEXP _arrow_Table__GetColumnByName(SEXP table_sexp, SEXP name_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6183,7 +6183,7 @@ extern "C" SEXP _arrow_Table__GetColumnByName(SEXP table_sexp, SEXP name_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__SelectColumns(const std::shared_ptr& table, const std::vector& indices); +std::shared_ptr Table__SelectColumns(const std::shared_ptr& table, const std::vector& indices); extern "C" SEXP _arrow_Table__SelectColumns(SEXP table_sexp, SEXP indices_sexp){ BEGIN_CPP11 arrow::r::Input&>::type table(table_sexp); @@ -6214,7 +6214,7 @@ extern "C" SEXP _arrow_all_record_batches(SEXP lst_sexp){ // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__from_record_batches(const std::vector>& batches, SEXP schema_sxp); +std::shared_ptr Table__from_record_batches(const std::vector>& batches, SEXP schema_sxp); extern "C" SEXP _arrow_Table__from_record_batches(SEXP batches_sexp, SEXP schema_sxp_sexp){ BEGIN_CPP11 arrow::r::Input>&>::type batches(batches_sexp); @@ -6230,7 +6230,7 @@ extern "C" SEXP _arrow_Table__from_record_batches(SEXP batches_sexp, SEXP schema // table.cpp #if defined(ARROW_R_WITH_ARROW) -R6 Table__from_dots(SEXP lst, SEXP schema_sxp); +std::shared_ptr Table__from_dots(SEXP lst, SEXP schema_sxp); extern "C" SEXP _arrow_Table__from_dots(SEXP lst_sexp, SEXP schema_sxp_sexp){ BEGIN_CPP11 arrow::r::Input::type lst(lst_sexp); diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index fb4c4dca090..f3e7cbcade4 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -22,10 +22,10 @@ #include #undef Free -#include "./nameof.h" - #include +#include "./nameof.h" + // borrowed from enc package // because R does not make these macros available (i.e. from Defn.h) #define UTF8_MASK (1 << 3) @@ -295,14 +295,10 @@ bool GetBoolOption(const std::string& name, bool default_); namespace cpp11 { template -std::string r6_class_name(const std::shared_ptr& x); +SEXP to_r6(const std::shared_ptr& ptr, const std::string& r_class_name) { + if (ptr == nullptr) return R_NilValue; -template -SEXP to_r6(const std::shared_ptr& x) { - if (x == nullptr) return R_NilValue; - - auto r_class_name = cpp11::r6_class_name(x); - cpp11::external_pointer> xp(new std::shared_ptr(x)); + cpp11::external_pointer> xp(new std::shared_ptr(ptr)); SEXP r6_class = Rf_install(r_class_name.c_str()); // make call: $new() @@ -315,8 +311,27 @@ SEXP to_r6(const std::shared_ptr& x) { UNPROTECT(3); return r6; } + +template +const char* r6_class_name(const std::shared_ptr&); + +template +SEXP to_r6(const std::shared_ptr& x) { + if (x == nullptr) return R_NilValue; + + return to_r6(x, cpp11::r6_class_name(x)); +} + } // namespace cpp11 +#define DEFAULT_R6_CLASS_NAME(CLASS, NAME) \ + namespace cpp11 { \ + template <> \ + const char* r6_class_name(const std::shared_ptr&) { \ + return NAME; \ + } \ + } + namespace arrow { namespace r { @@ -361,4 +376,9 @@ enable_if_enum as_sexp(E e) { return as_sexp(static_cast(e)); } +template +SEXP as_sexp(const std::shared_ptr& ptr) { + return cpp11::to_r6(ptr); +} + } // namespace cpp11 diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index 42dcf0acce3..38e4ad9edae 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -59,6 +59,11 @@ struct ParseOptions; } // namespace json +namespace dataset { +class DirectoryPartitioning; +class HivePartitioning; +} // namespace dataset + } // namespace arrow namespace parquet { diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index 502c1ca2465..0023a30a26f 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -36,8 +36,8 @@ SEXP ChunkedArray__as_vector(const std::shared_ptr& chunked_array); SEXP Array__as_vector(const std::shared_ptr& array); -R6 Array__from_vector(SEXP x, SEXP type); -R6 RecordBatch__from_arrays(SEXP, SEXP); +std::shared_ptr Array__from_vector(SEXP x, SEXP type); +std::shared_ptr RecordBatch__from_arrays(SEXP, SEXP); arrow::MemoryPool* gc_memory_pool(); namespace arrow { @@ -123,67 +123,11 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, namespace cpp11 { template <> -std::string r6_class_name(const std::shared_ptr& array); +const char* r6_class_name(const std::shared_ptr&); template <> -std::string r6_class_name(const std::shared_ptr& type); +const char* r6_class_name(const std::shared_ptr&); template <> -std::string r6_class_name(const std::shared_ptr& ptr); - -template <> -inline std::string r6_class_name( - const std::shared_ptr& array_data) { - return "Field"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& array_data) { - return "ArrayData"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& array) { - return "ChunkedArray"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& array) { - return "Buffer"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "Codec"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CompressedOutputStream"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CompressedInputStream"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "RecordBatch"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "Table"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "Schema"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "MemoryPool"; -} +const char* r6_class_name(const std::shared_ptr&); } // namespace cpp11 diff --git a/r/src/buffer.cpp b/r/src/buffer.cpp index e270efd48a1..5fc70b43784 100644 --- a/r/src/buffer.cpp +++ b/r/src/buffer.cpp @@ -40,7 +40,7 @@ int64_t Buffer__size(const std::shared_ptr& buffer) { } // [[arrow::export]] -R6 r___RBuffer__initialize(SEXP x) { +std::shared_ptr r___RBuffer__initialize(SEXP x) { std::shared_ptr out; switch (TYPEOF(x)) { case RAWSXP: diff --git a/r/src/chunkedarray.cpp b/r/src/chunkedarray.cpp index eda55a5483a..52ceff7d914 100644 --- a/r/src/chunkedarray.cpp +++ b/r/src/chunkedarray.cpp @@ -37,7 +37,8 @@ int ChunkedArray__num_chunks(const std::shared_ptr& chunked } // [[arrow::export]] -R6 ChunkedArray__chunk(const std::shared_ptr& chunked_array, int i) { +std::shared_ptr ChunkedArray__chunk( + const std::shared_ptr& chunked_array, int i) { arrow::r::validate_index(i, chunked_array->num_chunks()); return chunked_array->chunk(i); } @@ -49,28 +50,31 @@ cpp11::list ChunkedArray__chunks( } // [[arrow::export]] -R6 ChunkedArray__type(const std::shared_ptr& chunked_array) { +std::shared_ptr ChunkedArray__type( + const std::shared_ptr& chunked_array) { return chunked_array->type(); } // [[arrow::export]] -R6 ChunkedArray__Slice1(const std::shared_ptr& chunked_array, - R_xlen_t offset) { +std::shared_ptr ChunkedArray__Slice1( + const std::shared_ptr& chunked_array, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, chunked_array->length()); return chunked_array->Slice(offset); } // [[arrow::export]] -R6 ChunkedArray__Slice2(const std::shared_ptr& chunked_array, - R_xlen_t offset, R_xlen_t length) { +std::shared_ptr ChunkedArray__Slice2( + const std::shared_ptr& chunked_array, R_xlen_t offset, + R_xlen_t length) { arrow::r::validate_slice_offset(offset, chunked_array->length()); arrow::r::validate_slice_length(length, chunked_array->length() - offset); return chunked_array->Slice(offset, length); } // [[arrow::export]] -R6 ChunkedArray__View(const std::shared_ptr& array, - const std::shared_ptr& type) { +std::shared_ptr ChunkedArray__View( + const std::shared_ptr& array, + const std::shared_ptr& type) { return ValueOrStop(array->View(type)); } diff --git a/r/src/compression.cpp b/r/src/compression.cpp index 856eeedb274..18c63e4fd19 100644 --- a/r/src/compression.cpp +++ b/r/src/compression.cpp @@ -22,7 +22,8 @@ #include // [[arrow::export]] -R6 util___Codec__Create(arrow::Compression::type codec, R_xlen_t compression_level) { +std::shared_ptr util___Codec__Create(arrow::Compression::type codec, + R_xlen_t compression_level) { return ValueOrStop(arrow::util::Codec::Create(codec, compression_level)); } @@ -37,7 +38,7 @@ bool util___Codec__IsAvailable(arrow::Compression::type codec) { } // [[arrow::export]] -R6 io___CompressedOutputStream__Make( +std::shared_ptr io___CompressedOutputStream__Make( const std::shared_ptr& codec, const std::shared_ptr& raw) { return ValueOrStop( @@ -45,8 +46,9 @@ R6 io___CompressedOutputStream__Make( } // [[arrow::export]] -R6 io___CompressedInputStream__Make(const std::shared_ptr& codec, - const std::shared_ptr& raw) { +std::shared_ptr io___CompressedInputStream__Make( + const std::shared_ptr& codec, + const std::shared_ptr& raw) { return ValueOrStop( arrow::io::CompressedInputStream::Make(codec.get(), raw, gc_memory_pool())); } diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 1e8850fe24b..6e6d5f05897 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -23,13 +23,7 @@ #include #include -namespace cpp11 { -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CastOptions"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::compute::CastOptions, "CastOptions") arrow::compute::ExecContext* gc_context() { static arrow::compute::ExecContext context(gc_memory_pool()); @@ -37,8 +31,8 @@ arrow::compute::ExecContext* gc_context() { } // [[arrow::export]] -R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_truncate, - bool allow_float_truncate) { +std::shared_ptr compute___CastOptions__initialize( + bool allow_int_overflow, bool allow_time_truncate, bool allow_float_truncate) { auto options = std::make_shared(); options->allow_int_overflow = allow_int_overflow; options->allow_time_truncate = allow_time_truncate; @@ -47,16 +41,18 @@ R6 compute___CastOptions__initialize(bool allow_int_overflow, bool allow_time_tr } // [[arrow::export]] -R6 Array__cast(const std::shared_ptr& array, - const std::shared_ptr& target_type, - const std::shared_ptr& options) { +std::shared_ptr Array__cast( + const std::shared_ptr& array, + const std::shared_ptr& target_type, + const std::shared_ptr& options) { return ValueOrStop(arrow::compute::Cast(*array, target_type, *options, gc_context())); } // [[arrow::export]] -R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, - const std::shared_ptr& target_type, - const std::shared_ptr& options) { +std::shared_ptr ChunkedArray__cast( + const std::shared_ptr& chunked_array, + const std::shared_ptr& target_type, + const std::shared_ptr& options) { arrow::Datum value(chunked_array); arrow::Datum out = ValueOrStop(arrow::compute::Cast(value, target_type, *options, gc_context())); @@ -64,9 +60,10 @@ R6 ChunkedArray__cast(const std::shared_ptr& chunked_array, } // [[arrow::export]] -R6 RecordBatch__cast(const std::shared_ptr& batch, - const std::shared_ptr& schema, - const std::shared_ptr& options) { +std::shared_ptr RecordBatch__cast( + const std::shared_ptr& batch, + const std::shared_ptr& schema, + const std::shared_ptr& options) { auto nc = batch->num_columns(); arrow::ArrayVector columns(nc); @@ -79,9 +76,10 @@ R6 RecordBatch__cast(const std::shared_ptr& batch, } // [[arrow::export]] -R6 Table__cast(const std::shared_ptr& table, - const std::shared_ptr& schema, - const std::shared_ptr& options) { +std::shared_ptr Table__cast( + const std::shared_ptr& table, + const std::shared_ptr& schema, + const std::shared_ptr& options) { auto nc = table->num_columns(); using ColumnVector = std::vector>; diff --git a/r/src/csv.cpp b/r/src/csv.cpp index cd85179f079..9066116269e 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -22,36 +22,15 @@ #include #include -namespace cpp11 { -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CsvReadOptions"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CsvParseOptions"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CsvConvertOptions"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "CsvTableReader"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "TimestampParser"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::csv::ReadOptions, "CsvReadOptions") +DEFAULT_R6_CLASS_NAME(arrow::csv::ParseOptions, "CsvParseOptions") +DEFAULT_R6_CLASS_NAME(arrow::csv::ConvertOptions, "CsvConvertOptions") +DEFAULT_R6_CLASS_NAME(arrow::csv::TableReader, "CsvTableReader") +DEFAULT_R6_CLASS_NAME(arrow::TimestampParser, "TimestampParser") // [[arrow::export]] -R6 csv___ReadOptions__initialize(cpp11::list options) { +std::shared_ptr csv___ReadOptions__initialize( + cpp11::list options) { auto res = std::make_shared(arrow::csv::ReadOptions::Defaults()); res->use_threads = cpp11::as_cpp(options["use_threads"]); @@ -65,7 +44,8 @@ R6 csv___ReadOptions__initialize(cpp11::list options) { } // [[arrow::export]] -R6 csv___ParseOptions__initialize(cpp11::list options) { +std::shared_ptr csv___ParseOptions__initialize( + cpp11::list options) { auto res = std::make_shared(arrow::csv::ParseOptions::Defaults()); res->delimiter = cpp11::as_cpp(options["delimiter"]); @@ -89,7 +69,8 @@ SEXP csv___ReadOptions__column_names( } // [[arrow::export]] -R6 csv___ConvertOptions__initialize(cpp11::list options) { +std::shared_ptr csv___ConvertOptions__initialize( + cpp11::list options) { auto res = std::make_shared( arrow::csv::ConvertOptions::Defaults()); res->check_utf8 = cpp11::as_cpp(options["check_utf8"]); @@ -161,7 +142,7 @@ R6 csv___ConvertOptions__initialize(cpp11::list options) { } // [[arrow::export]] -R6 csv___TableReader__Make( +std::shared_ptr csv___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options, @@ -171,7 +152,8 @@ R6 csv___TableReader__Make( } // [[arrow::export]] -R6 csv___TableReader__Read(const std::shared_ptr& table_reader) { +std::shared_ptr csv___TableReader__Read( + const std::shared_ptr& table_reader) { return ValueOrStop(table_reader->Read()); } @@ -187,11 +169,14 @@ std::string TimestampParser__format( } // [[arrow::export]] -R6 TimestampParser__MakeStrptime(std::string format) { +std::shared_ptr TimestampParser__MakeStrptime( + std::string format) { return arrow::TimestampParser::MakeStrptime(format); } // [[arrow::export]] -R6 TimestampParser__MakeISO8601() { return arrow::TimestampParser::MakeISO8601(); } +std::shared_ptr TimestampParser__MakeISO8601() { + return arrow::TimestampParser::MakeISO8601(); +} #endif diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 9247d6f6ef0..6b43f79a4d0 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -28,10 +28,26 @@ namespace ds = ::arrow::dataset; namespace fs = ::arrow::fs; +DEFAULT_R6_CLASS_NAME(ds::UnionDataset, "UnionDataset") +DEFAULT_R6_CLASS_NAME(ds::InMemoryDataset, "InMemoryDataset") +DEFAULT_R6_CLASS_NAME(ds::FileSystemDataset, "FileSystemDataset") +DEFAULT_R6_CLASS_NAME(ds::ScannerBuilder, "ScannerBuilder") +DEFAULT_R6_CLASS_NAME(ds::DatasetFactory, "DatasetFactory") +DEFAULT_R6_CLASS_NAME(ds::FileSystemDatasetFactory, "FileSystemDatasetFactory") +DEFAULT_R6_CLASS_NAME(ds::PartitioningFactory, "PartitioningFactory") +DEFAULT_R6_CLASS_NAME(ds::ParquetFileFormat, "ParquetFileFormat") +DEFAULT_R6_CLASS_NAME(ds::IpcFileFormat, "IpcFileFormat") +DEFAULT_R6_CLASS_NAME(ds::CsvFileFormat, "CsvFileFormat") +DEFAULT_R6_CLASS_NAME(ds::DirectoryPartitioning, "DirectoryPartitioning") +DEFAULT_R6_CLASS_NAME(ds::HivePartitioning, "HivePartitioning") +DEFAULT_R6_CLASS_NAME(ds::Scanner, "Scanner") +DEFAULT_R6_CLASS_NAME(ds::ScanTask, "ScanTask") +DEFAULT_R6_CLASS_NAME(ds::FileWriteOptions, "FileWriteOptions") + namespace cpp11 { template <> -std::string r6_class_name(const std::shared_ptr& dataset) { +const char* r6_class_name(const std::shared_ptr& dataset) { auto type_name = dataset->type_name(); if (type_name == "union") { @@ -44,24 +60,9 @@ std::string r6_class_name(const std::shared_ptr& datas return "Dataset"; } } -template <> -std::string r6_class_name( - const std::shared_ptr& dataset) { - return "UnionDataset"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& dataset) { - return "InMemoryDataset"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& dataset) { - return "FileSystemDataset"; -} template <> -std::string r6_class_name( +const char* r6_class_name( const std::shared_ptr& file_system) { auto type_name = file_system->type_name(); @@ -77,7 +78,7 @@ std::string r6_class_name( } template <> -std::string r6_class_name( +const char* r6_class_name( const std::shared_ptr& file_format) { auto type_name = file_format->type_name(); if (type_name == "parquet") { @@ -90,79 +91,22 @@ std::string r6_class_name( return "FileFormat"; } } -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ScannerBuilder"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "DatasetFactory"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "FileSystemDatasetFactory"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "PartitioningFactory"; -} - -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetFileFormat"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "IpcFileFormat"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "CsvFileFormat"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "DirectoryPartitioning"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "HivePartitioning"; -} -template <> -std::string r6_class_name(const std::shared_ptr& x) { - return "Scanner"; -} -template <> -std::string r6_class_name(const std::shared_ptr& x) { - return "ScanTask"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "FileWriteOptions"; -} } // namespace cpp11 // Dataset, UnionDataset, FileSystemDataset // [[arrow::export]] -R6 dataset___Dataset__NewScan(const std::shared_ptr& ds) { +std::shared_ptr dataset___Dataset__NewScan( + const std::shared_ptr& ds) { auto context = std::make_shared(); context->pool = gc_memory_pool(); return ValueOrStop(ds->NewScan(std::move(context))); } // [[arrow::export]] -R6 dataset___Dataset__schema(const std::shared_ptr& dataset) { +std::shared_ptr dataset___Dataset__schema( + const std::shared_ptr& dataset) { return dataset->schema(); } @@ -172,19 +116,21 @@ std::string dataset___Dataset__type_name(const std::shared_ptr& dat } // [[arrow::export]] -R6 dataset___Dataset__ReplaceSchema(const std::shared_ptr& dataset, - const std::shared_ptr& schm) { +std::shared_ptr dataset___Dataset__ReplaceSchema( + const std::shared_ptr& dataset, + const std::shared_ptr& schm) { return ValueOrStop(dataset->ReplaceSchema(schm)); } // [[arrow::export]] -R6 dataset___UnionDataset__create(const ds::DatasetVector& datasets, - const std::shared_ptr& schm) { +std::shared_ptr dataset___UnionDataset__create( + const ds::DatasetVector& datasets, const std::shared_ptr& schm) { return ValueOrStop(ds::UnionDataset::Make(schm, datasets)); } // [[arrow::export]] -R6 dataset___InMemoryDataset__create(const std::shared_ptr& table) { +std::shared_ptr dataset___InMemoryDataset__create( + const std::shared_ptr& table) { return std::make_shared(table); } @@ -195,13 +141,13 @@ cpp11::list dataset___UnionDataset__children( } // [[arrow::export]] -R6 dataset___FileSystemDataset__format( +std::shared_ptr dataset___FileSystemDataset__format( const std::shared_ptr& dataset) { return dataset->format(); } // [[arrow::export]] -R6 dataset___FileSystemDataset__filesystem( +std::shared_ptr dataset___FileSystemDataset__filesystem( const std::shared_ptr& dataset) { return dataset->filesystem(); } @@ -215,8 +161,8 @@ std::vector dataset___FileSystemDataset__files( // DatasetFactory, UnionDatasetFactory, FileSystemDatasetFactory // [[arrow::export]] -R6 dataset___DatasetFactory__Finish1(const std::shared_ptr& factory, - bool unify_schemas) { +std::shared_ptr dataset___DatasetFactory__Finish1( + const std::shared_ptr& factory, bool unify_schemas) { ds::FinishOptions opts; if (unify_schemas) { opts.inspect_options.fragments = ds::InspectOptions::kInspectAllFragments; @@ -225,14 +171,15 @@ R6 dataset___DatasetFactory__Finish1(const std::shared_ptr& } // [[arrow::export]] -R6 dataset___DatasetFactory__Finish2(const std::shared_ptr& factory, - const std::shared_ptr& schema) { +std::shared_ptr dataset___DatasetFactory__Finish2( + const std::shared_ptr& factory, + const std::shared_ptr& schema) { return ValueOrStop(factory->Finish(schema)); } // [[arrow::export]] -R6 dataset___DatasetFactory__Inspect(const std::shared_ptr& factory, - bool unify_schemas) { +std::shared_ptr dataset___DatasetFactory__Inspect( + const std::shared_ptr& factory, bool unify_schemas) { ds::InspectOptions opts; if (unify_schemas) { opts.fragments = ds::InspectOptions::kInspectAllFragments; @@ -241,13 +188,13 @@ R6 dataset___DatasetFactory__Inspect(const std::shared_ptr& } // [[arrow::export]] -R6 dataset___UnionDatasetFactory__Make( +std::shared_ptr dataset___UnionDatasetFactory__Make( const std::vector>& children) { return ValueOrStop(ds::UnionDatasetFactory::Make(children)); } // [[arrow::export]] -R6 dataset___FileSystemDatasetFactory__Make2( +std::shared_ptr dataset___FileSystemDatasetFactory__Make2( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, @@ -262,7 +209,7 @@ R6 dataset___FileSystemDatasetFactory__Make2( } // [[arrow::export]] -R6 dataset___FileSystemDatasetFactory__Make1( +std::shared_ptr dataset___FileSystemDatasetFactory__Make1( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format) { @@ -270,7 +217,7 @@ R6 dataset___FileSystemDatasetFactory__Make1( } // [[arrow::export]] -R6 dataset___FileSystemDatasetFactory__Make3( +std::shared_ptr dataset___FileSystemDatasetFactory__Make3( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, @@ -293,13 +240,14 @@ std::string dataset___FileFormat__type_name( } // [[arrow::export]] -R6 dataset___FileFormat__DefaultWriteOptions(const std::shared_ptr& fmt) { +std::shared_ptr dataset___FileFormat__DefaultWriteOptions( + const std::shared_ptr& fmt) { return fmt->DefaultWriteOptions(); } // [[arrow::export]] -R6 dataset___ParquetFileFormat__Make(bool use_buffered_stream, int64_t buffer_size, - cpp11::strings dict_columns) { +std::shared_ptr dataset___ParquetFileFormat__Make( + bool use_buffered_stream, int64_t buffer_size, cpp11::strings dict_columns) { auto fmt = std::make_shared(); fmt->reader_options.use_buffered_stream = use_buffered_stream; @@ -347,10 +295,12 @@ void dataset___IpcFileWriteOptions__update1( } // [[arrow::export]] -R6 dataset___IpcFileFormat__Make() { return std::make_shared(); } +std::shared_ptr dataset___IpcFileFormat__Make() { + return std::make_shared(); +} // [[arrow::export]] -R6 dataset___CsvFileFormat__Make( +std::shared_ptr dataset___CsvFileFormat__Make( const std::shared_ptr& parse_options) { auto format = std::make_shared(); format->parse_options = *parse_options; @@ -360,23 +310,25 @@ R6 dataset___CsvFileFormat__Make( // DirectoryPartitioning, HivePartitioning // [[arrow::export]] -R6 dataset___DirectoryPartitioning(const std::shared_ptr& schm) { +std::shared_ptr dataset___DirectoryPartitioning( + const std::shared_ptr& schm) { return std::make_shared(schm); } // [[arrow::export]] -R6 dataset___DirectoryPartitioning__MakeFactory( +std::shared_ptr dataset___DirectoryPartitioning__MakeFactory( const std::vector& field_names) { return ds::DirectoryPartitioning::MakeFactory(field_names); } // [[arrow::export]] -R6 dataset___HivePartitioning(const std::shared_ptr& schm) { +std::shared_ptr dataset___HivePartitioning( + const std::shared_ptr& schm) { return std::make_shared(schm); } // [[arrow::export]] -R6 dataset___HivePartitioning__MakeFactory() { +std::shared_ptr dataset___HivePartitioning__MakeFactory() { return ds::HivePartitioning::MakeFactory(); } @@ -410,22 +362,26 @@ void dataset___ScannerBuilder__BatchSize(const std::shared_ptr& sb) { +std::shared_ptr dataset___ScannerBuilder__schema( + const std::shared_ptr& sb) { return sb->schema(); } // [[arrow::export]] -R6 dataset___ScannerBuilder__Finish(const std::shared_ptr& sb) { +std::shared_ptr dataset___ScannerBuilder__Finish( + const std::shared_ptr& sb) { return ValueOrStop(sb->Finish()); } // [[arrow::export]] -R6 dataset___Scanner__ToTable(const std::shared_ptr& scanner) { +std::shared_ptr dataset___Scanner__ToTable( + const std::shared_ptr& scanner) { return ValueOrStop(scanner->ToTable()); } // [[arrow::export]] -R6 dataset___Scanner__head(const std::shared_ptr& scanner, int n) { +std::shared_ptr dataset___Scanner__head( + const std::shared_ptr& scanner, int n) { // TODO: make this a full Slice with offset > 0 std::vector> batches; std::shared_ptr current_batch; @@ -457,7 +413,8 @@ cpp11::list dataset___Scanner__Scan(const std::shared_ptr& scanner) } // [[arrow::export]] -R6 dataset___Scanner__schema(const std::shared_ptr& sc) { +std::shared_ptr dataset___Scanner__schema( + const std::shared_ptr& sc) { return sc->schema(); } diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index 721090dcc11..c4852524339 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -22,7 +22,7 @@ namespace cpp11 { template <> -std::string r6_class_name(const std::shared_ptr& type) { +const char* r6_class_name(const std::shared_ptr& type) { using arrow::Type; switch (type->id()) { @@ -99,84 +99,86 @@ std::string r6_class_name(const std::shared_ptr Int8__initialize() { return arrow::int8(); } // [[arrow::export]] -R6 Int16__initialize() { return arrow::int16(); } +std::shared_ptr Int16__initialize() { return arrow::int16(); } // [[arrow::export]] -R6 Int32__initialize() { return arrow::int32(); } +std::shared_ptr Int32__initialize() { return arrow::int32(); } // [[arrow::export]] -R6 Int64__initialize() { return arrow::int64(); } +std::shared_ptr Int64__initialize() { return arrow::int64(); } // [[arrow::export]] -R6 UInt8__initialize() { return arrow::uint8(); } +std::shared_ptr UInt8__initialize() { return arrow::uint8(); } // [[arrow::export]] -R6 UInt16__initialize() { return arrow::uint16(); } +std::shared_ptr UInt16__initialize() { return arrow::uint16(); } // [[arrow::export]] -R6 UInt32__initialize() { return arrow::uint32(); } +std::shared_ptr UInt32__initialize() { return arrow::uint32(); } // [[arrow::export]] -R6 UInt64__initialize() { return arrow::uint64(); } +std::shared_ptr UInt64__initialize() { return arrow::uint64(); } // [[arrow::export]] -R6 Float16__initialize() { return arrow::float16(); } +std::shared_ptr Float16__initialize() { return arrow::float16(); } // [[arrow::export]] -R6 Float32__initialize() { return arrow::float32(); } +std::shared_ptr Float32__initialize() { return arrow::float32(); } // [[arrow::export]] -R6 Float64__initialize() { return arrow::float64(); } +std::shared_ptr Float64__initialize() { return arrow::float64(); } // [[arrow::export]] -R6 Boolean__initialize() { return arrow::boolean(); } +std::shared_ptr Boolean__initialize() { return arrow::boolean(); } // [[arrow::export]] -R6 Utf8__initialize() { return arrow::utf8(); } +std::shared_ptr Utf8__initialize() { return arrow::utf8(); } // [[arrow::export]] -R6 LargeUtf8__initialize() { return arrow::large_utf8(); } +std::shared_ptr LargeUtf8__initialize() { return arrow::large_utf8(); } // [[arrow::export]] -R6 Binary__initialize() { return arrow::binary(); } +std::shared_ptr Binary__initialize() { return arrow::binary(); } // [[arrow::export]] -R6 LargeBinary__initialize() { return arrow::large_binary(); } +std::shared_ptr LargeBinary__initialize() { + return arrow::large_binary(); +} // [[arrow::export]] -R6 Date32__initialize() { return arrow::date32(); } +std::shared_ptr Date32__initialize() { return arrow::date32(); } // [[arrow::export]] -R6 Date64__initialize() { return arrow::date64(); } +std::shared_ptr Date64__initialize() { return arrow::date64(); } // [[arrow::export]] -R6 Null__initialize() { return arrow::null(); } +std::shared_ptr Null__initialize() { return arrow::null(); } // [[arrow::export]] -R6 Decimal128Type__initialize(int32_t precision, int32_t scale) { +std::shared_ptr Decimal128Type__initialize(int32_t precision, + int32_t scale) { // Use the builder that validates inputs return ValueOrStop(arrow::Decimal128Type::Make(precision, scale)); } // [[arrow::export]] -R6 FixedSizeBinary__initialize(R_xlen_t byte_width) { +std::shared_ptr FixedSizeBinary__initialize(R_xlen_t byte_width) { if (byte_width == NA_INTEGER) { cpp11::stop("'byte_width' cannot be NA"); } @@ -187,66 +189,69 @@ R6 FixedSizeBinary__initialize(R_xlen_t byte_width) { } // [[arrow::export]] -R6 Timestamp__initialize(arrow::TimeUnit::type unit, const std::string& timezone) { +std::shared_ptr Timestamp__initialize(arrow::TimeUnit::type unit, + const std::string& timezone) { return arrow::timestamp(unit, timezone); } // [[arrow::export]] -R6 Time32__initialize(arrow::TimeUnit::type unit) { return arrow::time32(unit); } +std::shared_ptr Time32__initialize(arrow::TimeUnit::type unit) { + return arrow::time32(unit); +} // [[arrow::export]] -R6 Time64__initialize(arrow::TimeUnit::type unit) { return arrow::time64(unit); } +std::shared_ptr Time64__initialize(arrow::TimeUnit::type unit) { + return arrow::time64(unit); +} // [[arrow::export]] -R6 list__(SEXP x) { +std::shared_ptr list__(SEXP x) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); return arrow::list(field); } - if (Rf_inherits(x, "DataType")) { - auto type = cpp11::as_cpp>(x); - return arrow::list(type); + if (!Rf_inherits(x, "DataType")) { + cpp11::stop("incompatible"); } - cpp11::stop("incompatible"); - return R_NilValue; + auto type = cpp11::as_cpp>(x); + return arrow::list(type); } // [[arrow::export]] -R6 large_list__(SEXP x) { +std::shared_ptr large_list__(SEXP x) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); return arrow::large_list(field); } - if (Rf_inherits(x, "DataType")) { - auto type = cpp11::as_cpp>(x); - return arrow::large_list(type); + if (!Rf_inherits(x, "DataType")) { + cpp11::stop("incompatible"); } - cpp11::stop("incompatible"); - return R_NilValue; + auto type = cpp11::as_cpp>(x); + return arrow::large_list(type); } // [[arrow::export]] -R6 fixed_size_list__(SEXP x, int list_size) { +std::shared_ptr fixed_size_list__(SEXP x, int list_size) { if (Rf_inherits(x, "Field")) { auto field = cpp11::as_cpp>(x); return arrow::fixed_size_list(field, list_size); } - if (Rf_inherits(x, "DataType")) { - auto type = cpp11::as_cpp>(x); - return arrow::fixed_size_list(type, list_size); + if (!Rf_inherits(x, "DataType")) { + cpp11::stop("incompatible"); } - cpp11::stop("incompatible"); - return R_NilValue; + auto type = cpp11::as_cpp>(x); + return arrow::fixed_size_list(type, list_size); } // [[arrow::export]] -R6 struct__(const std::vector>& fields) { +std::shared_ptr struct__( + const std::vector>& fields) { return arrow::struct_(fields); } @@ -323,19 +328,21 @@ arrow::TimeUnit::type TimestampType__unit( } // [[arrow::export]] -R6 DictionaryType__initialize(const std::shared_ptr& index_type, - const std::shared_ptr& value_type, - bool ordered) { +std::shared_ptr DictionaryType__initialize( + const std::shared_ptr& index_type, + const std::shared_ptr& value_type, bool ordered) { return ValueOrStop(arrow::DictionaryType::Make(index_type, value_type, ordered)); } // [[arrow::export]] -R6 DictionaryType__index_type(const std::shared_ptr& type) { +std::shared_ptr DictionaryType__index_type( + const std::shared_ptr& type) { return type->index_type(); } // [[arrow::export]] -R6 DictionaryType__value_type(const std::shared_ptr& type) { +std::shared_ptr DictionaryType__value_type( + const std::shared_ptr& type) { return type->value_type(); } @@ -350,8 +357,8 @@ bool DictionaryType__ordered(const std::shared_ptr& type) } // [[arrow::export]] -R6 StructType__GetFieldByName(const std::shared_ptr& type, - const std::string& name) { +std::shared_ptr StructType__GetFieldByName( + const std::shared_ptr& type, const std::string& name) { return type->GetFieldByName(name); } @@ -362,32 +369,38 @@ int StructType__GetFieldIndex(const std::shared_ptr& type, } // [[arrow::export]] -R6 ListType__value_field(const std::shared_ptr& type) { +std::shared_ptr ListType__value_field( + const std::shared_ptr& type) { return type->value_field(); } // [[arrow::export]] -R6 ListType__value_type(const std::shared_ptr& type) { +std::shared_ptr ListType__value_type( + const std::shared_ptr& type) { return type->value_type(); } // [[arrow::export]] -R6 LargeListType__value_field(const std::shared_ptr& type) { +std::shared_ptr LargeListType__value_field( + const std::shared_ptr& type) { return type->value_field(); } // [[arrow::export]] -R6 LargeListType__value_type(const std::shared_ptr& type) { +std::shared_ptr LargeListType__value_type( + const std::shared_ptr& type) { return type->value_type(); } // [[arrow::export]] -R6 FixedSizeListType__value_field(const std::shared_ptr& type) { +std::shared_ptr FixedSizeListType__value_field( + const std::shared_ptr& type) { return type->value_field(); } // [[arrow::export]] -R6 FixedSizeListType__value_type(const std::shared_ptr& type) { +std::shared_ptr FixedSizeListType__value_type( + const std::shared_ptr& type) { return type->value_type(); } diff --git a/r/src/expression.cpp b/r/src/expression.cpp index 03d190cac14..5164ed29bae 100644 --- a/r/src/expression.cpp +++ b/r/src/expression.cpp @@ -22,88 +22,92 @@ #include namespace ds = ::arrow::dataset; -namespace cpp11 { -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "Expression"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "Expression"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(ds::Expression, "Expression") +DEFAULT_R6_CLASS_NAME(ds::ComparisonExpression, "Expression") // [[arrow::export]] -R6 dataset___expr__field_ref(std::string name) { return ds::field_ref(std::move(name)); } +std::shared_ptr dataset___expr__field_ref(std::string name) { + return ds::field_ref(std::move(name)); +} // [[arrow::export]] -R6 dataset___expr__equal(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__equal( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::equal(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__not_equal(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__not_equal( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::not_equal(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__greater(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__greater( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::greater(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__greater_equal(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__greater_equal( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::greater_equal(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__less(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__less( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::less(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__less_equal(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__less_equal( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::less_equal(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__in(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__in( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return lhs->In(rhs).Copy(); } // [[arrow::export]] -R6 dataset___expr__and(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__and( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::and_(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__or(const std::shared_ptr& lhs, - const std::shared_ptr& rhs) { +std::shared_ptr dataset___expr__or( + const std::shared_ptr& lhs, + const std::shared_ptr& rhs) { return ds::or_(lhs, rhs); } // [[arrow::export]] -R6 dataset___expr__not(const std::shared_ptr& lhs) { +std::shared_ptr dataset___expr__not( + const std::shared_ptr& lhs) { return ds::not_(lhs); } // [[arrow::export]] -R6 dataset___expr__is_valid(const std::shared_ptr& lhs) { +std::shared_ptr dataset___expr__is_valid( + const std::shared_ptr& lhs) { return lhs->IsValid().Copy(); } // [[arrow::export]] -R6 dataset___expr__scalar(const std::shared_ptr& x) { +std::shared_ptr dataset___expr__scalar( + const std::shared_ptr& x) { return ds::scalar(x); } diff --git a/r/src/feather.cpp b/r/src/feather.cpp index 60a77183aec..dab2c0504e3 100644 --- a/r/src/feather.cpp +++ b/r/src/feather.cpp @@ -21,13 +21,7 @@ #include #include -namespace cpp11 { -template <> -inline std::string r6_class_name( - const std::shared_ptr& codec) { - return "FeatherReader"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::ipc::feather::Reader, "FeatherReader") // ---------- WriteFeather @@ -55,7 +49,7 @@ int ipc___feather___Reader__version( } // [[arrow::export]] -R6 ipc___feather___Reader__Read( +std::shared_ptr ipc___feather___Reader__Read( const std::shared_ptr& reader, SEXP columns) { std::shared_ptr table; @@ -81,7 +75,7 @@ R6 ipc___feather___Reader__Read( } // [[arrow::export]] -R6 ipc___feather___Reader__Open( +std::shared_ptr ipc___feather___Reader__Open( const std::shared_ptr& stream) { return ValueOrStop(arrow::ipc::feather::Reader::Open(stream)); } diff --git a/r/src/field.cpp b/r/src/field.cpp index e7f24fb5a28..914d270c6f4 100644 --- a/r/src/field.cpp +++ b/r/src/field.cpp @@ -21,9 +21,9 @@ #include // [[arrow::export]] -R6 Field__initialize(const std::string& name, - const std::shared_ptr& field, - bool nullable = true) { +std::shared_ptr Field__initialize( + const std::string& name, const std::shared_ptr& field, + bool nullable = true) { return arrow::field(name, field, nullable); } @@ -49,6 +49,8 @@ bool Field__nullable(const std::shared_ptr& field) { } // [[arrow::export]] -R6 Field__type(const std::shared_ptr& field) { return field->type(); } +std::shared_ptr Field__type(const std::shared_ptr& field) { + return field->type(); +} #endif diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 8141b47478c..fd849ced63e 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -24,41 +24,13 @@ namespace fs = ::arrow::fs; -namespace cpp11 { -template <> -std::string r6_class_name(const std::shared_ptr& x) { - return "FileSelector"; -} -template <> -std::string r6_class_name(const std::shared_ptr& x) { - return "FileInfo"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "InputStream"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "OutputStream"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "RandomAccessFile"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "LocalFileSystem"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "SubTreeFileSystem"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(fs::FileSelector, "FileSelector") +DEFAULT_R6_CLASS_NAME(fs::FileInfo, "FileInfo") +DEFAULT_R6_CLASS_NAME(arrow::io::InputStream, "InputStream") +DEFAULT_R6_CLASS_NAME(arrow::io::OutputStream, "OutputStream") +DEFAULT_R6_CLASS_NAME(arrow::io::RandomAccessFile, "RandomAccessFile") +DEFAULT_R6_CLASS_NAME(fs::LocalFileSystem, "LocalFileSystem") +DEFAULT_R6_CLASS_NAME(fs::SubTreeFileSystem, "SubTreeFileSystem") // [[arrow::export]] fs::FileType fs___FileInfo__type(const std::shared_ptr& x) { @@ -136,8 +108,9 @@ bool fs___FileSelector__recursive(const std::shared_ptr& selec } // [[arrow::export]] -R6 fs___FileSelector__create(const std::string& base_dir, bool allow_not_found, - bool recursive) { +std::shared_ptr fs___FileSelector__create(const std::string& base_dir, + bool allow_not_found, + bool recursive) { auto selector = std::make_shared(); selector->base_dir = base_dir; selector->allow_not_found = allow_not_found; @@ -215,26 +188,26 @@ void fs___FileSystem__CopyFile(const std::shared_ptr& file_syste } // [[arrow::export]] -R6 fs___FileSystem__OpenInputStream(const std::shared_ptr& file_system, - const std::string& path) { +std::shared_ptr fs___FileSystem__OpenInputStream( + const std::shared_ptr& file_system, const std::string& path) { return ValueOrStop(file_system->OpenInputStream(path)); } // [[arrow::export]] -R6 fs___FileSystem__OpenInputFile(const std::shared_ptr& file_system, - const std::string& path) { +std::shared_ptr fs___FileSystem__OpenInputFile( + const std::shared_ptr& file_system, const std::string& path) { return ValueOrStop(file_system->OpenInputFile(path)); } // [[arrow::export]] -R6 fs___FileSystem__OpenOutputStream(const std::shared_ptr& file_system, - const std::string& path) { +std::shared_ptr fs___FileSystem__OpenOutputStream( + const std::shared_ptr& file_system, const std::string& path) { return ValueOrStop(file_system->OpenOutputStream(path)); } // [[arrow::export]] -R6 fs___FileSystem__OpenAppendStream(const std::shared_ptr& file_system, - const std::string& path) { +std::shared_ptr fs___FileSystem__OpenAppendStream( + const std::shared_ptr& file_system, const std::string& path) { return ValueOrStop(file_system->OpenAppendStream(path)); } @@ -245,16 +218,18 @@ std::string fs___FileSystem__type_name( } // [[arrow::export]] -R6 fs___LocalFileSystem__create() { return std::make_shared(); } +std::shared_ptr fs___LocalFileSystem__create() { + return std::make_shared(); +} // [[arrow::export]] -R6 fs___SubTreeFileSystem__create(const std::string& base_path, - const std::shared_ptr& base_fs) { +std::shared_ptr fs___SubTreeFileSystem__create( + const std::string& base_path, const std::shared_ptr& base_fs) { return std::make_shared(base_path, base_fs); } // [[arrow::export]] -R6 fs___SubTreeFileSystem__base_fs( +std::shared_ptr fs___SubTreeFileSystem__base_fs( const std::shared_ptr& file_system) { return file_system->base_fs(); } @@ -291,12 +266,12 @@ void fs___CopyFiles(const std::shared_ptr& source_fs, #include // [[s3::export]] -R6 fs___S3FileSystem__create(bool anonymous = false, std::string access_key = "", - std::string secret_key = "", std::string session_token = "", - std::string role_arn = "", std::string session_name = "", - std::string external_id = "", int load_frequency = 900, - std::string region = "", std::string endpoint_override = "", - std::string scheme = "", bool background_writes = true) { +std::shared_ptr fs___S3FileSystem__create( + bool anonymous = false, std::string access_key = "", std::string secret_key = "", + std::string session_token = "", std::string role_arn = "", + std::string session_name = "", std::string external_id = "", int load_frequency = 900, + std::string region = "", std::string endpoint_override = "", std::string scheme = "", + bool background_writes = true) { fs::S3Options s3_opts; // Handle auth (anonymous, keys, default) // (validation/internal coherence handled in R) @@ -327,7 +302,7 @@ R6 fs___S3FileSystem__create(bool anonymous = false, std::string access_key = "" s3_opts.background_writes = background_writes; StopIfNotOk(fs::EnsureS3Initialized()); - return cpp11::r6(ValueOrStop(fs::S3FileSystem::Make(s3_opts)), "S3FileSystem"); + return ValueOrStop(fs::S3FileSystem::Make(s3_opts)); } // [[s3::export]] diff --git a/r/src/io.cpp b/r/src/io.cpp index f8e002670a5..05e9a2654d9 100644 --- a/r/src/io.cpp +++ b/r/src/io.cpp @@ -21,38 +21,17 @@ #include #include -namespace cpp11 { -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "MemoryMappedFile"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "ReadableFile"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "BufferReader"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "FileOutputStream"; -} -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "BufferOutputStream"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::io::MemoryMappedFile, "MemoryMappedFile") +DEFAULT_R6_CLASS_NAME(arrow::io::ReadableFile, "ReadableFile") +DEFAULT_R6_CLASS_NAME(arrow::io::BufferReader, "BufferReader") +DEFAULT_R6_CLASS_NAME(arrow::io::FileOutputStream, "FileOutputStream") +DEFAULT_R6_CLASS_NAME(arrow::io::BufferOutputStream, "BufferOutputStream") // ------ arrow::io::Readable // [[arrow::export]] -R6 io___Readable__Read(const std::shared_ptr& x, int64_t nbytes) { +std::shared_ptr io___Readable__Read( + const std::shared_ptr& x, int64_t nbytes) { return ValueOrStop(x->Read(nbytes)); } @@ -97,7 +76,8 @@ int64_t io___RandomAccessFile__Tell( } // [[arrow::export]] -R6 io___RandomAccessFile__Read0(const std::shared_ptr& x) { +std::shared_ptr io___RandomAccessFile__Read0( + const std::shared_ptr& x) { int64_t current = ValueOrStop(x->Tell()); int64_t n = ValueOrStop(x->GetSize()); @@ -106,20 +86,23 @@ R6 io___RandomAccessFile__Read0(const std::shared_ptr& x, - int64_t position, int64_t nbytes) { +std::shared_ptr io___RandomAccessFile__ReadAt( + const std::shared_ptr& x, int64_t position, + int64_t nbytes) { return ValueOrStop(x->ReadAt(position, nbytes)); } // ------ arrow::io::MemoryMappedFile // [[arrow::export]] -R6 io___MemoryMappedFile__Create(const std::string& path, int64_t size) { +std::shared_ptr io___MemoryMappedFile__Create( + const std::string& path, int64_t size) { return ValueOrStop(arrow::io::MemoryMappedFile::Create(path, size)); } // [[arrow::export]] -R6 io___MemoryMappedFile__Open(const std::string& path, arrow::io::FileMode::type mode) { +std::shared_ptr io___MemoryMappedFile__Open( + const std::string& path, arrow::io::FileMode::type mode) { return ValueOrStop(arrow::io::MemoryMappedFile::Open(path, mode)); } @@ -132,14 +115,16 @@ void io___MemoryMappedFile__Resize(const std::shared_ptr io___ReadableFile__Open( + const std::string& path) { return ValueOrStop(arrow::io::ReadableFile::Open(path, gc_memory_pool())); } // ------ arrow::io::BufferReader // [[arrow::export]] -R6 io___BufferReader__initialize(const std::shared_ptr& buffer) { +std::shared_ptr io___BufferReader__initialize( + const std::shared_ptr& buffer) { return std::make_shared(buffer); } @@ -161,14 +146,16 @@ int64_t io___OutputStream__Tell(const std::shared_ptr& // ------ arrow::io::FileOutputStream // [[arrow::export]] -R6 io___FileOutputStream__Open(const std::string& path) { +std::shared_ptr io___FileOutputStream__Open( + const std::string& path) { return ValueOrStop(arrow::io::FileOutputStream::Open(path)); } // ------ arrow::BufferOutputStream // [[arrow::export]] -R6 io___BufferOutputStream__Create(int64_t initial_capacity) { +std::shared_ptr io___BufferOutputStream__Create( + int64_t initial_capacity) { return ValueOrStop( arrow::io::BufferOutputStream::Create(initial_capacity, gc_memory_pool())); } @@ -180,7 +167,7 @@ int64_t io___BufferOutputStream__capacity( } // [[arrow::export]] -R6 io___BufferOutputStream__Finish( +std::shared_ptr io___BufferOutputStream__Finish( const std::shared_ptr& stream) { return ValueOrStop(stream->Finish()); } diff --git a/r/src/json.cpp b/r/src/json.cpp index 5164541d394..b94b3961f18 100644 --- a/r/src/json.cpp +++ b/r/src/json.cpp @@ -20,26 +20,13 @@ #include -namespace cpp11 { -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "JsonReadOptions"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "JsonParseOptions"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "JsonTableReader"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::json::ReadOptions, "JsonReadOptions") +DEFAULT_R6_CLASS_NAME(arrow::json::ParseOptions, "JsonParseOptions") +DEFAULT_R6_CLASS_NAME(arrow::json::TableReader, "JsonTableReader") // [[arrow::export]] -R6 json___ReadOptions__initialize(bool use_threads, int block_size) { +std::shared_ptr json___ReadOptions__initialize(bool use_threads, + int block_size) { auto res = std::make_shared(arrow::json::ReadOptions::Defaults()); res->use_threads = use_threads; @@ -48,7 +35,8 @@ R6 json___ReadOptions__initialize(bool use_threads, int block_size) { } // [[arrow::export]] -R6 json___ParseOptions__initialize(bool newlines_in_values) { +std::shared_ptr json___ParseOptions__initialize( + bool newlines_in_values) { auto res = std::make_shared(arrow::json::ParseOptions::Defaults()); res->newlines_in_values = newlines_in_values; @@ -56,7 +44,7 @@ R6 json___ParseOptions__initialize(bool newlines_in_values) { } // [[arrow::export]] -R6 json___TableReader__Make( +std::shared_ptr json___TableReader__Make( const std::shared_ptr& input, const std::shared_ptr& read_options, const std::shared_ptr& parse_options) { @@ -65,7 +53,7 @@ R6 json___TableReader__Make( } // [[arrow::export]] -R6 json___TableReader__Read( +std::shared_ptr json___TableReader__Read( const std::shared_ptr& table_reader) { return ValueOrStop(table_reader->Read()); } diff --git a/r/src/memorypool.cpp b/r/src/memorypool.cpp index b7db62a9682..1345d0b7446 100644 --- a/r/src/memorypool.cpp +++ b/r/src/memorypool.cpp @@ -65,7 +65,7 @@ static GcMemoryPool g_pool; arrow::MemoryPool* gc_memory_pool() { return &g_pool; } // [[arrow::export]] -R6 MemoryPool__default() { +std::shared_ptr MemoryPool__default() { return std::shared_ptr(&g_pool, [](...) {}); } diff --git a/r/src/message.cpp b/r/src/message.cpp index c64418bf573..febbf0753ac 100644 --- a/r/src/message.cpp +++ b/r/src/message.cpp @@ -21,18 +21,8 @@ #include #include -namespace cpp11 { -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "MessageReader"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "Message"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::ipc::MessageReader, "MessageReader") +DEFAULT_R6_CLASS_NAME(arrow::ipc::Message, "Message") // [[arrow::export]] int64_t ipc___Message__body_length(const std::unique_ptr& message) { @@ -40,12 +30,14 @@ int64_t ipc___Message__body_length(const std::unique_ptr& m } // [[arrow::export]] -R6 ipc___Message__metadata(const std::unique_ptr& message) { +std::shared_ptr ipc___Message__metadata( + const std::unique_ptr& message) { return message->metadata(); } // [[arrow::export]] -R6 ipc___Message__body(const std::unique_ptr& message) { +std::shared_ptr ipc___Message__body( + const std::unique_ptr& message) { return message->body(); } @@ -67,7 +59,7 @@ bool ipc___Message__Equals(const std::unique_ptr& x, } // [[arrow::export]] -R6 ipc___ReadRecordBatch__Message__Schema( +std::shared_ptr ipc___ReadRecordBatch__Message__Schema( const std::unique_ptr& message, const std::shared_ptr& schema) { // TODO: perhaps this should come from the R side @@ -78,14 +70,16 @@ R6 ipc___ReadRecordBatch__Message__Schema( } // [[arrow::export]] -R6 ipc___ReadSchema_InputStream(const std::shared_ptr& stream) { +std::shared_ptr ipc___ReadSchema_InputStream( + const std::shared_ptr& stream) { // TODO: promote to function argument arrow::ipc::DictionaryMemo memo; return ValueOrStop(arrow::ipc::ReadSchema(stream.get(), &memo)); } // [[arrow::export]] -R6 ipc___ReadSchema_Message(const std::unique_ptr& message) { +std::shared_ptr ipc___ReadSchema_Message( + const std::unique_ptr& message) { arrow::ipc::DictionaryMemo empty_memo; return ValueOrStop(arrow::ipc::ReadSchema(*message, &empty_memo)); } @@ -93,19 +87,21 @@ R6 ipc___ReadSchema_Message(const std::unique_ptr& message) //--------- MessageReader // [[arrow::export]] -R6 ipc___MessageReader__Open(const std::shared_ptr& stream) { +std::shared_ptr ipc___MessageReader__Open( + const std::shared_ptr& stream) { return std::shared_ptr( arrow::ipc::MessageReader::Open(stream)); } // [[arrow::export]] -R6 ipc___MessageReader__ReadNextMessage( +std::shared_ptr ipc___MessageReader__ReadNextMessage( const std::unique_ptr& reader) { return ValueOrStop(reader->ReadNextMessage()); } // [[arrow::export]] -R6 ipc___ReadMessage(const std::shared_ptr& stream) { +std::shared_ptr ipc___ReadMessage( + const std::shared_ptr& stream) { return ValueOrStop(arrow::ipc::ReadMessage(stream.get())); } diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index 971b16fe444..bfb9db52bbc 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -38,43 +38,16 @@ class ArrowWriterPropertiesBuilder : public ArrowWriterProperties::Builder { } // namespace parquet -namespace cpp11 { -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetArrowReaderProperties"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetArrowWriterProperties"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetWriterProperties"; -} - -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetFileReader"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetWriterPropertiesBuilder"; -} - -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "ParquetFileWriter"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(parquet::ArrowReaderProperties, "ParquetArrowReaderProperties") +DEFAULT_R6_CLASS_NAME(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties") +DEFAULT_R6_CLASS_NAME(parquet::WriterProperties, "ParquetWriterProperties") +DEFAULT_R6_CLASS_NAME(parquet::arrow::FileReader, "ParquetFileReader") +DEFAULT_R6_CLASS_NAME(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder") +DEFAULT_R6_CLASS_NAME(parquet::arrow::FileWriter, "ParquetFileWriter") // [[arrow::export]] -R6 parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { +std::shared_ptr +parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { return std::make_shared(use_threads); } @@ -104,7 +77,7 @@ void parquet___arrow___ArrowReaderProperties__set_read_dictionary( } // [[arrow::export]] -R6 parquet___arrow___FileReader__OpenFile( +std::shared_ptr parquet___arrow___FileReader__OpenFile( const std::shared_ptr& file, const std::shared_ptr& props) { std::unique_ptr reader; @@ -116,7 +89,7 @@ R6 parquet___arrow___FileReader__OpenFile( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadTable1( +std::shared_ptr parquet___arrow___FileReader__ReadTable1( const std::shared_ptr& reader) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadTable(&table)); @@ -124,7 +97,7 @@ R6 parquet___arrow___FileReader__ReadTable1( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadTable2( +std::shared_ptr parquet___arrow___FileReader__ReadTable2( const std::shared_ptr& reader, const std::vector& column_indices) { std::shared_ptr table; @@ -133,7 +106,7 @@ R6 parquet___arrow___FileReader__ReadTable2( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadRowGroup1( +std::shared_ptr parquet___arrow___FileReader__ReadRowGroup1( const std::shared_ptr& reader, int i) { std::shared_ptr table; PARQUET_THROW_NOT_OK(reader->ReadRowGroup(i, &table)); @@ -141,7 +114,7 @@ R6 parquet___arrow___FileReader__ReadRowGroup1( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadRowGroup2( +std::shared_ptr parquet___arrow___FileReader__ReadRowGroup2( const std::shared_ptr& reader, int i, const std::vector& column_indices) { std::shared_ptr table; @@ -150,7 +123,7 @@ R6 parquet___arrow___FileReader__ReadRowGroup2( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadRowGroups1( +std::shared_ptr parquet___arrow___FileReader__ReadRowGroups1( const std::shared_ptr& reader, const std::vector& row_groups) { std::shared_ptr table; @@ -159,7 +132,7 @@ R6 parquet___arrow___FileReader__ReadRowGroups1( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadRowGroups2( +std::shared_ptr parquet___arrow___FileReader__ReadRowGroups2( const std::shared_ptr& reader, const std::vector& row_groups, const std::vector& column_indices) { std::shared_ptr table; @@ -186,7 +159,7 @@ int parquet___arrow___FileReader__num_row_groups( } // [[arrow::export]] -R6 parquet___arrow___FileReader__ReadColumn( +std::shared_ptr parquet___arrow___FileReader__ReadColumn( const std::shared_ptr& reader, int i) { std::shared_ptr array; PARQUET_THROW_NOT_OK(reader->ReadColumn(i - 1, &array)); @@ -194,9 +167,9 @@ R6 parquet___arrow___FileReader__ReadColumn( } // [[arrow::export]] -R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, - bool use_deprecated_int96_timestamps, - int timestamp_unit) { +std::shared_ptr parquet___ArrowWriterProperties___create( + bool allow_truncated_timestamps, bool use_deprecated_int96_timestamps, + int timestamp_unit) { auto builder = std::make_shared(); builder->store_schema(); @@ -215,7 +188,8 @@ R6 parquet___ArrowWriterProperties___create(bool allow_truncated_timestamps, } // [[arrow::export]] -R6 parquet___WriterProperties___Builder__create() { +std::shared_ptr +parquet___WriterProperties___Builder__create() { return std::make_shared(); } @@ -308,13 +282,13 @@ void parquet___ArrowWriterProperties___Builder__data_page_size( } // [[arrow::export]] -R6 parquet___WriterProperties___Builder__build( +std::shared_ptr parquet___WriterProperties___Builder__build( const std::shared_ptr& builder) { return builder->build(); } // [[arrow::export]] -R6 parquet___arrow___ParquetFileWriter__Open( +std::shared_ptr parquet___arrow___ParquetFileWriter__Open( const std::shared_ptr& schema, const std::shared_ptr& sink, const std::shared_ptr& properties, @@ -322,7 +296,7 @@ R6 parquet___arrow___ParquetFileWriter__Open( std::unique_ptr writer; PARQUET_THROW_NOT_OK(parquet::arrow::FileWriter::Open( *schema, gc_memory_pool(), sink, properties, arrow_properties, &writer)); - return std::shared_ptr(std::move(writer)); + return std::move(writer); } // [[arrow::export]] @@ -349,7 +323,7 @@ void parquet___arrow___WriteTable( } // [[arrow::export]] -R6 parquet___arrow___FileReader__GetSchema( +std::shared_ptr parquet___arrow___FileReader__GetSchema( const std::shared_ptr& reader) { std::shared_ptr schema; StopIfNotOk(reader->GetSchema(&schema)); diff --git a/r/src/py-to-r.cpp b/r/src/py-to-r.cpp index e9f5cd91a06..d2ff13bc2f2 100644 --- a/r/src/py-to-r.cpp +++ b/r/src/py-to-r.cpp @@ -20,14 +20,15 @@ #if defined(ARROW_R_WITH_ARROW) // [[arrow::export]] -R6 ImportArray(arrow::r::Pointer array, - arrow::r::Pointer schema) { +std::shared_ptr ImportArray(arrow::r::Pointer array, + arrow::r::Pointer schema) { return ValueOrStop(arrow::ImportArray(array, schema)); } // [[arrow::export]] -R6 ImportRecordBatch(arrow::r::Pointer array, - arrow::r::Pointer schema) { +std::shared_ptr ImportRecordBatch( + arrow::r::Pointer array, + arrow::r::Pointer schema) { return ValueOrStop(arrow::ImportRecordBatch(array, schema)); } diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp index 8b7a4a781ba..51178ac027a 100644 --- a/r/src/recordbatch.cpp +++ b/r/src/recordbatch.cpp @@ -37,13 +37,14 @@ int RecordBatch__num_rows(const std::shared_ptr& x) { } // [[arrow::export]] -R6 RecordBatch__schema(const std::shared_ptr& x) { +std::shared_ptr RecordBatch__schema( + const std::shared_ptr& x) { return x->schema(); } // [[arrow::export]] -R6 RecordBatch__ReplaceSchemaMetadata(const std::shared_ptr& x, - cpp11::strings metadata) { +std::shared_ptr RecordBatch__ReplaceSchemaMetadata( + const std::shared_ptr& x, cpp11::strings metadata) { auto vec_metadata = cpp11::as_cpp>(metadata); auto names_metadata = cpp11::as_cpp>(metadata.names()); auto kv = std::shared_ptr( @@ -62,20 +63,21 @@ cpp11::list RecordBatch__columns(const std::shared_ptr& batc } // [[arrow::export]] -R6 RecordBatch__column(const std::shared_ptr& batch, R_xlen_t i) { +std::shared_ptr RecordBatch__column( + const std::shared_ptr& batch, R_xlen_t i) { arrow::r::validate_index(i, batch->num_columns()); return batch->column(i); } // [[arrow::export]] -R6 RecordBatch__GetColumnByName(const std::shared_ptr& batch, - const std::string& name) { +std::shared_ptr RecordBatch__GetColumnByName( + const std::shared_ptr& batch, const std::string& name) { return batch->GetColumnByName(name); } // [[arrow::export]] -R6 RecordBatch__SelectColumns(const std::shared_ptr& batch, - cpp11::integers indices) { +std::shared_ptr RecordBatch__SelectColumns( + const std::shared_ptr& batch, cpp11::integers indices) { R_xlen_t n = indices.size(); auto nrows = batch->num_rows(); @@ -100,8 +102,8 @@ bool RecordBatch__Equals(const std::shared_ptr& self, } // [[arrow::export]] -R6 RecordBatch__RemoveColumn(const std::shared_ptr& batch, - R_xlen_t i) { +std::shared_ptr RecordBatch__RemoveColumn( + const std::shared_ptr& batch, R_xlen_t i) { arrow::r::validate_index(i, batch->num_columns()); return ValueOrStop(batch->RemoveColumn(i)); } @@ -125,14 +127,15 @@ cpp11::writable::strings RecordBatch__names( } // [[arrow::export]] -R6 RecordBatch__Slice1(const std::shared_ptr& self, R_xlen_t offset) { +std::shared_ptr RecordBatch__Slice1( + const std::shared_ptr& self, R_xlen_t offset) { arrow::r::validate_slice_offset(offset, self->num_rows()); return self->Slice(offset); } // [[arrow::export]] -R6 RecordBatch__Slice2(const std::shared_ptr& self, R_xlen_t offset, - R_xlen_t length) { +std::shared_ptr RecordBatch__Slice2( + const std::shared_ptr& self, R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, self->num_rows()); arrow::r::validate_slice_length(length, self->num_rows() - offset); return self->Slice(offset, length); @@ -159,7 +162,7 @@ cpp11::raws ipc___SerializeRecordBatch__Raw( } // [[arrow::export]] -R6 ipc___ReadRecordBatch__InputStream__Schema( +std::shared_ptr ipc___ReadRecordBatch__InputStream__Schema( const std::shared_ptr& stream, const std::shared_ptr& schema) { // TODO: promote to function arg @@ -256,7 +259,7 @@ arrow::Status CollectRecordBatchArrays( } // namespace arrow // [[arrow::export]] -R6 RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) { +std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SEXP lst) { bool infer_schema = !Rf_inherits(schema_sxp, "Schema"); int num_fields; diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp index e6aefdd3b56..947aa28858d 100644 --- a/r/src/recordbatchreader.cpp +++ b/r/src/recordbatchreader.cpp @@ -21,26 +21,18 @@ #include #include -namespace cpp11 { -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "RecordBatchStreamReader"; -} -template <> -std::string r6_class_name( - const std::shared_ptr& x) { - return "RecordBatchFileReader"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::ipc::RecordBatchStreamReader, "RecordBatchStreamReader") +DEFAULT_R6_CLASS_NAME(arrow::ipc::RecordBatchFileReader, "RecordBatchFileReader") // [[arrow::export]] -R6 RecordBatchReader__schema(const std::shared_ptr& reader) { +std::shared_ptr RecordBatchReader__schema( + const std::shared_ptr& reader) { return reader->schema(); } // [[arrow::export]] -R6 RecordBatchReader__ReadNext(const std::shared_ptr& reader) { +std::shared_ptr RecordBatchReader__ReadNext( + const std::shared_ptr& reader) { std::shared_ptr batch; StopIfNotOk(reader->ReadNext(&batch)); return batch; @@ -49,7 +41,7 @@ R6 RecordBatchReader__ReadNext(const std::shared_ptr& // -------- RecordBatchStreamReader // [[arrow::export]] -R6 ipc___RecordBatchStreamReader__Open( +std::shared_ptr ipc___RecordBatchStreamReader__Open( const std::shared_ptr& stream) { return ValueOrStop(arrow::ipc::RecordBatchStreamReader::Open(stream)); } @@ -73,7 +65,7 @@ cpp11::list ipc___RecordBatchStreamReader__batches( // -------- RecordBatchFileReader // [[arrow::export]] -R6 ipc___RecordBatchFileReader__schema( +std::shared_ptr ipc___RecordBatchFileReader__schema( const std::shared_ptr& reader) { return reader->schema(); } @@ -85,7 +77,7 @@ int ipc___RecordBatchFileReader__num_record_batches( } // [[arrow::export]] -R6 ipc___RecordBatchFileReader__ReadRecordBatch( +std::shared_ptr ipc___RecordBatchFileReader__ReadRecordBatch( const std::shared_ptr& reader, int i) { if (i < 0 && i >= reader->num_record_batches()) { cpp11::stop("Record batch index out of bounds"); @@ -94,13 +86,13 @@ R6 ipc___RecordBatchFileReader__ReadRecordBatch( } // [[arrow::export]] -R6 ipc___RecordBatchFileReader__Open( +std::shared_ptr ipc___RecordBatchFileReader__Open( const std::shared_ptr& file) { return ValueOrStop(arrow::ipc::RecordBatchFileReader::Open(file)); } // [[arrow::export]] -R6 Table__from_RecordBatchFileReader( +std::shared_ptr Table__from_RecordBatchFileReader( const std::shared_ptr& reader) { int num_batches = reader->num_record_batches(); std::vector> batches(num_batches); @@ -112,7 +104,7 @@ R6 Table__from_RecordBatchFileReader( } // [[arrow::export]] -R6 Table__from_RecordBatchStreamReader( +std::shared_ptr Table__from_RecordBatchStreamReader( const std::shared_ptr& reader) { std::shared_ptr batch; std::vector> batches; diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp index efdc4df7c9a..0579d2cd96f 100644 --- a/r/src/recordbatchwriter.cpp +++ b/r/src/recordbatchwriter.cpp @@ -20,13 +20,7 @@ #if defined(ARROW_R_WITH_ARROW) #include -namespace cpp11 { -template <> -inline std::string r6_class_name( - const std::shared_ptr& x) { - return "RecordBatchWriter"; -} -} // namespace cpp11 +DEFAULT_R6_CLASS_NAME(arrow::ipc::RecordBatchWriter, "RecordBatchWriter") // [[arrow::export]] void ipc___RecordBatchWriter__WriteRecordBatch( @@ -49,7 +43,7 @@ void ipc___RecordBatchWriter__Close( } // [[arrow::export]] -R6 ipc___RecordBatchFileWriter__Open( +std::shared_ptr ipc___RecordBatchFileWriter__Open( const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version) { @@ -61,7 +55,7 @@ R6 ipc___RecordBatchFileWriter__Open( } // [[arrow::export]] -R6 ipc___RecordBatchStreamWriter__Open( +std::shared_ptr ipc___RecordBatchStreamWriter__Open( const std::shared_ptr& stream, const std::shared_ptr& schema, bool use_legacy_format, arrow::ipc::MetadataVersion metadata_version) { diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index c309e65bfd6..24ad3e67950 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -27,8 +27,8 @@ namespace cpp11 { template <> -std::string r6_class_name(const std::shared_ptr& ptr) { - if (ptr->type->id() == arrow::Type::STRUCT) { +const char* r6_class_name(const std::shared_ptr& type) { + if (type->type->id() == arrow::Type::STRUCT) { return "StructScalar"; } return "Scalar"; @@ -37,7 +37,8 @@ std::string r6_class_name(const std::shared_ptr& p } // namespace cpp11 // [[arrow::export]] -R6 Array__GetScalar(const std::shared_ptr& x, int64_t i) { +std::shared_ptr Array__GetScalar(const std::shared_ptr& x, + int64_t i) { return ValueOrStop(x->GetScalar(i)); } @@ -47,19 +48,20 @@ std::string Scalar__ToString(const std::shared_ptr& s) { } // [[arrow::export]] -R6 Scalar__CastTo(const std::shared_ptr& s, - const std::shared_ptr& t) { +std::shared_ptr Scalar__CastTo(const std::shared_ptr& s, + const std::shared_ptr& t) { return ValueOrStop(s->CastTo(t)); } // [[arrow::export]] -R6 StructScalar__field(const std::shared_ptr& s, int i) { +std::shared_ptr StructScalar__field( + const std::shared_ptr& s, int i) { return ValueOrStop(s->field(i)); } // [[arrow::export]] -R6 StructScalar__GetFieldByName(const std::shared_ptr& s, - const std::string& name) { +std::shared_ptr StructScalar__GetFieldByName( + const std::shared_ptr& s, const std::string& name) { return ValueOrStop(s->field(name)); } @@ -76,6 +78,8 @@ SEXP Scalar__as_vector(const std::shared_ptr& scalar) { bool Scalar__is_valid(const std::shared_ptr& s) { return s->is_valid; } // [[arrow::export]] -R6 Scalar__type(const std::shared_ptr& s) { return s->type; } +std::shared_ptr Scalar__type(const std::shared_ptr& s) { + return s->type; +} #endif diff --git a/r/src/schema.cpp b/r/src/schema.cpp index d219c8d5942..d298c80154a 100644 --- a/r/src/schema.cpp +++ b/r/src/schema.cpp @@ -23,7 +23,8 @@ #include // [[arrow::export]] -R6 schema_(const std::vector>& fields) { +std::shared_ptr schema_( + const std::vector>& fields) { return arrow::schema(fields); } @@ -38,7 +39,8 @@ int Schema__num_fields(const std::shared_ptr& s) { } // [[arrow::export]] -R6 Schema__field(const std::shared_ptr& s, int i) { +std::shared_ptr Schema__field(const std::shared_ptr& s, + int i) { if (i >= s->num_fields() || i < 0) { cpp11::stop("Invalid field index for schema."); } @@ -47,7 +49,8 @@ R6 Schema__field(const std::shared_ptr& s, int i) { } // [[arrow::export]] -R6 Schema__GetFieldByName(const std::shared_ptr& s, std::string x) { +std::shared_ptr Schema__GetFieldByName( + const std::shared_ptr& s, std::string x) { return s->GetFieldByName(x); } @@ -91,8 +94,8 @@ cpp11::writable::list Schema__metadata(const std::shared_ptr& sch } // [[arrow::export]] -R6 Schema__WithMetadata(const std::shared_ptr& schema, - cpp11::strings metadata) { +std::shared_ptr Schema__WithMetadata( + const std::shared_ptr& schema, cpp11::strings metadata) { auto values = cpp11::as_cpp>(metadata); auto names = cpp11::as_cpp>(metadata.attr("names")); @@ -115,7 +118,8 @@ bool Schema__Equals(const std::shared_ptr& schema, } // [[arrow::export]] -R6 arrow__UnifySchemas(const std::vector>& schemas) { +std::shared_ptr arrow__UnifySchemas( + const std::vector>& schemas) { return ValueOrStop(arrow::UnifySchemas(schemas)); } diff --git a/r/src/table.cpp b/r/src/table.cpp index 4611395cb13..b12d2b26861 100644 --- a/r/src/table.cpp +++ b/r/src/table.cpp @@ -22,6 +22,18 @@ #include #include +DEFAULT_R6_CLASS_NAME(arrow::Table, "Table") +DEFAULT_R6_CLASS_NAME(arrow::Field, "Field") +DEFAULT_R6_CLASS_NAME(arrow::ArrayData, "ArrayData") +DEFAULT_R6_CLASS_NAME(arrow::ChunkedArray, "ChunkedArray") +DEFAULT_R6_CLASS_NAME(arrow::Buffer, "Buffer") +DEFAULT_R6_CLASS_NAME(arrow::util::Codec, "Codec") +DEFAULT_R6_CLASS_NAME(arrow::io::CompressedOutputStream, "CompressedOutputStream") +DEFAULT_R6_CLASS_NAME(arrow::io::CompressedInputStream, "CompressedInputStream") +DEFAULT_R6_CLASS_NAME(arrow::RecordBatch, "RecordBatch") +DEFAULT_R6_CLASS_NAME(arrow::Schema, "Schema") +DEFAULT_R6_CLASS_NAME(arrow::MemoryPool, "MemoryPool") + // [[arrow::export]] int Table__num_columns(const std::shared_ptr& x) { return x->num_columns(); @@ -31,11 +43,13 @@ int Table__num_columns(const std::shared_ptr& x) { int Table__num_rows(const std::shared_ptr& x) { return x->num_rows(); } // [[arrow::export]] -R6 Table__schema(const std::shared_ptr& x) { return x->schema(); } +std::shared_ptr Table__schema(const std::shared_ptr& x) { + return x->schema(); +} // [[arrow::export]] -R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, - cpp11::strings metadata) { +std::shared_ptr Table__ReplaceSchemaMetadata( + const std::shared_ptr& x, cpp11::strings metadata) { auto vec_metadata = cpp11::as_cpp>(metadata); auto names_metadata = cpp11::as_cpp>(metadata.names()); auto kv = std::shared_ptr( @@ -44,13 +58,15 @@ R6 Table__ReplaceSchemaMetadata(const std::shared_ptr& x, } // [[arrow::export]] -R6 Table__column(const std::shared_ptr& table, R_xlen_t i) { +std::shared_ptr Table__column( + const std::shared_ptr& table, R_xlen_t i) { arrow::r::validate_index(i, table->num_columns()); return table->column(i); } // [[arrow::export]] -R6 Table__field(const std::shared_ptr& table, R_xlen_t i) { +std::shared_ptr Table__field(const std::shared_ptr& table, + R_xlen_t i) { arrow::r::validate_index(i, table->num_columns()); return table->field(i); } @@ -71,14 +87,15 @@ std::vector Table__ColumnNames(const std::shared_ptr& } // [[arrow::export]] -R6 Table__Slice1(const std::shared_ptr& table, R_xlen_t offset) { +std::shared_ptr Table__Slice1(const std::shared_ptr& table, + R_xlen_t offset) { arrow::r::validate_slice_offset(offset, table->num_rows()); return table->Slice(offset); } // [[arrow::export]] -R6 Table__Slice2(const std::shared_ptr& table, R_xlen_t offset, - R_xlen_t length) { +std::shared_ptr Table__Slice2(const std::shared_ptr& table, + R_xlen_t offset, R_xlen_t length) { arrow::r::validate_slice_offset(offset, table->num_rows()); arrow::r::validate_slice_length(length, table->num_rows() - offset); return table->Slice(offset, length); @@ -103,14 +120,14 @@ bool Table__ValidateFull(const std::shared_ptr& table) { } // [[arrow::export]] -R6 Table__GetColumnByName(const std::shared_ptr& table, - const std::string& name) { +std::shared_ptr Table__GetColumnByName( + const std::shared_ptr& table, const std::string& name) { return table->GetColumnByName(name); } // [[arrow::export]] -R6 Table__SelectColumns(const std::shared_ptr& table, - const std::vector& indices) { +std::shared_ptr Table__SelectColumns( + const std::shared_ptr& table, const std::vector& indices) { return ValueOrStop(table->SelectColumns(indices)); } @@ -253,7 +270,7 @@ bool all_record_batches(SEXP lst) { } // [[arrow::export]] -R6 Table__from_record_batches( +std::shared_ptr Table__from_record_batches( const std::vector>& batches, SEXP schema_sxp) { bool infer_schema = !Rf_inherits(schema_sxp, "Schema"); @@ -270,7 +287,7 @@ R6 Table__from_record_batches( } // [[arrow::export]] -R6 Table__from_dots(SEXP lst, SEXP schema_sxp) { +std::shared_ptr Table__from_dots(SEXP lst, SEXP schema_sxp) { bool infer_schema = !Rf_inherits(schema_sxp, "Schema"); int num_fields; From 799feccbe9aa8e780fa13e2aa93abbf01e8b36d4 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 10 Nov 2020 14:21:26 +0100 Subject: [PATCH 30/43] remove R6 catch-all class --- r/src/arrow_cpp11.h | 16 ---------------- r/src/compute.cpp | 10 +++++----- r/src/filesystem.cpp | 5 +++-- 3 files changed, 8 insertions(+), 23 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index f3e7cbcade4..6a6294aea88 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -344,22 +344,6 @@ cpp11::writable::list to_r_list(const std::vector>& x) { } // namespace r } // namespace arrow -class R6 { - public: - template - R6(const std::shared_ptr& x) : data_(cpp11::to_r6(x)) {} - - template - R6(std::unique_ptr x) : data_(cpp11::to_r6(std::move(x))) {} - - R6(SEXP data) : data_(data) {} - - operator SEXP() const { return data_; } - - private: - SEXP data_; -}; - namespace cpp11 { template diff --git a/r/src/compute.cpp b/r/src/compute.cpp index 6e6d5f05897..c99dc498176 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -135,19 +135,19 @@ arrow::Datum as_cpp(SEXP x) { SEXP from_datum(arrow::Datum datum) { switch (datum.kind()) { case arrow::Datum::SCALAR: - return R6(datum.scalar()); + return cpp11::to_r6(datum.scalar()); case arrow::Datum::ARRAY: - return R6(datum.make_array()); + return cpp11::to_r6(datum.make_array()); case arrow::Datum::CHUNKED_ARRAY: - return R6(datum.chunked_array()); + return cpp11::to_r6(datum.chunked_array()); case arrow::Datum::RECORD_BATCH: - return R6(datum.record_batch()); + return cpp11::to_r6(datum.record_batch()); case arrow::Datum::TABLE: - return R6(datum.table()); + return cpp11::to_r6(datum.table()); default: break; diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index fd849ced63e..76b7f7c065a 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -245,8 +245,9 @@ cpp11::writable::list fs___FileSystemFromUri(const std::string& path) { using cpp11::literals::operator"" _nm; std::string out_path; - R6 out_fs = ValueOrStop(fs::FileSystemFromUri(path, &out_path)); - return cpp11::writable::list({"fs"_nm = out_fs, "path"_nm = out_path}); + return cpp11::writable::list( + {"fs"_nm = cpp11::to_r6(ValueOrStop(fs::FileSystemFromUri(path, &out_path))), + "path"_nm = out_path}); } // [[arrow::export]] From 03e05c01c34b9758dcd78ca1f2c738f2425179a1 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 10 Nov 2020 14:35:40 +0100 Subject: [PATCH 31/43] remove unnecessary declarations --- r/src/arrow_types.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index 0023a30a26f..e43effa3ddb 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -120,15 +120,4 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, } // namespace r } // namespace arrow -namespace cpp11 { - -template <> -const char* r6_class_name(const std::shared_ptr&); -template <> -const char* r6_class_name(const std::shared_ptr&); -template <> -const char* r6_class_name(const std::shared_ptr&); - -} // namespace cpp11 - #endif From 17b0ef6f79cc409c02a3c89e3f6fe75b1a7d6d57 Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Tue, 10 Nov 2020 14:53:17 +0100 Subject: [PATCH 32/43] DEFAULT_R6_CLASS_NAME(fs::S3FileSystem, "S3FileSystem") --- r/src/filesystem.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 76b7f7c065a..7558ba5cabb 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -32,6 +32,10 @@ DEFAULT_R6_CLASS_NAME(arrow::io::RandomAccessFile, "RandomAccessFile") DEFAULT_R6_CLASS_NAME(fs::LocalFileSystem, "LocalFileSystem") DEFAULT_R6_CLASS_NAME(fs::SubTreeFileSystem, "SubTreeFileSystem") +#if defined(ARROW_R_WITH_S3) +DEFAULT_R6_CLASS_NAME(fs::S3FileSystem, "S3FileSystem") +#endif + // [[arrow::export]] fs::FileType fs___FileInfo__type(const std::shared_ptr& x) { return x->type(); From 4c462c92774c0b9e76813e8eed0fa0f2f1644c9e Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Tue, 10 Nov 2020 15:04:31 -0500 Subject: [PATCH 33/43] add an explicit check for an R6 class definition --- r/src/arrow_cpp11.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 6a6294aea88..1566cf85f6d 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -295,11 +295,15 @@ bool GetBoolOption(const std::string& name, bool default_); namespace cpp11 { template -SEXP to_r6(const std::shared_ptr& ptr, const std::string& r_class_name) { +SEXP to_r6(const std::shared_ptr& ptr, const char* r6_class_name) { if (ptr == nullptr) return R_NilValue; cpp11::external_pointer> xp(new std::shared_ptr(ptr)); - SEXP r6_class = Rf_install(r_class_name.c_str()); + SEXP r6_class = Rf_install(r6_class_name); + + if (Rf_findVarInFrame3(arrow::r::ns::arrow, r6_class, FALSE) == R_UnboundValue) { + cpp11::stop("No arrow R6 class named '%s'", r6_class_name); + } // make call: $new() SEXP call = PROTECT(Rf_lang3(R_DollarSymbol, r6_class, arrow::r::symbols::new_)); From e88fb82602c05c3b1c607e6b12087b9ecd362a22 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Tue, 10 Nov 2020 16:26:40 -0500 Subject: [PATCH 34/43] refactor r6_class_name to a trait struct --- r/src/array.cpp | 2 +- r/src/arrow_cpp11.h | 29 +++++++++++------ r/src/arrow_exports.h | 63 +++++++++++++++++++++++++++++++++++++ r/src/compute.cpp | 2 -- r/src/csv.cpp | 6 ---- r/src/dataset.cpp | 36 ++------------------- r/src/datatype.cpp | 3 +- r/src/expression.cpp | 3 -- r/src/feather.cpp | 2 -- r/src/filesystem.cpp | 28 +++++++++++------ r/src/io.cpp | 6 ---- r/src/json.cpp | 4 --- r/src/message.cpp | 3 -- r/src/nameof.h | 11 +++++-- r/src/parquet.cpp | 7 ----- r/src/recordbatchreader.cpp | 3 -- r/src/recordbatchwriter.cpp | 2 -- r/src/scalar.cpp | 5 +-- r/src/table.cpp | 12 ------- 19 files changed, 117 insertions(+), 110 deletions(-) diff --git a/r/src/array.cpp b/r/src/array.cpp index f2344ae18b7..ba79b80159c 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -25,7 +25,7 @@ namespace cpp11 { template <> -const char* r6_class_name(const std::shared_ptr& array) { +const char* r6_class_name::get(const std::shared_ptr& array) { auto type = array->type_id(); switch (type) { case arrow::Type::DICTIONARY: diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 1566cf85f6d..2e3daf66d96 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -316,26 +316,35 @@ SEXP to_r6(const std::shared_ptr& ptr, const char* r6_class_name) { return r6; } +/// This trait defines a single static function which returns the name of the R6 class +/// which corresponds to T. By default, this is just the c++ class name with any +/// namespaces stripped, for example the R6 class for arrow::ipc::RecordBatchStreamReader +/// is simply named "RecordBatchStreamReader". +/// +/// Some classes require specializations of this trait. For example the R6 classes which +/// wrap arrow::csv::ReadOptions and arrow::json::ReadOptions would collide if both were +/// named "ReadOptions", so they are named "CsvReadOptions" and "JsonReadOptions" +/// respectively. Other classes such as arrow::Array are base classes and the proper R6 +/// class name must be derived by examining a discriminant like Array::type_id. +/// +/// All specializations are located in arrow_exports.h to be visible in generated code. template -const char* r6_class_name(const std::shared_ptr&); +struct r6_class_name { + static const char* get(const std::shared_ptr& ptr) { + static const std::string name = arrow::util::nameof(/*strip_namespace=*/true); + return name.c_str(); + } +}; template SEXP to_r6(const std::shared_ptr& x) { if (x == nullptr) return R_NilValue; - return to_r6(x, cpp11::r6_class_name(x)); + return to_r6(x, cpp11::r6_class_name::get(x)); } } // namespace cpp11 -#define DEFAULT_R6_CLASS_NAME(CLASS, NAME) \ - namespace cpp11 { \ - template <> \ - const char* r6_class_name(const std::shared_ptr&) { \ - return NAME; \ - } \ - } - namespace arrow { namespace r { diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h index 38e4ad9edae..381b7537fe0 100644 --- a/r/src/arrow_exports.h +++ b/r/src/arrow_exports.h @@ -90,4 +90,67 @@ class FileWriter; } // namespace arrow } // namespace parquet +namespace cpp11 { + +// Overrides of default R6 class names: +#define R6_CLASS_NAME(CLASS, NAME) \ + template <> \ + struct r6_class_name { \ + static const char* get(const std::shared_ptr&) { return NAME; } \ + } + +R6_CLASS_NAME(arrow::csv::ReadOptions, "CsvReadOptions"); +R6_CLASS_NAME(arrow::csv::ParseOptions, "CsvParseOptions"); +R6_CLASS_NAME(arrow::csv::ConvertOptions, "CsvConvertOptions"); +R6_CLASS_NAME(arrow::csv::TableReader, "CsvTableReader"); + +R6_CLASS_NAME(parquet::ArrowReaderProperties, "ParquetArrowReaderProperties"); +R6_CLASS_NAME(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties"); +R6_CLASS_NAME(parquet::WriterProperties, "ParquetWriterProperties"); +R6_CLASS_NAME(parquet::arrow::FileReader, "ParquetFileReader"); +R6_CLASS_NAME(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder"); +R6_CLASS_NAME(parquet::arrow::FileWriter, "ParquetFileWriter"); + +R6_CLASS_NAME(arrow::ipc::feather::Reader, "FeatherReader"); + +R6_CLASS_NAME(arrow::json::ReadOptions, "JsonReadOptions"); +R6_CLASS_NAME(arrow::json::ParseOptions, "JsonParseOptions"); +R6_CLASS_NAME(arrow::json::TableReader, "JsonTableReader"); + +#undef R6_CLASS_NAME + +// Declarations of discriminated base classes. +// Definitions reside in corresponding .cpp files. +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +} // namespace cpp11 + #endif diff --git a/r/src/compute.cpp b/r/src/compute.cpp index c99dc498176..a456ec4711b 100644 --- a/r/src/compute.cpp +++ b/r/src/compute.cpp @@ -23,8 +23,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::compute::CastOptions, "CastOptions") - arrow::compute::ExecContext* gc_context() { static arrow::compute::ExecContext context(gc_memory_pool()); return &context; diff --git a/r/src/csv.cpp b/r/src/csv.cpp index 9066116269e..54d3abc3821 100644 --- a/r/src/csv.cpp +++ b/r/src/csv.cpp @@ -22,12 +22,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::csv::ReadOptions, "CsvReadOptions") -DEFAULT_R6_CLASS_NAME(arrow::csv::ParseOptions, "CsvParseOptions") -DEFAULT_R6_CLASS_NAME(arrow::csv::ConvertOptions, "CsvConvertOptions") -DEFAULT_R6_CLASS_NAME(arrow::csv::TableReader, "CsvTableReader") -DEFAULT_R6_CLASS_NAME(arrow::TimestampParser, "TimestampParser") - // [[arrow::export]] std::shared_ptr csv___ReadOptions__initialize( cpp11::list options) { diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 6b43f79a4d0..d8e9f8581d9 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -28,26 +28,10 @@ namespace ds = ::arrow::dataset; namespace fs = ::arrow::fs; -DEFAULT_R6_CLASS_NAME(ds::UnionDataset, "UnionDataset") -DEFAULT_R6_CLASS_NAME(ds::InMemoryDataset, "InMemoryDataset") -DEFAULT_R6_CLASS_NAME(ds::FileSystemDataset, "FileSystemDataset") -DEFAULT_R6_CLASS_NAME(ds::ScannerBuilder, "ScannerBuilder") -DEFAULT_R6_CLASS_NAME(ds::DatasetFactory, "DatasetFactory") -DEFAULT_R6_CLASS_NAME(ds::FileSystemDatasetFactory, "FileSystemDatasetFactory") -DEFAULT_R6_CLASS_NAME(ds::PartitioningFactory, "PartitioningFactory") -DEFAULT_R6_CLASS_NAME(ds::ParquetFileFormat, "ParquetFileFormat") -DEFAULT_R6_CLASS_NAME(ds::IpcFileFormat, "IpcFileFormat") -DEFAULT_R6_CLASS_NAME(ds::CsvFileFormat, "CsvFileFormat") -DEFAULT_R6_CLASS_NAME(ds::DirectoryPartitioning, "DirectoryPartitioning") -DEFAULT_R6_CLASS_NAME(ds::HivePartitioning, "HivePartitioning") -DEFAULT_R6_CLASS_NAME(ds::Scanner, "Scanner") -DEFAULT_R6_CLASS_NAME(ds::ScanTask, "ScanTask") -DEFAULT_R6_CLASS_NAME(ds::FileWriteOptions, "FileWriteOptions") - namespace cpp11 { template <> -const char* r6_class_name(const std::shared_ptr& dataset) { +const char* r6_class_name::get(const std::shared_ptr& dataset) { auto type_name = dataset->type_name(); if (type_name == "union") { @@ -62,23 +46,7 @@ const char* r6_class_name(const std::shared_ptr& datas } template <> -const char* r6_class_name( - const std::shared_ptr& file_system) { - auto type_name = file_system->type_name(); - - if (type_name == "local") { - return "LocalFileSystem"; - } else if (type_name == "s3") { - return "S3FileSystem"; - } else if (type_name == "subtree") { - return "SubTreeFileSystem"; - } else { - return "FileSystem"; - } -} - -template <> -const char* r6_class_name( +const char* r6_class_name::get( const std::shared_ptr& file_format) { auto type_name = file_format->type_name(); if (type_name == "parquet") { diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index c4852524339..68c7b62cb8e 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -22,7 +22,8 @@ namespace cpp11 { template <> -const char* r6_class_name(const std::shared_ptr& type) { +const char* r6_class_name::get( + const std::shared_ptr& type) { using arrow::Type; switch (type->id()) { diff --git a/r/src/expression.cpp b/r/src/expression.cpp index 5164ed29bae..575dddc7da7 100644 --- a/r/src/expression.cpp +++ b/r/src/expression.cpp @@ -22,9 +22,6 @@ #include namespace ds = ::arrow::dataset; -DEFAULT_R6_CLASS_NAME(ds::Expression, "Expression") -DEFAULT_R6_CLASS_NAME(ds::ComparisonExpression, "Expression") - // [[arrow::export]] std::shared_ptr dataset___expr__field_ref(std::string name) { return ds::field_ref(std::move(name)); diff --git a/r/src/feather.cpp b/r/src/feather.cpp index dab2c0504e3..22bdd7acde0 100644 --- a/r/src/feather.cpp +++ b/r/src/feather.cpp @@ -21,8 +21,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::ipc::feather::Reader, "FeatherReader") - // ---------- WriteFeather // [[arrow::export]] diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index 7558ba5cabb..bdfc2509cad 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -24,17 +24,25 @@ namespace fs = ::arrow::fs; -DEFAULT_R6_CLASS_NAME(fs::FileSelector, "FileSelector") -DEFAULT_R6_CLASS_NAME(fs::FileInfo, "FileInfo") -DEFAULT_R6_CLASS_NAME(arrow::io::InputStream, "InputStream") -DEFAULT_R6_CLASS_NAME(arrow::io::OutputStream, "OutputStream") -DEFAULT_R6_CLASS_NAME(arrow::io::RandomAccessFile, "RandomAccessFile") -DEFAULT_R6_CLASS_NAME(fs::LocalFileSystem, "LocalFileSystem") -DEFAULT_R6_CLASS_NAME(fs::SubTreeFileSystem, "SubTreeFileSystem") +namespace cpp11 { -#if defined(ARROW_R_WITH_S3) -DEFAULT_R6_CLASS_NAME(fs::S3FileSystem, "S3FileSystem") -#endif +template <> +const char* r6_class_name::get( + const std::shared_ptr& file_system) { + auto type_name = file_system->type_name(); + + if (type_name == "local") { + return "LocalFileSystem"; + } else if (type_name == "s3") { + return "S3FileSystem"; + } else if (type_name == "subtree") { + return "SubTreeFileSystem"; + } else { + return "FileSystem"; + } +} + +} // namespace cpp11 // [[arrow::export]] fs::FileType fs___FileInfo__type(const std::shared_ptr& x) { diff --git a/r/src/io.cpp b/r/src/io.cpp index 05e9a2654d9..6a912dd7815 100644 --- a/r/src/io.cpp +++ b/r/src/io.cpp @@ -21,12 +21,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::io::MemoryMappedFile, "MemoryMappedFile") -DEFAULT_R6_CLASS_NAME(arrow::io::ReadableFile, "ReadableFile") -DEFAULT_R6_CLASS_NAME(arrow::io::BufferReader, "BufferReader") -DEFAULT_R6_CLASS_NAME(arrow::io::FileOutputStream, "FileOutputStream") -DEFAULT_R6_CLASS_NAME(arrow::io::BufferOutputStream, "BufferOutputStream") - // ------ arrow::io::Readable // [[arrow::export]] diff --git a/r/src/json.cpp b/r/src/json.cpp index b94b3961f18..87d40623f6b 100644 --- a/r/src/json.cpp +++ b/r/src/json.cpp @@ -20,10 +20,6 @@ #include -DEFAULT_R6_CLASS_NAME(arrow::json::ReadOptions, "JsonReadOptions") -DEFAULT_R6_CLASS_NAME(arrow::json::ParseOptions, "JsonParseOptions") -DEFAULT_R6_CLASS_NAME(arrow::json::TableReader, "JsonTableReader") - // [[arrow::export]] std::shared_ptr json___ReadOptions__initialize(bool use_threads, int block_size) { diff --git a/r/src/message.cpp b/r/src/message.cpp index febbf0753ac..f2524644a61 100644 --- a/r/src/message.cpp +++ b/r/src/message.cpp @@ -21,9 +21,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::ipc::MessageReader, "MessageReader") -DEFAULT_R6_CLASS_NAME(arrow::ipc::Message, "Message") - // [[arrow::export]] int64_t ipc___Message__body_length(const std::unique_ptr& message) { return message->body_length(); diff --git a/r/src/nameof.h b/r/src/nameof.h index a46ac762869..397c690cc51 100644 --- a/r/src/nameof.h +++ b/r/src/nameof.h @@ -78,8 +78,15 @@ const char* typename_begin() { } // namespace detail template -std::string nameof() { - return {detail::typename_begin(), detail::typename_length()}; +std::string nameof(bool strip_namespace = false) { + std::string name{detail::typename_begin(), detail::typename_length()}; + if (strip_namespace) { + auto i = name.find_last_of("::"); + if (i != std::string::npos) { + name = name.substr(i + 1); + } + } + return name; } } // namespace util diff --git a/r/src/parquet.cpp b/r/src/parquet.cpp index bfb9db52bbc..1b0bc41b833 100644 --- a/r/src/parquet.cpp +++ b/r/src/parquet.cpp @@ -38,13 +38,6 @@ class ArrowWriterPropertiesBuilder : public ArrowWriterProperties::Builder { } // namespace parquet -DEFAULT_R6_CLASS_NAME(parquet::ArrowReaderProperties, "ParquetArrowReaderProperties") -DEFAULT_R6_CLASS_NAME(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties") -DEFAULT_R6_CLASS_NAME(parquet::WriterProperties, "ParquetWriterProperties") -DEFAULT_R6_CLASS_NAME(parquet::arrow::FileReader, "ParquetFileReader") -DEFAULT_R6_CLASS_NAME(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder") -DEFAULT_R6_CLASS_NAME(parquet::arrow::FileWriter, "ParquetFileWriter") - // [[arrow::export]] std::shared_ptr parquet___arrow___ArrowReaderProperties__Make(bool use_threads) { diff --git a/r/src/recordbatchreader.cpp b/r/src/recordbatchreader.cpp index 947aa28858d..76487164f4f 100644 --- a/r/src/recordbatchreader.cpp +++ b/r/src/recordbatchreader.cpp @@ -21,9 +21,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::ipc::RecordBatchStreamReader, "RecordBatchStreamReader") -DEFAULT_R6_CLASS_NAME(arrow::ipc::RecordBatchFileReader, "RecordBatchFileReader") - // [[arrow::export]] std::shared_ptr RecordBatchReader__schema( const std::shared_ptr& reader) { diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp index 0579d2cd96f..07649ce1963 100644 --- a/r/src/recordbatchwriter.cpp +++ b/r/src/recordbatchwriter.cpp @@ -20,8 +20,6 @@ #if defined(ARROW_R_WITH_ARROW) #include -DEFAULT_R6_CLASS_NAME(arrow::ipc::RecordBatchWriter, "RecordBatchWriter") - // [[arrow::export]] void ipc___RecordBatchWriter__WriteRecordBatch( const std::shared_ptr& batch_writer, diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index 24ad3e67950..02459641ad5 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -27,8 +27,9 @@ namespace cpp11 { template <> -const char* r6_class_name(const std::shared_ptr& type) { - if (type->type->id() == arrow::Type::STRUCT) { +const char* r6_class_name::get( + const std::shared_ptr& scalar) { + if (scalar->type->id() == arrow::Type::STRUCT) { return "StructScalar"; } return "Scalar"; diff --git a/r/src/table.cpp b/r/src/table.cpp index b12d2b26861..2c89934eb86 100644 --- a/r/src/table.cpp +++ b/r/src/table.cpp @@ -22,18 +22,6 @@ #include #include -DEFAULT_R6_CLASS_NAME(arrow::Table, "Table") -DEFAULT_R6_CLASS_NAME(arrow::Field, "Field") -DEFAULT_R6_CLASS_NAME(arrow::ArrayData, "ArrayData") -DEFAULT_R6_CLASS_NAME(arrow::ChunkedArray, "ChunkedArray") -DEFAULT_R6_CLASS_NAME(arrow::Buffer, "Buffer") -DEFAULT_R6_CLASS_NAME(arrow::util::Codec, "Codec") -DEFAULT_R6_CLASS_NAME(arrow::io::CompressedOutputStream, "CompressedOutputStream") -DEFAULT_R6_CLASS_NAME(arrow::io::CompressedInputStream, "CompressedInputStream") -DEFAULT_R6_CLASS_NAME(arrow::RecordBatch, "RecordBatch") -DEFAULT_R6_CLASS_NAME(arrow::Schema, "Schema") -DEFAULT_R6_CLASS_NAME(arrow::MemoryPool, "MemoryPool") - // [[arrow::export]] int Table__num_columns(const std::shared_ptr& x) { return x->num_columns(); From 6a3632a5f91636efb29b9aebc445799206252616 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Tue, 10 Nov 2020 16:36:28 -0500 Subject: [PATCH 35/43] some diff scrubbing --- r/src/buffer.cpp | 19 +++++++------------ r/src/recordbatch.cpp | 3 +-- r/src/recordbatchwriter.cpp | 2 -- r/tests/testthat/test-dataset.R | 6 +++--- r/tests/testthat/test-read-record-batch.R | 2 +- r/tests/testthat/test-record-batch-reader.R | 4 ++-- r/tests/testthat/test-schema.R | 2 +- 7 files changed, 15 insertions(+), 23 deletions(-) diff --git a/r/src/buffer.cpp b/r/src/buffer.cpp index 5fc70b43784..2814677343d 100644 --- a/r/src/buffer.cpp +++ b/r/src/buffer.cpp @@ -41,25 +41,20 @@ int64_t Buffer__size(const std::shared_ptr& buffer) { // [[arrow::export]] std::shared_ptr r___RBuffer__initialize(SEXP x) { - std::shared_ptr out; switch (TYPEOF(x)) { case RAWSXP: - out = std::make_shared>(x); - break; + return std::make_shared>(x); case REALSXP: - out = std::make_shared>(x); - break; + return std::make_shared>(x); case INTSXP: - out = std::make_shared>(x); - break; + return std::make_shared>(x); case CPLXSXP: - out = - std::make_shared>(arrow::r::complexs(x)); - break; + return std::make_shared>( + arrow::r::complexs(x)); default: - cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x))); + break; } - return out; + cpp11::stop("R object of type <%s> not supported", Rf_type2char(TYPEOF(x))); } // [[arrow::export]] diff --git a/r/src/recordbatch.cpp b/r/src/recordbatch.cpp index 51178ac027a..bae5b8e713a 100644 --- a/r/src/recordbatch.cpp +++ b/r/src/recordbatch.cpp @@ -284,8 +284,7 @@ std::shared_ptr RecordBatch__from_arrays(SEXP schema_sxp, SE int64_t num_rows = 0; StopIfNotOk(arrow::r::check_consistent_array_size(arrays, &num_rows)); - auto out = arrow::RecordBatch::Make(schema, num_rows, arrays); - return out; + return arrow::RecordBatch::Make(schema, num_rows, arrays); } #endif diff --git a/r/src/recordbatchwriter.cpp b/r/src/recordbatchwriter.cpp index 07649ce1963..4714c1d104a 100644 --- a/r/src/recordbatchwriter.cpp +++ b/r/src/recordbatchwriter.cpp @@ -48,7 +48,6 @@ std::shared_ptr ipc___RecordBatchFileWriter__Open auto options = arrow::ipc::IpcWriteOptions::Defaults(); options.write_legacy_ipc_format = use_legacy_format; options.metadata_version = metadata_version; - return ValueOrStop(arrow::ipc::MakeFileWriter(stream, schema, options)); } @@ -60,7 +59,6 @@ std::shared_ptr ipc___RecordBatchStreamWriter__Op auto options = arrow::ipc::IpcWriteOptions::Defaults(); options.write_legacy_ipc_format = use_legacy_format; options.metadata_version = metadata_version; - return ValueOrStop(MakeStreamWriter(stream, schema, options)); } diff --git a/r/tests/testthat/test-dataset.R b/r/tests/testthat/test-dataset.R index b545aabdd46..73d654eb5a1 100644 --- a/r/tests/testthat/test-dataset.R +++ b/r/tests/testthat/test-dataset.R @@ -694,7 +694,7 @@ test_that("Assembling a Dataset manually and getting a Table", { fmt <- FileFormat$create("parquet") factory <- FileSystemDatasetFactory$create(fs, selector, fmt, partitioning = partitioning) - expect_is(factory, "DatasetFactory") + expect_is(factory, "FileSystemDatasetFactory") schm <- factory$Inspect() expect_is(schm, "Schema") @@ -716,9 +716,9 @@ test_that("Assembling a Dataset manually and getting a Table", { test_that("Assembling multiple DatasetFactories with DatasetFactory", { factory1 <- dataset_factory(file.path(dataset_dir, 1), format = "parquet") - expect_is(factory1, "DatasetFactory") + expect_is(factory1, "FileSystemDatasetFactory") factory2 <- dataset_factory(file.path(dataset_dir, 2), format = "parquet") - expect_is(factory2, "DatasetFactory") + expect_is(factory2, "FileSystemDatasetFactory") factory <- DatasetFactory$create(list(factory1, factory2)) expect_is(factory, "DatasetFactory") diff --git a/r/tests/testthat/test-read-record-batch.R b/r/tests/testthat/test-read-record-batch.R index 9383c476588..8eb196a1eab 100644 --- a/r/tests/testthat/test-read-record-batch.R +++ b/r/tests/testthat/test-read-record-batch.R @@ -34,7 +34,7 @@ test_that("RecordBatchFileWriter / RecordBatchFileReader roundtrips", { stream <- FileOutputStream$create(tf) writer <- RecordBatchFileWriter$create(stream, tab$schema) - expect_is(writer, "RecordBatchWriter") + expect_is(writer, "RecordBatchFileWriter") writer$write_table(tab) writer$close() stream$close() diff --git a/r/tests/testthat/test-record-batch-reader.R b/r/tests/testthat/test-record-batch-reader.R index 533d53e7ffb..d9c34068425 100644 --- a/r/tests/testthat/test-record-batch-reader.R +++ b/r/tests/testthat/test-record-batch-reader.R @@ -28,7 +28,7 @@ test_that("RecordBatchStreamReader / Writer", { sink <- BufferOutputStream$create() expect_equal(sink$tell(), 0) writer <- RecordBatchStreamWriter$create(sink, batch$schema) - expect_is(writer, "RecordBatchWriter") + expect_is(writer, "RecordBatchStreamWriter") writer$write(batch) writer$write(tab) writer$write(tbl) @@ -56,7 +56,7 @@ test_that("RecordBatchStreamReader / Writer", { test_that("RecordBatchFileReader / Writer", { sink <- BufferOutputStream$create() writer <- RecordBatchFileWriter$create(sink, batch$schema) - expect_is(writer, "RecordBatchWriter") + expect_is(writer, "RecordBatchFileWriter") writer$write(batch) writer$write(tab) writer$write(tbl) diff --git a/r/tests/testthat/test-schema.R b/r/tests/testthat/test-schema.R index 2730cb50839..23b08da5457 100644 --- a/r/tests/testthat/test-schema.R +++ b/r/tests/testthat/test-schema.R @@ -76,7 +76,7 @@ test_that("reading schema from Buffer", { stream <- BufferOutputStream$create() writer <- RecordBatchStreamWriter$create(stream, batch$schema) - expect_is(writer, "RecordBatchWriter") + expect_is(writer, "RecordBatchStreamWriter") writer$close() buffer <- stream$finish() From ae60ba111e4e9f1fde6e3262f7c4dffa25d31fa9 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Tue, 10 Nov 2020 17:09:07 -0500 Subject: [PATCH 36/43] amend return types --- cpp/src/arrow/dataset/type_fwd.h | 4 +++- r/src/arrowExports.cpp | 6 +++--- r/src/dataset.cpp | 13 ++++++++----- r/tests/testthat/test-record-batch-reader.R | 4 ++-- r/tests/testthat/test-schema.R | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/cpp/src/arrow/dataset/type_fwd.h b/cpp/src/arrow/dataset/type_fwd.h index 73cfdff2b42..214cfc62e27 100644 --- a/cpp/src/arrow/dataset/type_fwd.h +++ b/cpp/src/arrow/dataset/type_fwd.h @@ -36,10 +36,11 @@ class ExecContext; namespace dataset { class Dataset; +class DatasetFactory; using DatasetVector = std::vector>; class UnionDataset; -class DatasetFactory; +class UnionDatasetFactory; class Fragment; using FragmentIterator = Iterator>; @@ -51,6 +52,7 @@ class FileFragment; class FileWriter; class FileWriteOptions; class FileSystemDataset; +class FileSystemDatasetFactory; struct FileSystemDatasetWriteOptions; class InMemoryDataset; diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index df694f1a276..33295484ca7 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -1564,7 +1564,7 @@ extern "C" SEXP _arrow_dataset___UnionDatasetFactory__Make(SEXP children_sexp){ // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDatasetFactory__Make2(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& partitioning); +std::shared_ptr dataset___FileSystemDatasetFactory__Make2(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& partitioning); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make2(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp, SEXP partitioning_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1582,7 +1582,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make2(SEXP fs_sexp, S // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDatasetFactory__Make1(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format); +std::shared_ptr dataset___FileSystemDatasetFactory__Make1(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make1(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); @@ -1599,7 +1599,7 @@ extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make1(SEXP fs_sexp, S // dataset.cpp #if defined(ARROW_R_WITH_ARROW) -std::shared_ptr dataset___FileSystemDatasetFactory__Make3(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& factory); +std::shared_ptr dataset___FileSystemDatasetFactory__Make3(const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, const std::shared_ptr& factory); extern "C" SEXP _arrow_dataset___FileSystemDatasetFactory__Make3(SEXP fs_sexp, SEXP selector_sexp, SEXP format_sexp, SEXP factory_sexp){ BEGIN_CPP11 arrow::r::Input&>::type fs(fs_sexp); diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index d8e9f8581d9..95a45b3ac1e 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include namespace ds = ::arrow::dataset; @@ -162,7 +163,7 @@ std::shared_ptr dataset___UnionDatasetFactory__Make( } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDatasetFactory__Make2( +std::shared_ptr dataset___FileSystemDatasetFactory__Make2( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, @@ -173,11 +174,12 @@ std::shared_ptr dataset___FileSystemDatasetFactory__Make2( options.partitioning = partitioning; } - return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); + return arrow::internal::checked_pointer_cast( + ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options))); } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDatasetFactory__Make1( +std::shared_ptr dataset___FileSystemDatasetFactory__Make1( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format) { @@ -185,7 +187,7 @@ std::shared_ptr dataset___FileSystemDatasetFactory__Make1( } // [[arrow::export]] -std::shared_ptr dataset___FileSystemDatasetFactory__Make3( +std::shared_ptr dataset___FileSystemDatasetFactory__Make3( const std::shared_ptr& fs, const std::shared_ptr& selector, const std::shared_ptr& format, @@ -196,7 +198,8 @@ std::shared_ptr dataset___FileSystemDatasetFactory__Make3( options.partitioning = factory; } - return ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options)); + return arrow::internal::checked_pointer_cast( + ValueOrStop(ds::FileSystemDatasetFactory::Make(fs, *selector, format, options))); } // FileFormat, ParquetFileFormat, IpcFileFormat diff --git a/r/tests/testthat/test-record-batch-reader.R b/r/tests/testthat/test-record-batch-reader.R index d9c34068425..533d53e7ffb 100644 --- a/r/tests/testthat/test-record-batch-reader.R +++ b/r/tests/testthat/test-record-batch-reader.R @@ -28,7 +28,7 @@ test_that("RecordBatchStreamReader / Writer", { sink <- BufferOutputStream$create() expect_equal(sink$tell(), 0) writer <- RecordBatchStreamWriter$create(sink, batch$schema) - expect_is(writer, "RecordBatchStreamWriter") + expect_is(writer, "RecordBatchWriter") writer$write(batch) writer$write(tab) writer$write(tbl) @@ -56,7 +56,7 @@ test_that("RecordBatchStreamReader / Writer", { test_that("RecordBatchFileReader / Writer", { sink <- BufferOutputStream$create() writer <- RecordBatchFileWriter$create(sink, batch$schema) - expect_is(writer, "RecordBatchFileWriter") + expect_is(writer, "RecordBatchWriter") writer$write(batch) writer$write(tab) writer$write(tbl) diff --git a/r/tests/testthat/test-schema.R b/r/tests/testthat/test-schema.R index 23b08da5457..2730cb50839 100644 --- a/r/tests/testthat/test-schema.R +++ b/r/tests/testthat/test-schema.R @@ -76,7 +76,7 @@ test_that("reading schema from Buffer", { stream <- BufferOutputStream$create() writer <- RecordBatchStreamWriter$create(stream, batch$schema) - expect_is(writer, "RecordBatchStreamWriter") + expect_is(writer, "RecordBatchWriter") writer$close() buffer <- stream$finish() From 8ffe1b8f7fbadaa0eafd1f77ea523e7965841272 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Tue, 10 Nov 2020 17:18:35 -0500 Subject: [PATCH 37/43] one last test --- r/src/datatype.cpp | 18 ++++++++++-------- r/tests/testthat/test-read-record-batch.R | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index 68c7b62cb8e..d5030dd5d5f 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -99,16 +99,18 @@ const char* r6_class_name::get( break; } + // No R6 classes are defined for: + // INTERVAL + // SPARSE_UNION + // DENSE_UNION + // MAP + // EXTENSION + // DURATION + // + // If a c++ function returns one it will be wrapped as a DataType. + return "DataType"; } -// switch(names(Type)[self$id + 1], -// -// INTERVAL = stop("Type INTERVAL not implemented yet"), -// SPARSE_UNION = stop("Type SPARSE_UNION not implemented yet"), -// DENSE_UNION = stop("Type DENSE_UNION not implemented yet"), -// MAP = stop("Type MAP not implemented yet"), -// EXTENSION = stop("Type EXTENSION not implemented yet"), -// DURATION = stop("Type DURATION not implemented yet"), } // namespace cpp11 diff --git a/r/tests/testthat/test-read-record-batch.R b/r/tests/testthat/test-read-record-batch.R index 8eb196a1eab..9383c476588 100644 --- a/r/tests/testthat/test-read-record-batch.R +++ b/r/tests/testthat/test-read-record-batch.R @@ -34,7 +34,7 @@ test_that("RecordBatchFileWriter / RecordBatchFileReader roundtrips", { stream <- FileOutputStream$create(tf) writer <- RecordBatchFileWriter$create(stream, tab$schema) - expect_is(writer, "RecordBatchFileWriter") + expect_is(writer, "RecordBatchWriter") writer$write_table(tab) writer$close() stream$close() From 1895b9a06e2728639483629d246c5e70cc448926 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Wed, 11 Nov 2020 12:49:31 -0500 Subject: [PATCH 38/43] More forward declarations in C++ --- cpp/src/arrow/compute/type_fwd.h | 2 + cpp/src/arrow/csv/options.h | 1 + cpp/src/arrow/csv/type_fwd.h | 27 +++ cpp/src/arrow/dataset/type_fwd.h | 2 + cpp/src/arrow/json/options.h | 1 + cpp/src/arrow/json/type_fwd.h | 26 +++ cpp/src/arrow/util/type_fwd.h | 2 + cpp/src/parquet/arrow/generate_fuzz_corpus.cc | 2 +- cpp/src/parquet/arrow/schema_internal.cc | 4 +- cpp/src/parquet/column_writer.cc | 8 +- cpp/src/parquet/encoding_benchmark.cc | 38 ++--- cpp/src/parquet/encoding_test.cc | 98 +++++------ cpp/src/parquet/file_reader.cc | 18 +- cpp/src/parquet/level_conversion_test.cc | 2 +- cpp/src/parquet/metadata.cc | 2 +- cpp/src/parquet/platform.cc | 2 +- cpp/src/parquet/printer.cc | 4 +- cpp/src/parquet/properties.h | 5 +- cpp/src/parquet/properties_test.cc | 2 +- cpp/src/parquet/reader_test.cc | 10 +- cpp/src/parquet/statistics_test.cc | 4 +- cpp/src/parquet/stream_reader.h | 2 +- cpp/src/parquet/stream_reader_test.cc | 18 +- cpp/src/parquet/stream_writer.cc | 2 +- cpp/src/parquet/stream_writer.h | 4 +- cpp/src/parquet/stream_writer_test.cc | 5 +- cpp/src/parquet/test_encryption_util.h | 4 +- cpp/src/parquet/type_fwd.h | 12 ++ r/src/arrow_exports.h | 156 ------------------ 29 files changed, 191 insertions(+), 272 deletions(-) create mode 100644 cpp/src/arrow/csv/type_fwd.h create mode 100644 cpp/src/arrow/json/type_fwd.h delete mode 100644 r/src/arrow_exports.h diff --git a/cpp/src/arrow/compute/type_fwd.h b/cpp/src/arrow/compute/type_fwd.h index 99fb60ef634..4b05ceccb5a 100644 --- a/cpp/src/arrow/compute/type_fwd.h +++ b/cpp/src/arrow/compute/type_fwd.h @@ -23,6 +23,8 @@ struct Datum; namespace compute { +struct CastOptions; + class ExecContext; class KernelContext; diff --git a/cpp/src/arrow/csv/options.h b/cpp/src/arrow/csv/options.h index e94f5fc9653..82153ed466a 100644 --- a/cpp/src/arrow/csv/options.h +++ b/cpp/src/arrow/csv/options.h @@ -23,6 +23,7 @@ #include #include +#include "arrow/csv/type_fwd.h" #include "arrow/util/visibility.h" namespace arrow { diff --git a/cpp/src/arrow/csv/type_fwd.h b/cpp/src/arrow/csv/type_fwd.h new file mode 100644 index 00000000000..17fcdbdcc56 --- /dev/null +++ b/cpp/src/arrow/csv/type_fwd.h @@ -0,0 +1,27 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace arrow { +namespace csv { + +class TableReader; +struct ConvertOptions; +struct ReadOptions; +struct ParseOptions; + +} // namespace csv +} // namespace arrow diff --git a/cpp/src/arrow/dataset/type_fwd.h b/cpp/src/arrow/dataset/type_fwd.h index 214cfc62e27..0ff77de0102 100644 --- a/cpp/src/arrow/dataset/type_fwd.h +++ b/cpp/src/arrow/dataset/type_fwd.h @@ -79,6 +79,8 @@ const std::shared_ptr& scalar(bool); class Partitioning; class PartitioningFactory; class PartitioningOrFactory; +class DirectoryPartitioning; +class HivePartitioning; struct ScanContext; diff --git a/cpp/src/arrow/json/options.h b/cpp/src/arrow/json/options.h index 03d46ad8430..d7edab9cedd 100644 --- a/cpp/src/arrow/json/options.h +++ b/cpp/src/arrow/json/options.h @@ -20,6 +20,7 @@ #include #include +#include "arrow/json/type_fwd.h" #include "arrow/util/visibility.h" namespace arrow { diff --git a/cpp/src/arrow/json/type_fwd.h b/cpp/src/arrow/json/type_fwd.h new file mode 100644 index 00000000000..67e2e1bb406 --- /dev/null +++ b/cpp/src/arrow/json/type_fwd.h @@ -0,0 +1,26 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +namespace arrow { +namespace json { + +class TableReader; +struct ReadOptions; +struct ParseOptions; + +} // namespace json +} // namespace arrow diff --git a/cpp/src/arrow/util/type_fwd.h b/cpp/src/arrow/util/type_fwd.h index 3eabd0d2553..e51ebc8509b 100644 --- a/cpp/src/arrow/util/type_fwd.h +++ b/cpp/src/arrow/util/type_fwd.h @@ -22,6 +22,8 @@ namespace arrow { template class Future; +class TimestampParser; + namespace internal { class Executor; diff --git a/cpp/src/parquet/arrow/generate_fuzz_corpus.cc b/cpp/src/parquet/arrow/generate_fuzz_corpus.cc index ec5accdeea0..33c3a1461b6 100644 --- a/cpp/src/parquet/arrow/generate_fuzz_corpus.cc +++ b/cpp/src/parquet/arrow/generate_fuzz_corpus.cc @@ -195,4 +195,4 @@ int Main(int argc, char** argv) { } // namespace arrow -int main(int argc, char** argv) { return arrow::Main(argc, argv); } +int main(int argc, char** argv) { return ::arrow::Main(argc, argv); } diff --git a/cpp/src/parquet/arrow/schema_internal.cc b/cpp/src/parquet/arrow/schema_internal.cc index 4d37519d39e..3d83a382d3f 100644 --- a/cpp/src/parquet/arrow/schema_internal.cc +++ b/cpp/src/parquet/arrow/schema_internal.cc @@ -19,8 +19,8 @@ #include "arrow/type.h" -using ArrowType = arrow::DataType; -using ArrowTypeId = arrow::Type; +using ArrowType = ::arrow::DataType; +using ArrowTypeId = ::arrow::Type; using ParquetType = parquet::Type; namespace parquet { diff --git a/cpp/src/parquet/column_writer.cc b/cpp/src/parquet/column_writer.cc index b68ad4537c4..db3f427572c 100644 --- a/cpp/src/parquet/column_writer.cc +++ b/cpp/src/parquet/column_writer.cc @@ -1129,7 +1129,7 @@ class TypedColumnWriterImpl : public ColumnWriterImpl, public TypedColumnWriter< if (maybe_parent_nulls) { ARROW_ASSIGN_OR_RAISE( bits_buffer_, - arrow::AllocateResizableBuffer( + ::arrow::AllocateResizableBuffer( BitUtil::BytesForBits(properties_->write_batch_size()), ctx->memory_pool)); bits_buffer_->ZeroPadding(); } @@ -1304,7 +1304,7 @@ class TypedColumnWriterImpl : public ColumnWriterImpl, public TypedColumnWriter< Result> MaybeReplaceValidity(std::shared_ptr array, int64_t new_null_count, - arrow::MemoryPool* memory_pool) { + ::arrow::MemoryPool* memory_pool) { if (bits_buffer_ == nullptr) { return array; } @@ -1320,7 +1320,7 @@ class TypedColumnWriterImpl : public ColumnWriterImpl, public TypedColumnWriter< RETURN_NOT_OK(::arrow::VisitArrayInline(*array, &slicer)); buffers[1] = slicer.buffer_; } - return arrow::MakeArray(std::make_shared( + return ::arrow::MakeArray(std::make_shared( array->type(), array->length(), std::move(buffers), new_null_count)); } @@ -1462,7 +1462,7 @@ Status TypedColumnWriterImpl::WriteArrowDictionary( auto WriteIndicesChunk = [&](int64_t offset, int64_t batch_size) { int64_t batch_num_values = 0; int64_t batch_num_spaced_values = 0; - int64_t null_count = arrow::kUnknownNullCount; + int64_t null_count = ::arrow::kUnknownNullCount; // Bits is not null for nullable values. At this point in the code we can't determine // if the leaf array has the same null values as any parents it might have had so we // need to recompute it from def levels. diff --git a/cpp/src/parquet/encoding_benchmark.cc b/cpp/src/parquet/encoding_benchmark.cc index c12ce98a639..8e409c5e429 100644 --- a/cpp/src/parquet/encoding_benchmark.cc +++ b/cpp/src/parquet/encoding_benchmark.cc @@ -202,7 +202,7 @@ BENCHMARK(BM_PlainDecodingFloat)->Range(MIN_RANGE, MAX_RANGE); template struct BM_SpacedEncodingTraits { using ArrowType = typename EncodingTraits::ArrowType; - using ArrayType = typename arrow::TypeTraits::ArrayType; + using ArrayType = typename ::arrow::TypeTraits::ArrayType; using CType = typename ParquetType::c_type; }; @@ -236,7 +236,7 @@ static void BM_PlainEncodingSpaced(benchmark::State& state) { auto rand = ::arrow::random::RandomArrayGenerator(1923); const auto array = rand.Numeric(num_values, -100, 100, null_percent); const auto valid_bits = array->null_bitmap_data(); - const auto array_actual = arrow::internal::checked_pointer_cast(array); + const auto array_actual = ::arrow::internal::checked_pointer_cast(array); const auto raw_values = array_actual->raw_values(); // Guarantee the type cast between raw_values and input of PutSpaced. static_assert(sizeof(CType) == sizeof(*raw_values), "Type mismatch"); @@ -281,7 +281,7 @@ static void BM_PlainDecodingSpaced(benchmark::State& state) { const auto array = rand.Numeric(num_values, -100, 100, null_percent); const auto valid_bits = array->null_bitmap_data(); const int null_count = static_cast(array->null_count()); - const auto array_actual = arrow::internal::checked_pointer_cast(array); + const auto array_actual = ::arrow::internal::checked_pointer_cast(array); const auto raw_values = array_actual->raw_values(); // Guarantee the type cast between raw_values and input of PutSpaced. static_assert(sizeof(CType) == sizeof(*raw_values), "Type mismatch"); @@ -348,22 +348,22 @@ static void BM_ByteStreamSplitEncode(benchmark::State& state, EncodeFunc&& encod static void BM_ByteStreamSplitDecode_Float_Scalar(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeScalar); + state, ::arrow::util::internal::ByteStreamSplitDecodeScalar); } static void BM_ByteStreamSplitDecode_Double_Scalar(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeScalar); + state, ::arrow::util::internal::ByteStreamSplitDecodeScalar); } static void BM_ByteStreamSplitEncode_Float_Scalar(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeScalar); + state, ::arrow::util::internal::ByteStreamSplitEncodeScalar); } static void BM_ByteStreamSplitEncode_Double_Scalar(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeScalar); + state, ::arrow::util::internal::ByteStreamSplitEncodeScalar); } BENCHMARK(BM_ByteStreamSplitDecode_Float_Scalar)->Range(MIN_RANGE, MAX_RANGE); @@ -374,22 +374,22 @@ BENCHMARK(BM_ByteStreamSplitEncode_Double_Scalar)->Range(MIN_RANGE, MAX_RANGE); #if defined(ARROW_HAVE_SSE4_2) static void BM_ByteStreamSplitDecode_Float_Sse2(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeSse2); + state, ::arrow::util::internal::ByteStreamSplitDecodeSse2); } static void BM_ByteStreamSplitDecode_Double_Sse2(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeSse2); + state, ::arrow::util::internal::ByteStreamSplitDecodeSse2); } static void BM_ByteStreamSplitEncode_Float_Sse2(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeSse2); + state, ::arrow::util::internal::ByteStreamSplitEncodeSse2); } static void BM_ByteStreamSplitEncode_Double_Sse2(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeSse2); + state, ::arrow::util::internal::ByteStreamSplitEncodeSse2); } BENCHMARK(BM_ByteStreamSplitDecode_Float_Sse2)->Range(MIN_RANGE, MAX_RANGE); @@ -401,22 +401,22 @@ BENCHMARK(BM_ByteStreamSplitEncode_Double_Sse2)->Range(MIN_RANGE, MAX_RANGE); #if defined(ARROW_HAVE_AVX2) static void BM_ByteStreamSplitDecode_Float_Avx2(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeAvx2); + state, ::arrow::util::internal::ByteStreamSplitDecodeAvx2); } static void BM_ByteStreamSplitDecode_Double_Avx2(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeAvx2); + state, ::arrow::util::internal::ByteStreamSplitDecodeAvx2); } static void BM_ByteStreamSplitEncode_Float_Avx2(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeAvx2); + state, ::arrow::util::internal::ByteStreamSplitEncodeAvx2); } static void BM_ByteStreamSplitEncode_Double_Avx2(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeAvx2); + state, ::arrow::util::internal::ByteStreamSplitEncodeAvx2); } BENCHMARK(BM_ByteStreamSplitDecode_Float_Avx2)->Range(MIN_RANGE, MAX_RANGE); @@ -428,22 +428,22 @@ BENCHMARK(BM_ByteStreamSplitEncode_Double_Avx2)->Range(MIN_RANGE, MAX_RANGE); #if defined(ARROW_HAVE_AVX512) static void BM_ByteStreamSplitDecode_Float_Avx512(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeAvx512); + state, ::arrow::util::internal::ByteStreamSplitDecodeAvx512); } static void BM_ByteStreamSplitDecode_Double_Avx512(benchmark::State& state) { BM_ByteStreamSplitDecode( - state, arrow::util::internal::ByteStreamSplitDecodeAvx512); + state, ::arrow::util::internal::ByteStreamSplitDecodeAvx512); } static void BM_ByteStreamSplitEncode_Float_Avx512(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeAvx512); + state, ::arrow::util::internal::ByteStreamSplitEncodeAvx512); } static void BM_ByteStreamSplitEncode_Double_Avx512(benchmark::State& state) { BM_ByteStreamSplitEncode( - state, arrow::util::internal::ByteStreamSplitEncodeAvx512); + state, ::arrow::util::internal::ByteStreamSplitEncodeAvx512); } BENCHMARK(BM_ByteStreamSplitDecode_Float_Avx512)->Range(MIN_RANGE, MAX_RANGE); diff --git a/cpp/src/parquet/encoding_test.cc b/cpp/src/parquet/encoding_test.cc index 6766c95dcdd..7d107328f38 100644 --- a/cpp/src/parquet/encoding_test.cc +++ b/cpp/src/parquet/encoding_test.cc @@ -60,7 +60,7 @@ TEST(VectorBooleanTest, TestEncodeDecode) { int nbytes = static_cast(BitUtil::BytesForBits(nvalues)); std::vector draws; - arrow::random_is_valid(nvalues, 0.5 /* null prob */, &draws, 0 /* seed */); + ::arrow::random_is_valid(nvalues, 0.5 /* null prob */, &draws, 0 /* seed */); std::unique_ptr encoder = MakeTypedEncoder(Encoding::PLAIN); @@ -81,7 +81,7 @@ TEST(VectorBooleanTest, TestEncodeDecode) { ASSERT_EQ(nvalues, values_decoded); for (int i = 0; i < nvalues; ++i) { - ASSERT_EQ(draws[i], arrow::BitUtil::GetBit(decode_data, i)) << i; + ASSERT_EQ(draws[i], ::arrow::BitUtil::GetBit(decode_data, i)) << i; } } @@ -408,8 +408,8 @@ TEST(TestDictionaryEncoding, CannotDictDecodeBoolean) { class TestArrowBuilderDecoding : public ::testing::Test { public: - using DenseBuilder = arrow::internal::ChunkedBinaryBuilder; - using DictBuilder = arrow::BinaryDictionary32Builder; + using DenseBuilder = ::arrow::internal::ChunkedBinaryBuilder; + using DictBuilder = ::arrow::BinaryDictionary32Builder; void SetUp() override { null_probabilities_ = {0.0, 0.5, 1.0}; } void TearDown() override {} @@ -424,7 +424,7 @@ class TestArrowBuilderDecoding : public ::testing::Test { constexpr int repeat = 100; constexpr int64_t min_length = 2; constexpr int64_t max_length = 10; - arrow::random::RandomArrayGenerator rag(0); + ::arrow::random::RandomArrayGenerator rag(0); expected_dense_ = rag.BinaryWithRepeats(repeat * num_unique, num_unique, min_length, max_length, null_probability); @@ -437,7 +437,7 @@ class TestArrowBuilderDecoding : public ::testing::Test { ASSERT_OK(builder->Finish(&expected_dict_)); // Initialize input_data_ for the encoder from the expected_array_ values - const auto& binary_array = static_cast(*expected_dense_); + const auto& binary_array = static_cast(*expected_dense_); input_data_.resize(binary_array.length()); for (int64_t i = 0; i < binary_array.length(); ++i) { @@ -454,7 +454,7 @@ class TestArrowBuilderDecoding : public ::testing::Test { // Setup encoder/decoder pair for testing with virtual void SetupEncoderDecoder() = 0; - void CheckDense(int actual_num_values, const arrow::Array& chunk) { + void CheckDense(int actual_num_values, const ::arrow::Array& chunk) { ASSERT_EQ(actual_num_values, num_values_ - null_count_); ASSERT_ARRAYS_EQUAL(chunk, *expected_dense_); } @@ -462,7 +462,7 @@ class TestArrowBuilderDecoding : public ::testing::Test { template void CheckDict(int actual_num_values, Builder& builder) { ASSERT_EQ(actual_num_values, num_values_ - null_count_); - std::shared_ptr actual; + std::shared_ptr<::arrow::Array> actual; ASSERT_OK(builder.Finish(&actual)); ASSERT_ARRAYS_EQUAL(*actual, *expected_dict_); } @@ -517,8 +517,8 @@ class TestArrowBuilderDecoding : public ::testing::Test { protected: std::vector null_probabilities_; - std::shared_ptr expected_dict_; - std::shared_ptr expected_dense_; + std::shared_ptr<::arrow::Array> expected_dict_; + std::shared_ptr<::arrow::Array> expected_dense_; int num_values_; int null_count_; std::vector input_data_; @@ -572,7 +572,7 @@ TEST(PlainEncodingAdHoc, ArrowBinaryDirectPut) { const double null_probability = 0.25; auto CheckSeed = [&](int seed) { - arrow::random::RandomArrayGenerator rag(seed); + ::arrow::random::RandomArrayGenerator rag(seed); auto values = rag.String(size, min_length, max_length, null_probability); auto encoder = MakeTypedEncoder(Encoding::PLAIN); @@ -585,7 +585,7 @@ TEST(PlainEncodingAdHoc, ArrowBinaryDirectPut) { decoder->SetData(num_values, buf->data(), static_cast(buf->size())); typename EncodingTraits::Accumulator acc; - acc.builder.reset(new arrow::StringBuilder); + acc.builder.reset(new ::arrow::StringBuilder); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(values->length()), static_cast(values->null_count()), @@ -594,7 +594,7 @@ TEST(PlainEncodingAdHoc, ArrowBinaryDirectPut) { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.builder->Finish(&result)); ASSERT_EQ(50, result->length()); - arrow::AssertArraysEqual(*values, *result); + ::arrow::AssertArraysEqual(*values, *result); }; for (auto seed : {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}) { @@ -642,9 +642,9 @@ class EncodingAdHocTyped : public ::testing::Test { return column_descr.get(); } - std::shared_ptr GetValues(int seed); + std::shared_ptr<::arrow::Array> GetValues(int seed); - static std::shared_ptr arrow_type(); + static std::shared_ptr<::arrow::DataType> arrow_type(); void Plain(int seed) { auto values = GetValues(seed); @@ -658,7 +658,7 @@ class EncodingAdHocTyped : public ::testing::Test { int num_values = static_cast(values->length() - values->null_count()); decoder->SetData(num_values, buf->data(), static_cast(buf->size())); - BuilderType acc(arrow_type(), arrow::default_memory_pool()); + BuilderType acc(arrow_type(), ::arrow::default_memory_pool()); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(values->length()), static_cast(values->null_count()), @@ -667,7 +667,7 @@ class EncodingAdHocTyped : public ::testing::Test { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.Finish(&result)); ASSERT_EQ(50, result->length()); - arrow::AssertArraysEqual(*values, *result); + ::arrow::AssertArraysEqual(*values, *result); } void ByteStreamSplit(int seed) { @@ -687,7 +687,7 @@ class EncodingAdHocTyped : public ::testing::Test { int num_values = static_cast(values->length() - values->null_count()); decoder->SetData(num_values, buf->data(), static_cast(buf->size())); - BuilderType acc(arrow_type(), arrow::default_memory_pool()); + BuilderType acc(arrow_type(), ::arrow::default_memory_pool()); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(values->length()), static_cast(values->null_count()), @@ -696,7 +696,7 @@ class EncodingAdHocTyped : public ::testing::Test { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.Finish(&result)); ASSERT_EQ(50, result->length()); - arrow::AssertArraysEqual(*values, *result); + ::arrow::AssertArraysEqual(*values, *result); } void Dict(int seed) { @@ -719,7 +719,7 @@ class EncodingAdHocTyped : public ::testing::Test { std::unique_ptr> decoder; GetDictDecoder(encoder, num_values, &buf, &dict_buf, column_descr(), &decoder); - BuilderType acc(arrow_type(), arrow::default_memory_pool()); + BuilderType acc(arrow_type(), ::arrow::default_memory_pool()); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(values->length()), static_cast(values->null_count()), @@ -727,7 +727,7 @@ class EncodingAdHocTyped : public ::testing::Test { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.Finish(&result)); - arrow::AssertArraysEqual(*values, *result); + ::arrow::AssertArraysEqual(*values, *result); } void DictPutIndices() { @@ -735,14 +735,15 @@ class EncodingAdHocTyped : public ::testing::Test { return; } - auto dict_values = - arrow::ArrayFromJSON(arrow_type(), std::is_same::value - ? R"(["abcdefgh", "ijklmnop", "qrstuvwx"])" - : "[120, -37, 47]"); - auto indices = arrow::ArrayFromJSON(arrow::int32(), "[0, 1, 2]"); - auto indices_nulls = arrow::ArrayFromJSON(arrow::int32(), "[null, 0, 1, null, 2]"); + auto dict_values = ::arrow::ArrayFromJSON( + arrow_type(), std::is_same::value + ? R"(["abcdefgh", "ijklmnop", "qrstuvwx"])" + : "[120, -37, 47]"); + auto indices = ::arrow::ArrayFromJSON(::arrow::int32(), "[0, 1, 2]"); + auto indices_nulls = + ::arrow::ArrayFromJSON(::arrow::int32(), "[null, 0, 1, null, 2]"); - auto expected = arrow::ArrayFromJSON( + auto expected = ::arrow::ArrayFromJSON( arrow_type(), std::is_same::value ? R"(["abcdefgh", "ijklmnop", "qrstuvwx", null, "abcdefgh", "ijklmnop", null, "qrstuvwx"])" @@ -770,7 +771,7 @@ class EncodingAdHocTyped : public ::testing::Test { std::unique_ptr> decoder; GetDictDecoder(encoder, num_values, &buf, &dict_buf, column_descr(), &decoder); - BuilderType acc(arrow_type(), arrow::default_memory_pool()); + BuilderType acc(arrow_type(), ::arrow::default_memory_pool()); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(expected->length()), static_cast(expected->null_count()), expected->null_bitmap_data(), @@ -778,7 +779,7 @@ class EncodingAdHocTyped : public ::testing::Test { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.Finish(&result)); - arrow::AssertArraysEqual(*expected, *result); + ::arrow::AssertArraysEqual(*expected, *result); } protected: @@ -788,29 +789,29 @@ class EncodingAdHocTyped : public ::testing::Test { template std::shared_ptr EncodingAdHocTyped::arrow_type() { - return arrow::TypeTraits::type_singleton(); + return ::arrow::TypeTraits::type_singleton(); } template <> std::shared_ptr EncodingAdHocTyped::arrow_type() { - return arrow::fixed_size_binary(sizeof(uint64_t)); + return ::arrow::fixed_size_binary(sizeof(uint64_t)); } template std::shared_ptr EncodingAdHocTyped::GetValues(int seed) { - arrow::random::RandomArrayGenerator rag(seed); + ::arrow::random::RandomArrayGenerator rag(seed); return rag.Numeric(size_, 0, 10, null_probability_); } template <> std::shared_ptr EncodingAdHocTyped::GetValues(int seed) { - arrow::random::RandomArrayGenerator rag(seed); + ::arrow::random::RandomArrayGenerator rag(seed); return rag.Boolean(size_, 0.1, null_probability_); } template <> std::shared_ptr EncodingAdHocTyped::GetValues(int seed) { - arrow::random::RandomArrayGenerator rag(seed); + ::arrow::random::RandomArrayGenerator rag(seed); std::shared_ptr values; ARROW_EXPECT_OK( rag.UInt64(size_, 0, std::numeric_limits::max(), null_probability_) @@ -842,7 +843,7 @@ TEST(DictEncodingAdHoc, ArrowBinaryDirectPut) { const int64_t min_length = 0; const int64_t max_length = 10; const double null_probability = 0.1; - arrow::random::RandomArrayGenerator rag(0); + ::arrow::random::RandomArrayGenerator rag(0); auto values = rag.String(size, min_length, max_length, null_probability); auto owned_encoder = MakeTypedEncoder(Encoding::PLAIN, @@ -858,7 +859,7 @@ TEST(DictEncodingAdHoc, ArrowBinaryDirectPut) { GetDictDecoder(encoder, num_values, &buf, &dict_buf, nullptr, &decoder); typename EncodingTraits::Accumulator acc; - acc.builder.reset(new arrow::StringBuilder); + acc.builder.reset(new ::arrow::StringBuilder); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(values->length()), static_cast(values->null_count()), @@ -866,22 +867,23 @@ TEST(DictEncodingAdHoc, ArrowBinaryDirectPut) { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.builder->Finish(&result)); - arrow::AssertArraysEqual(*values, *result); + ::arrow::AssertArraysEqual(*values, *result); } TYPED_TEST(EncodingAdHocTyped, DictArrowDirectPut) { this->Dict(0); } TEST(DictEncodingAdHoc, PutDictionaryPutIndices) { // Part of ARROW-3246 - auto dict_values = arrow::ArrayFromJSON(arrow::binary(), "[\"foo\", \"bar\", \"baz\"]"); + auto dict_values = + ::arrow::ArrayFromJSON(::arrow::binary(), "[\"foo\", \"bar\", \"baz\"]"); - auto CheckIndexType = [&](const std::shared_ptr& index_ty) { - auto indices = arrow::ArrayFromJSON(index_ty, "[0, 1, 2]"); - auto indices_nulls = arrow::ArrayFromJSON(index_ty, "[null, 0, 1, null, 2]"); + auto CheckIndexType = [&](const std::shared_ptr<::arrow::DataType>& index_ty) { + auto indices = ::arrow::ArrayFromJSON(index_ty, "[0, 1, 2]"); + auto indices_nulls = ::arrow::ArrayFromJSON(index_ty, "[null, 0, 1, null, 2]"); - auto expected = arrow::ArrayFromJSON(arrow::binary(), - "[\"foo\", \"bar\", \"baz\", null, " - "\"foo\", \"bar\", null, \"baz\"]"); + auto expected = ::arrow::ArrayFromJSON(arrow::binary(), + "[\"foo\", \"bar\", \"baz\", null, " + "\"foo\", \"bar\", null, \"baz\"]"); auto owned_encoder = MakeTypedEncoder(Encoding::PLAIN, /*use_dictionary=*/true); @@ -903,7 +905,7 @@ TEST(DictEncodingAdHoc, PutDictionaryPutIndices) { GetDictDecoder(encoder, num_values, &buf, &dict_buf, nullptr, &decoder); typename EncodingTraits::Accumulator acc; - acc.builder.reset(new arrow::BinaryBuilder); + acc.builder.reset(new ::arrow::BinaryBuilder); ASSERT_EQ(num_values, decoder->DecodeArrow(static_cast(expected->length()), static_cast(expected->null_count()), expected->null_bitmap_data(), @@ -911,7 +913,7 @@ TEST(DictEncodingAdHoc, PutDictionaryPutIndices) { std::shared_ptr<::arrow::Array> result; ASSERT_OK(acc.builder->Finish(&result)); - arrow::AssertArraysEqual(*expected, *result); + ::arrow::AssertArraysEqual(*expected, *result); }; for (auto ty : ::arrow::all_dictionary_index_types()) { @@ -988,7 +990,7 @@ TEST_F(DictEncoding, CheckDecodeIndicesSpaced) { num_values_, null_count_, valid_bits_, 0, builder.get()); } ASSERT_EQ(actual_num_values, num_values_ - null_count_); - std::shared_ptr actual; + std::shared_ptr<::arrow::Array> actual; ASSERT_OK(builder->Finish(&actual)); ASSERT_ARRAYS_EQUAL(*actual, *expected_dict_); diff --git a/cpp/src/parquet/file_reader.cc b/cpp/src/parquet/file_reader.cc index 67f211b29c7..332493cf230 100644 --- a/cpp/src/parquet/file_reader.cc +++ b/cpp/src/parquet/file_reader.cc @@ -88,9 +88,9 @@ const RowGroupMetaData* RowGroupReader::metadata() const { return contents_->met /// Compute the section of the file that should be read for the given /// row group and column chunk. -arrow::io::ReadRange ComputeColumnChunkRange(FileMetaData* file_metadata, - int64_t source_size, int row_group_index, - int column_index) { +::arrow::io::ReadRange ComputeColumnChunkRange(FileMetaData* file_metadata, + int64_t source_size, int row_group_index, + int column_index) { auto row_group_metadata = file_metadata->RowGroup(row_group_index); auto column_metadata = row_group_metadata->ColumnChunk(column_index); @@ -142,7 +142,7 @@ class SerializedRowGroup : public RowGroupReader::Contents { // Read column chunk from the file auto col = row_group_metadata_->ColumnChunk(i); - arrow::io::ReadRange col_range = + ::arrow::io::ReadRange col_range = ComputeColumnChunkRange(file_metadata_, source_size_, row_group_ordinal_, i); std::shared_ptr stream; if (cached_source_) { @@ -254,8 +254,8 @@ class SerializedFile : public ParquetFileReader::Contents { const ::arrow::io::AsyncContext& ctx, const ::arrow::io::CacheOptions& options) { cached_source_ = - std::make_shared(source_, ctx, options); - std::vector ranges; + std::make_shared<::arrow::io::internal::ReadRangeCache>(source_, ctx, options); + std::vector<::arrow::io::ReadRange> ranges; for (int row : row_groups) { for (int col : column_indices) { ranges.push_back( @@ -316,7 +316,7 @@ class SerializedFile : public ParquetFileReader::Contents { private: std::shared_ptr source_; - std::shared_ptr cached_source_; + std::shared_ptr<::arrow::io::internal::ReadRangeCache> cached_source_; int64_t source_size_; std::shared_ptr file_metadata_; ReaderProperties properties_; @@ -344,7 +344,7 @@ void SerializedFile::ParseUnencryptedFileMetadata( const std::shared_ptr& footer_buffer, int64_t footer_read_size, std::shared_ptr* metadata_buffer, uint32_t* metadata_len, uint32_t* read_metadata_len) { - *metadata_len = arrow::util::SafeLoadAs( + *metadata_len = ::arrow::util::SafeLoadAs( reinterpret_cast(footer_buffer->data()) + footer_read_size - kFooterSize); int64_t metadata_start = source_size_ - kFooterSize - *metadata_len; @@ -376,7 +376,7 @@ void SerializedFile::ParseMetaDataOfEncryptedFileWithEncryptedFooter( const std::shared_ptr& footer_buffer, int64_t footer_read_size) { // encryption with encrypted footer // both metadata & crypto metadata length - uint32_t footer_len = arrow::util::SafeLoadAs( + uint32_t footer_len = ::arrow::util::SafeLoadAs( reinterpret_cast(footer_buffer->data()) + footer_read_size - kFooterSize); int64_t crypto_metadata_start = source_size_ - kFooterSize - footer_len; diff --git a/cpp/src/parquet/level_conversion_test.cc b/cpp/src/parquet/level_conversion_test.cc index a3036758a0a..bfce74ae3a8 100644 --- a/cpp/src/parquet/level_conversion_test.cc +++ b/cpp/src/parquet/level_conversion_test.cc @@ -38,7 +38,7 @@ using ::arrow::internal::Bitmap; using ::testing::ElementsAreArray; std::string BitmapToString(const uint8_t* bitmap, int64_t bit_count) { - return arrow::internal::Bitmap(bitmap, /*offset*/ 0, /*length=*/bit_count).ToString(); + return ::arrow::internal::Bitmap(bitmap, /*offset*/ 0, /*length=*/bit_count).ToString(); } std::string BitmapToString(const std::vector& bitmap, int64_t bit_count) { diff --git a/cpp/src/parquet/metadata.cc b/cpp/src/parquet/metadata.cc index 5407922ffa9..c2002efce07 100644 --- a/cpp/src/parquet/metadata.cc +++ b/cpp/src/parquet/metadata.cc @@ -936,7 +936,7 @@ void FileCryptoMetaData::WriteTo(::arrow::io::OutputStream* dst) const { std::string FileMetaData::SerializeToString() const { // We need to pass in an initial size. Since it will automatically // increase the buffer size to hold the metadata, we just leave it 0. - PARQUET_ASSIGN_OR_THROW(auto serializer, arrow::io::BufferOutputStream::Create(0)); + PARQUET_ASSIGN_OR_THROW(auto serializer, ::arrow::io::BufferOutputStream::Create(0)); WriteTo(serializer.get()); PARQUET_ASSIGN_OR_THROW(auto metadata_buffer, serializer->Finish()); return metadata_buffer->ToString(); diff --git a/cpp/src/parquet/platform.cc b/cpp/src/parquet/platform.cc index f1eabe0290f..5c355c28be1 100644 --- a/cpp/src/parquet/platform.cc +++ b/cpp/src/parquet/platform.cc @@ -34,7 +34,7 @@ std::shared_ptr<::arrow::io::BufferOutputStream> CreateOutputStream(MemoryPool* } std::shared_ptr AllocateBuffer(MemoryPool* pool, int64_t size) { - PARQUET_ASSIGN_OR_THROW(auto result, arrow::AllocateResizableBuffer(size, pool)); + PARQUET_ASSIGN_OR_THROW(auto result, ::arrow::AllocateResizableBuffer(size, pool)); return std::move(result); } diff --git a/cpp/src/parquet/printer.cc b/cpp/src/parquet/printer.cc index 224a19dda6b..164e76f1df4 100644 --- a/cpp/src/parquet/printer.cc +++ b/cpp/src/parquet/printer.cc @@ -123,7 +123,7 @@ void ParquetFilePrinter::DebugPrint(std::ostream& stream, std::list selecte } stream << std::endl << " Compression: " - << arrow::internal::AsciiToUpper( + << ::arrow::internal::AsciiToUpper( Codec::GetCodecAsString(column_chunk->compression())) << ", Encodings:"; for (auto encoding : column_chunk->encodings()) { @@ -259,7 +259,7 @@ void ParquetFilePrinter::JSONPrint(std::ostream& stream, std::list selected stream << "\"False\","; } stream << "\n \"Compression\": \"" - << arrow::internal::AsciiToUpper( + << ::arrow::internal::AsciiToUpper( Codec::GetCodecAsString(column_chunk->compression())) << "\", \"Encodings\": \""; for (auto encoding : column_chunk->encodings()) { diff --git a/cpp/src/parquet/properties.h b/cpp/src/parquet/properties.h index 2d9725c2b49..f0422012122 100644 --- a/cpp/src/parquet/properties.h +++ b/cpp/src/parquet/properties.h @@ -31,6 +31,7 @@ #include "parquet/parquet_version.h" #include "parquet/platform.h" #include "parquet/schema.h" +#include "parquet/type_fwd.h" #include "parquet/types.h" namespace parquet { @@ -45,9 +46,7 @@ namespace parquet { /// Note that the 2.x format version series also introduced new serialized /// data page metadata and on disk data page layout. To enable this, use /// ParquetDataPageVersion. -struct ParquetVersion { - enum type { PARQUET_1_0, PARQUET_2_0 }; -}; +struct ParquetVersion; /// Controls serialization format of data pages. parquet-format v2.0.0 /// introduced a new data page metadata type DataPageV2 and serialized page diff --git a/cpp/src/parquet/properties_test.cc b/cpp/src/parquet/properties_test.cc index 39dbb7f0556..7ce96e4a7d7 100644 --- a/cpp/src/parquet/properties_test.cc +++ b/cpp/src/parquet/properties_test.cc @@ -72,7 +72,7 @@ TEST(TestReaderProperties, GetStreamInsufficientData) { // ARROW-6058 std::string data = "shorter than expected"; auto buf = std::make_shared(data); - auto reader = std::make_shared(buf); + auto reader = std::make_shared<::arrow::io::BufferReader>(buf); ReaderProperties props; try { diff --git a/cpp/src/parquet/reader_test.cc b/cpp/src/parquet/reader_test.cc index 5fda439e4a1..8dbcde8e5f2 100644 --- a/cpp/src/parquet/reader_test.cc +++ b/cpp/src/parquet/reader_test.cc @@ -450,22 +450,22 @@ TEST(TestFileReader, BufferedReads) { std::shared_ptr writer_props = WriterProperties::Builder().write_batch_size(64)->data_pagesize(128)->build(); - ASSERT_OK_AND_ASSIGN(auto out_file, arrow::io::BufferOutputStream::Create()); + ASSERT_OK_AND_ASSIGN(auto out_file, ::arrow::io::BufferOutputStream::Create()); std::shared_ptr file_writer = ParquetFileWriter::Open(out_file, schema, writer_props); RowGroupWriter* rg_writer = file_writer->AppendRowGroup(); - std::vector> column_data; + ::arrow::ArrayVector column_data; ::arrow::random::RandomArrayGenerator rag(0); // Scratch space for reads - std::vector> scratch_space; + ::arrow::BufferVector scratch_space; // write columns for (int col_index = 0; col_index < num_columns; ++col_index) { DoubleWriter* writer = static_cast(rg_writer->NextColumn()); - std::shared_ptr col = rag.Float64(num_rows, 0, 100); + std::shared_ptr<::arrow::Array> col = rag.Float64(num_rows, 0, 100); const auto& col_typed = static_cast(*col); writer->WriteBatch(num_rows, nullptr, nullptr, col_typed.raw_values()); column_data.push_back(col); @@ -479,7 +479,7 @@ TEST(TestFileReader, BufferedReads) { // Open the reader ASSERT_OK_AND_ASSIGN(auto file_buf, out_file->Finish()); - auto in_file = std::make_shared(file_buf); + auto in_file = std::make_shared<::arrow::io::BufferReader>(file_buf); ReaderProperties reader_props; reader_props.enable_buffered_stream(); diff --git a/cpp/src/parquet/statistics_test.cc b/cpp/src/parquet/statistics_test.cc index 8edc5ee984f..7a86e3338af 100644 --- a/cpp/src/parquet/statistics_test.cc +++ b/cpp/src/parquet/statistics_test.cc @@ -654,7 +654,7 @@ class TestStatisticsSortOrder : public ::testing::Test { // Create a ParquetReader instance std::unique_ptr parquet_reader = parquet::ParquetFileReader::Open( - std::make_shared(pbuffer)); + std::make_shared<::arrow::io::BufferReader>(pbuffer)); // Get the File MetaData std::shared_ptr file_metadata = parquet_reader->metadata(); @@ -867,7 +867,7 @@ TEST_F(TestStatisticsSortOrderFLBA, UnknownSortOrder) { // Create a ParquetReader instance std::unique_ptr parquet_reader = parquet::ParquetFileReader::Open( - std::make_shared(pbuffer)); + std::make_shared<::arrow::io::BufferReader>(pbuffer)); // Get the File MetaData std::shared_ptr file_metadata = parquet_reader->metadata(); std::shared_ptr rg_metadata = file_metadata->RowGroup(0); diff --git a/cpp/src/parquet/stream_reader.h b/cpp/src/parquet/stream_reader.h index 5cac4cd0c85..806b0e8ad9a 100644 --- a/cpp/src/parquet/stream_reader.h +++ b/cpp/src/parquet/stream_reader.h @@ -58,7 +58,7 @@ namespace parquet { class PARQUET_EXPORT StreamReader { public: template - using optional = arrow::util::optional; + using optional = ::arrow::util::optional; // N.B. Default constructed objects are not usable. This // constructor is provided so that the object may be move diff --git a/cpp/src/parquet/stream_reader_test.cc b/cpp/src/parquet/stream_reader_test.cc index f6db4dd1969..eb7b133740e 100644 --- a/cpp/src/parquet/stream_reader_test.cc +++ b/cpp/src/parquet/stream_reader_test.cc @@ -34,7 +34,7 @@ namespace test { template using optional = StreamReader::optional; -using arrow::util::nullopt; +using ::arrow::util::nullopt; struct TestData { static void init() { std::time(&ts_offset_); } @@ -150,7 +150,7 @@ class TestStreamReader : public ::testing::Test { const char* GetDataFile() const { return "stream_reader_test.parquet"; } void SetUp() { - PARQUET_ASSIGN_OR_THROW(auto infile, arrow::io::ReadableFile::Open(GetDataFile())); + PARQUET_ASSIGN_OR_THROW(auto infile, ::arrow::io::ReadableFile::Open(GetDataFile())); auto file_reader = parquet::ParquetFileReader::Open(infile); reader_ = StreamReader{std::move(file_reader)}; } @@ -202,7 +202,7 @@ class TestStreamReader : public ::testing::Test { void createTestFile() { PARQUET_ASSIGN_OR_THROW(auto outfile, - arrow::io::FileOutputStream::Open(GetDataFile())); + ::arrow::io::FileOutputStream::Open(GetDataFile())); auto file_writer = ParquetFileWriter::Open(outfile, GetSchema()); @@ -591,7 +591,7 @@ class TestOptionalFields : public ::testing::Test { const char* GetDataFile() const { return "stream_reader_test_optional_fields.parquet"; } void SetUp() { - PARQUET_ASSIGN_OR_THROW(auto infile, arrow::io::ReadableFile::Open(GetDataFile())); + PARQUET_ASSIGN_OR_THROW(auto infile, ::arrow::io::ReadableFile::Open(GetDataFile())); auto file_reader = ParquetFileReader::Open(infile); @@ -645,7 +645,7 @@ class TestOptionalFields : public ::testing::Test { void createTestFile() { PARQUET_ASSIGN_OR_THROW(auto outfile, - arrow::io::FileOutputStream::Open(GetDataFile())); + ::arrow::io::FileOutputStream::Open(GetDataFile())); StreamWriter os{ParquetFileWriter::Open(outfile, GetSchema())}; @@ -835,8 +835,8 @@ class TestReadingDataFiles : public ::testing::Test { }; TEST_F(TestReadingDataFiles, AllTypesPlain) { - PARQUET_ASSIGN_OR_THROW( - auto infile, arrow::io::ReadableFile::Open(GetDataFile("alltypes_plain.parquet"))); + PARQUET_ASSIGN_OR_THROW(auto infile, ::arrow::io::ReadableFile::Open( + GetDataFile("alltypes_plain.parquet"))); auto file_reader = ParquetFileReader::Open(infile); auto reader = StreamReader{std::move(file_reader)}; @@ -880,7 +880,7 @@ TEST_F(TestReadingDataFiles, AllTypesPlain) { TEST_F(TestReadingDataFiles, Int32Decimal) { PARQUET_ASSIGN_OR_THROW( - auto infile, arrow::io::ReadableFile::Open(GetDataFile("int32_decimal.parquet"))); + auto infile, ::arrow::io::ReadableFile::Open(GetDataFile("int32_decimal.parquet"))); auto file_reader = ParquetFileReader::Open(infile); auto reader = StreamReader{std::move(file_reader)}; @@ -897,7 +897,7 @@ TEST_F(TestReadingDataFiles, Int32Decimal) { TEST_F(TestReadingDataFiles, Int64Decimal) { PARQUET_ASSIGN_OR_THROW( - auto infile, arrow::io::ReadableFile::Open(GetDataFile("int64_decimal.parquet"))); + auto infile, ::arrow::io::ReadableFile::Open(GetDataFile("int64_decimal.parquet"))); auto file_reader = ParquetFileReader::Open(infile); auto reader = StreamReader{std::move(file_reader)}; diff --git a/cpp/src/parquet/stream_writer.cc b/cpp/src/parquet/stream_writer.cc index ef03629d879..253ebf1bc91 100644 --- a/cpp/src/parquet/stream_writer.cc +++ b/cpp/src/parquet/stream_writer.cc @@ -136,7 +136,7 @@ StreamWriter& StreamWriter::operator<<(const std::string& v) { return WriteVariableLength(v.data(), v.size()); } -StreamWriter& StreamWriter::operator<<(arrow::util::string_view v) { +StreamWriter& StreamWriter::operator<<(::arrow::util::string_view v) { return WriteVariableLength(v.data(), v.size()); } diff --git a/cpp/src/parquet/stream_writer.h b/cpp/src/parquet/stream_writer.h index 4c7945960ea..d0db850c341 100644 --- a/cpp/src/parquet/stream_writer.h +++ b/cpp/src/parquet/stream_writer.h @@ -62,7 +62,7 @@ namespace parquet { class PARQUET_EXPORT StreamWriter { public: template - using optional = arrow::util::optional; + using optional = ::arrow::util::optional; // N.B. Default constructed objects are not usable. This // constructor is provided so that the object may be move @@ -149,7 +149,7 @@ class PARQUET_EXPORT StreamWriter { /// \brief Output operators for variable length strings. StreamWriter& operator<<(const char* v); StreamWriter& operator<<(const std::string& v); - StreamWriter& operator<<(arrow::util::string_view v); + StreamWriter& operator<<(::arrow::util::string_view v); /// \brief Output operator for optional fields. template diff --git a/cpp/src/parquet/stream_writer_test.cc b/cpp/src/parquet/stream_writer_test.cc index 62e714c4ec2..d427f51b6ab 100644 --- a/cpp/src/parquet/stream_writer_test.cc +++ b/cpp/src/parquet/stream_writer_test.cc @@ -297,7 +297,8 @@ TEST_F(TestStreamWriter, SkipColumns) { } TEST_F(TestStreamWriter, AppendNotImplemented) { - PARQUET_ASSIGN_OR_THROW(auto outfile, arrow::io::FileOutputStream::Open(GetDataFile())); + PARQUET_ASSIGN_OR_THROW(auto outfile, + ::arrow::io::FileOutputStream::Open(GetDataFile())); writer_ = StreamWriter{ParquetFileWriter::Open(outfile, GetSchema())}; writer_ << false << std::string("Just one row") << 'x' @@ -308,7 +309,7 @@ TEST_F(TestStreamWriter, AppendNotImplemented) { // Re-open file in append mode. PARQUET_ASSIGN_OR_THROW(outfile, - arrow::io::FileOutputStream::Open(GetDataFile(), true)); + ::arrow::io::FileOutputStream::Open(GetDataFile(), true)); EXPECT_THROW(ParquetFileWriter::Open(outfile, GetSchema()), ParquetException); } // namespace test diff --git a/cpp/src/parquet/test_encryption_util.h b/cpp/src/parquet/test_encryption_util.h index 39911e62d7a..e17ab0b0717 100644 --- a/cpp/src/parquet/test_encryption_util.h +++ b/cpp/src/parquet/test_encryption_util.h @@ -72,8 +72,8 @@ inline std::string data_file(const char* file) { // A temporary directory that contains the encrypted files generated in the tests. extern std::unique_ptr temp_dir; -inline arrow::Result> temp_data_dir() { - arrow::Result> dir; +inline ::arrow::Result> temp_data_dir() { + ::arrow::Result> dir; ARROW_ASSIGN_OR_RAISE(dir, TemporaryDir::Make("parquet-encryption-test-")); return dir; } diff --git a/cpp/src/parquet/type_fwd.h b/cpp/src/parquet/type_fwd.h index 2f5337b2b84..a427f5a9591 100644 --- a/cpp/src/parquet/type_fwd.h +++ b/cpp/src/parquet/type_fwd.h @@ -19,9 +19,21 @@ namespace parquet { +struct ParquetVersion { + enum type { PARQUET_1_0, PARQUET_2_0 }; +}; + class FileMetaData; class SchemaDescriptor; +class ReaderProperties; +class ArrowReaderProperties; + +class WriterProperties; +class WriterPropertiesBuilder; +class ArrowWriterProperties; +class ArrowWriterPropertiesBuilder; + namespace arrow { class FileWriter; diff --git a/r/src/arrow_exports.h b/r/src/arrow_exports.h deleted file mode 100644 index 381b7537fe0..00000000000 --- a/r/src/arrow_exports.h +++ /dev/null @@ -1,156 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -// This gets included in arrowExports.cpp - -#pragma once - -#include "./arrow_cpp11.h" - -#if defined(ARROW_R_WITH_ARROW) -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ds = ::arrow::dataset; -namespace fs = ::arrow::fs; - -namespace arrow { - -namespace compute { - -struct CastOptions; - -} // namespace compute - -namespace csv { - -class TableReader; -struct ConvertOptions; -struct ReadOptions; -struct ParseOptions; - -} // namespace csv - -namespace json { - -class TableReader; -struct ReadOptions; -struct ParseOptions; - -} // namespace json - -namespace dataset { -class DirectoryPartitioning; -class HivePartitioning; -} // namespace dataset - -} // namespace arrow - -namespace parquet { - -struct ParquetVersion { - enum type { - // forward declaration - }; -}; - -class ReaderProperties; -class ArrowReaderProperties; - -class WriterProperties; -class WriterPropertiesBuilder; -class ArrowWriterProperties; -class ArrowWriterPropertiesBuilder; - -namespace arrow { - -class FileReader; -class FileWriter; - -} // namespace arrow -} // namespace parquet - -namespace cpp11 { - -// Overrides of default R6 class names: -#define R6_CLASS_NAME(CLASS, NAME) \ - template <> \ - struct r6_class_name { \ - static const char* get(const std::shared_ptr&) { return NAME; } \ - } - -R6_CLASS_NAME(arrow::csv::ReadOptions, "CsvReadOptions"); -R6_CLASS_NAME(arrow::csv::ParseOptions, "CsvParseOptions"); -R6_CLASS_NAME(arrow::csv::ConvertOptions, "CsvConvertOptions"); -R6_CLASS_NAME(arrow::csv::TableReader, "CsvTableReader"); - -R6_CLASS_NAME(parquet::ArrowReaderProperties, "ParquetArrowReaderProperties"); -R6_CLASS_NAME(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties"); -R6_CLASS_NAME(parquet::WriterProperties, "ParquetWriterProperties"); -R6_CLASS_NAME(parquet::arrow::FileReader, "ParquetFileReader"); -R6_CLASS_NAME(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder"); -R6_CLASS_NAME(parquet::arrow::FileWriter, "ParquetFileWriter"); - -R6_CLASS_NAME(arrow::ipc::feather::Reader, "FeatherReader"); - -R6_CLASS_NAME(arrow::json::ReadOptions, "JsonReadOptions"); -R6_CLASS_NAME(arrow::json::ParseOptions, "JsonParseOptions"); -R6_CLASS_NAME(arrow::json::TableReader, "JsonTableReader"); - -#undef R6_CLASS_NAME - -// Declarations of discriminated base classes. -// Definitions reside in corresponding .cpp files. -template <> -struct r6_class_name { - static const char* get(const std::shared_ptr&); -}; - -template <> -struct r6_class_name { - static const char* get(const std::shared_ptr&); -}; - -template <> -struct r6_class_name { - static const char* get(const std::shared_ptr&); -}; - -template <> -struct r6_class_name { - static const char* get(const std::shared_ptr&); -}; - -template <> -struct r6_class_name { - static const char* get(const std::shared_ptr&); -}; - -template <> -struct r6_class_name { - static const char* get(const std::shared_ptr&); -}; - -} // namespace cpp11 - -#endif From 2074be072300ec9198e115c7a1bb0b4f83b91ec3 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Wed, 11 Nov 2020 12:49:50 -0500 Subject: [PATCH 39/43] delete arrow_exports.h --- r/data-raw/codegen.R | 2 +- r/src/array.cpp | 1 - r/src/arrowExports.cpp | 2 +- r/src/arrow_cpp11.h | 9 +---- r/src/arrow_types.h | 84 ++++++++++++++++++++++++++++++++++++++++++ r/src/dataset.cpp | 2 - r/src/datatype.cpp | 2 +- r/src/filesystem.cpp | 1 - r/src/scalar.cpp | 1 - 9 files changed, 89 insertions(+), 15 deletions(-) diff --git a/r/data-raw/codegen.R b/r/data-raw/codegen.R index dbe2de62f3d..80660b30d06 100644 --- a/r/data-raw/codegen.R +++ b/r/data-raw/codegen.R @@ -140,7 +140,7 @@ writeLines(con = "src/arrowExports.cpp", glue::glue(' #include #include -#include "./arrow_exports.h" +#include "./arrow_types.h" {cpp_functions_definitions} {cpp_classes_finalizers} diff --git a/r/src/array.cpp b/r/src/array.cpp index ba79b80159c..e96e286a073 100644 --- a/r/src/array.cpp +++ b/r/src/array.cpp @@ -24,7 +24,6 @@ namespace cpp11 { -template <> const char* r6_class_name::get(const std::shared_ptr& array) { auto type = array->type_id(); switch (type) { diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index 33295484ca7..c9024d526fa 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -2,7 +2,7 @@ #include #include -#include "./arrow_exports.h" +#include "./arrow_types.h" // array.cpp #if defined(ARROW_R_WITH_ARROW) diff --git a/r/src/arrow_cpp11.h b/r/src/arrow_cpp11.h index 2e3daf66d96..2329db11e99 100644 --- a/r/src/arrow_cpp11.h +++ b/r/src/arrow_cpp11.h @@ -327,14 +327,9 @@ SEXP to_r6(const std::shared_ptr& ptr, const char* r6_class_name) { /// respectively. Other classes such as arrow::Array are base classes and the proper R6 /// class name must be derived by examining a discriminant like Array::type_id. /// -/// All specializations are located in arrow_exports.h to be visible in generated code. +/// All specializations are located in arrow_types.h template -struct r6_class_name { - static const char* get(const std::shared_ptr& ptr) { - static const std::string name = arrow::util::nameof(/*strip_namespace=*/true); - return name.c_str(); - } -}; +struct r6_class_name; template SEXP to_r6(const std::shared_ptr& x) { diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index e43effa3ddb..23cd298b220 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -25,15 +25,28 @@ #include // for RBuffer definition below #include +#include +#include +#include #include +#include +#include +#include #include +#include #include +#include +#include +#include #include #include #include #include +namespace ds = ::arrow::dataset; +namespace fs = ::arrow::fs; + SEXP ChunkedArray__as_vector(const std::shared_ptr& chunked_array); SEXP Array__as_vector(const std::shared_ptr& array); std::shared_ptr Array__from_vector(SEXP x, SEXP type); @@ -120,4 +133,75 @@ arrow::Status AddMetadataFromDots(SEXP lst, int num_fields, } // namespace r } // namespace arrow +namespace cpp11 { + +template +struct r6_class_name { + static const char* get(const std::shared_ptr& ptr) { + static const std::string name = arrow::util::nameof(/*strip_namespace=*/true); + return name.c_str(); + } +}; + +// Overrides of default R6 class names: +#define R6_CLASS_NAME(CLASS, NAME) \ + template <> \ + struct r6_class_name { \ + static const char* get(const std::shared_ptr&) { return NAME; } \ + } + +R6_CLASS_NAME(arrow::csv::ReadOptions, "CsvReadOptions"); +R6_CLASS_NAME(arrow::csv::ParseOptions, "CsvParseOptions"); +R6_CLASS_NAME(arrow::csv::ConvertOptions, "CsvConvertOptions"); +R6_CLASS_NAME(arrow::csv::TableReader, "CsvTableReader"); + +R6_CLASS_NAME(parquet::ArrowReaderProperties, "ParquetArrowReaderProperties"); +R6_CLASS_NAME(parquet::ArrowWriterProperties, "ParquetArrowWriterProperties"); +R6_CLASS_NAME(parquet::WriterProperties, "ParquetWriterProperties"); +R6_CLASS_NAME(parquet::arrow::FileReader, "ParquetFileReader"); +R6_CLASS_NAME(parquet::WriterPropertiesBuilder, "ParquetWriterPropertiesBuilder"); +R6_CLASS_NAME(parquet::arrow::FileWriter, "ParquetFileWriter"); + +R6_CLASS_NAME(arrow::ipc::feather::Reader, "FeatherReader"); + +R6_CLASS_NAME(arrow::json::ReadOptions, "JsonReadOptions"); +R6_CLASS_NAME(arrow::json::ParseOptions, "JsonParseOptions"); +R6_CLASS_NAME(arrow::json::TableReader, "JsonTableReader"); + +#undef R6_CLASS_NAME + +// Declarations of discriminated base classes. +// Definitions reside in corresponding .cpp files. +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +template <> +struct r6_class_name { + static const char* get(const std::shared_ptr&); +}; + +} // namespace cpp11 + #endif diff --git a/r/src/dataset.cpp b/r/src/dataset.cpp index 95a45b3ac1e..2ad59677eb0 100644 --- a/r/src/dataset.cpp +++ b/r/src/dataset.cpp @@ -31,7 +31,6 @@ namespace fs = ::arrow::fs; namespace cpp11 { -template <> const char* r6_class_name::get(const std::shared_ptr& dataset) { auto type_name = dataset->type_name(); @@ -46,7 +45,6 @@ const char* r6_class_name::get(const std::shared_ptr& } } -template <> const char* r6_class_name::get( const std::shared_ptr& file_format) { auto type_name = file_format->type_name(); diff --git a/r/src/datatype.cpp b/r/src/datatype.cpp index d5030dd5d5f..6e7398bdff0 100644 --- a/r/src/datatype.cpp +++ b/r/src/datatype.cpp @@ -21,7 +21,7 @@ #include namespace cpp11 { -template <> + const char* r6_class_name::get( const std::shared_ptr& type) { using arrow::Type; diff --git a/r/src/filesystem.cpp b/r/src/filesystem.cpp index bdfc2509cad..066e5b540f2 100644 --- a/r/src/filesystem.cpp +++ b/r/src/filesystem.cpp @@ -26,7 +26,6 @@ namespace fs = ::arrow::fs; namespace cpp11 { -template <> const char* r6_class_name::get( const std::shared_ptr& file_system) { auto type_name = file_system->type_name(); diff --git a/r/src/scalar.cpp b/r/src/scalar.cpp index 02459641ad5..2c2d291b5bf 100644 --- a/r/src/scalar.cpp +++ b/r/src/scalar.cpp @@ -26,7 +26,6 @@ namespace cpp11 { -template <> const char* r6_class_name::get( const std::shared_ptr& scalar) { if (scalar->type->id() == arrow::Type::STRUCT) { From 1de18f126e622027202f7f93aba51870c88c0d67 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Wed, 11 Nov 2020 13:16:47 -0500 Subject: [PATCH 40/43] also forward declare compression and c abi classes --- cpp/src/arrow/ipc/feather.h | 2 +- cpp/src/arrow/util/compression.h | 22 ++-------------------- cpp/src/arrow/util/type_fwd.h | 23 +++++++++++++++++++++++ r/src/arrowExports.cpp | 6 +++--- r/src/arrow_types.h | 18 +++++++++--------- r/src/py-to-r.cpp | 6 ++++-- 6 files changed, 42 insertions(+), 35 deletions(-) diff --git a/cpp/src/arrow/ipc/feather.h b/cpp/src/arrow/ipc/feather.h index b40893c408f..a32ff6d0a5a 100644 --- a/cpp/src/arrow/ipc/feather.h +++ b/cpp/src/arrow/ipc/feather.h @@ -128,7 +128,7 @@ struct ARROW_EXPORT WriteProperties { Compression::type compression = Compression::UNCOMPRESSED; /// Compressor-specific compression level - int compression_level = Compression::kUseDefaultCompressionLevel; + int compression_level = ::arrow::util::kUseDefaultCompressionLevel; }; ARROW_EXPORT diff --git a/cpp/src/arrow/util/compression.h b/cpp/src/arrow/util/compression.h index d3e8e1e62f1..6c9a74c6d21 100644 --- a/cpp/src/arrow/util/compression.h +++ b/cpp/src/arrow/util/compression.h @@ -24,31 +24,13 @@ #include "arrow/result.h" #include "arrow/status.h" +#include "arrow/util/type_fwd.h" #include "arrow/util/visibility.h" namespace arrow { - -struct Compression { - /// \brief Compression algorithm - enum type { - UNCOMPRESSED, - SNAPPY, - GZIP, - BROTLI, - ZSTD, - LZ4, - LZ4_FRAME, - LZO, - BZ2, - LZ4_HADOOP - }; - - static constexpr int kUseDefaultCompressionLevel = std::numeric_limits::min(); -}; - namespace util { -constexpr int kUseDefaultCompressionLevel = Compression::kUseDefaultCompressionLevel; +constexpr int kUseDefaultCompressionLevel = std::numeric_limits::min(); /// \brief Streaming compressor interface /// diff --git a/cpp/src/arrow/util/type_fwd.h b/cpp/src/arrow/util/type_fwd.h index e51ebc8509b..cda77d52c10 100644 --- a/cpp/src/arrow/util/type_fwd.h +++ b/cpp/src/arrow/util/type_fwd.h @@ -31,4 +31,27 @@ class TaskGroup; class ThreadPool; } // namespace internal + +struct Compression { + /// \brief Compression algorithm + enum type { + UNCOMPRESSED, + SNAPPY, + GZIP, + BROTLI, + ZSTD, + LZ4, + LZ4_FRAME, + LZO, + BZ2, + LZ4_HADOOP + }; +}; + +namespace util { +class Compressor; +class Decompressor; +class Codec; +} // namespace util + } // namespace arrow diff --git a/r/src/arrowExports.cpp b/r/src/arrowExports.cpp index c9024d526fa..81e426ef656 100644 --- a/r/src/arrowExports.cpp +++ b/r/src/arrowExports.cpp @@ -5102,12 +5102,12 @@ extern "C" SEXP _arrow_ExportArray(SEXP array_sexp, SEXP array_ptr_sexp, SEXP sc // py-to-r.cpp #if defined(ARROW_R_WITH_ARROW) -void ExportRecordBatch(const std::shared_ptr& batch, arrow::r::Pointer array_ptr, arrow::r::Pointer schema_ptr); +void ExportRecordBatch(const std::shared_ptr& batch, arrow::r::Pointer array_ptr, arrow::r::Pointer schema_ptr); extern "C" SEXP _arrow_ExportRecordBatch(SEXP batch_sexp, SEXP array_ptr_sexp, SEXP schema_ptr_sexp){ BEGIN_CPP11 arrow::r::Input&>::type batch(batch_sexp); - arrow::r::Input>::type array_ptr(array_ptr_sexp); - arrow::r::Input>::type schema_ptr(schema_ptr_sexp); + arrow::r::Input>::type array_ptr(array_ptr_sexp); + arrow::r::Input>::type schema_ptr(schema_ptr_sexp); ExportRecordBatch(batch, array_ptr, schema_ptr); return R_NilValue; END_CPP11 diff --git a/r/src/arrow_types.h b/r/src/arrow_types.h index 23cd298b220..e6c2362017a 100644 --- a/r/src/arrow_types.h +++ b/r/src/arrow_types.h @@ -23,8 +23,16 @@ #if defined(ARROW_R_WITH_ARROW) +#include +#include +#include + #include // for RBuffer definition below -#include +#include +#include + +// forward declaration-only headers +#include #include #include #include @@ -32,18 +40,10 @@ #include #include #include -#include -#include #include -#include #include #include -#include -#include -#include -#include - namespace ds = ::arrow::dataset; namespace fs = ::arrow::fs; diff --git a/r/src/py-to-r.cpp b/r/src/py-to-r.cpp index d2ff13bc2f2..56777919c5b 100644 --- a/r/src/py-to-r.cpp +++ b/r/src/py-to-r.cpp @@ -19,6 +19,8 @@ #if defined(ARROW_R_WITH_ARROW) +#include + // [[arrow::export]] std::shared_ptr ImportArray(arrow::r::Pointer array, arrow::r::Pointer schema) { @@ -65,8 +67,8 @@ void ExportArray(const std::shared_ptr& array, // [[arrow::export]] void ExportRecordBatch(const std::shared_ptr& batch, - arrow::r::Pointer array_ptr, - arrow::r::Pointer schema_ptr) { + arrow::r::Pointer array_ptr, + arrow::r::Pointer schema_ptr) { StopIfNotOk(arrow::ExportRecordBatch(*batch, array_ptr, schema_ptr)); } From c444282cde8ccf5e905dc3a28c85f4d969548962 Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Wed, 11 Nov 2020 13:18:31 -0500 Subject: [PATCH 41/43] adjust for msvc --- cpp/src/parquet/test_encryption_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/parquet/test_encryption_util.h b/cpp/src/parquet/test_encryption_util.h index e17ab0b0717..4a33534f8fb 100644 --- a/cpp/src/parquet/test_encryption_util.h +++ b/cpp/src/parquet/test_encryption_util.h @@ -46,7 +46,7 @@ namespace parquet { namespace test { -using arrow::internal::TemporaryDir; +using ::arrow::internal::TemporaryDir; using parquet::ConvertedType; using parquet::Repetition; From 9ef91fb0b0ab5d748ecc6644f1b53335ded10ccb Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Wed, 11 Nov 2020 13:20:50 -0500 Subject: [PATCH 42/43] parquet: more explicit ::arrow --- cpp/src/parquet/statistics.cc | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cpp/src/parquet/statistics.cc b/cpp/src/parquet/statistics.cc index bb970367f20..dd019c360cc 100644 --- a/cpp/src/parquet/statistics.cc +++ b/cpp/src/parquet/statistics.cc @@ -56,14 +56,14 @@ struct CompareHelper { // MSVC17 fix, isnan is not overloaded for IntegralType as per C++11 // standard requirements. template - static arrow::enable_if_t::value, T> Coalesce(T val, - T fallback) { + static ::arrow::enable_if_t::value, T> Coalesce(T val, + T fallback) { return std::isnan(val) ? fallback : val; } template - static arrow::enable_if_t::value, T> Coalesce(T val, - T fallback) { + static ::arrow::enable_if_t::value, T> Coalesce( + T val, T fallback) { return val; } @@ -83,7 +83,7 @@ struct UnsignedCompareHelperBase { static T Coalesce(T val, T fallback) { return val; } static inline bool Compare(int type_length, T a, T b) { - return arrow::util::SafeCopy(a) < arrow::util::SafeCopy(b); + return ::arrow::util::SafeCopy(a) < ::arrow::util::SafeCopy(b); } static T Min(int type_length, T a, T b) { return Compare(type_length, a, b) ? a : b; } @@ -117,8 +117,8 @@ struct CompareHelper { if (a.value[2] != b.value[2]) { // Only the MSB bit is by Signed comparison. For little-endian, this is the // last bit of Int96 type. - return arrow::util::SafeCopy(a.value[2]) < - arrow::util::SafeCopy(b.value[2]); + return ::arrow::util::SafeCopy(a.value[2]) < + ::arrow::util::SafeCopy(b.value[2]); } else if (a.value[1] != b.value[1]) { return (a.value[1] < b.value[1]); } @@ -223,11 +223,11 @@ CleanStatistic(std::pair min_max) { // Ignore if one of the value is nan. if (std::isnan(min) || std::isnan(max)) { - return arrow::util::nullopt; + return ::arrow::util::nullopt; } if (min == std::numeric_limits::max() && max == std::numeric_limits::lowest()) { - return arrow::util::nullopt; + return ::arrow::util::nullopt; } T zero{}; @@ -245,7 +245,7 @@ CleanStatistic(std::pair min_max) { optional> CleanStatistic(std::pair min_max) { if (min_max.first.ptr == nullptr || min_max.second.ptr == nullptr) { - return arrow::util::nullopt; + return ::arrow::util::nullopt; } return min_max; } @@ -253,7 +253,7 @@ optional> CleanStatistic(std::pair min_max) { optional> CleanStatistic( std::pair min_max) { if (min_max.first.ptr == nullptr || min_max.second.ptr == nullptr) { - return arrow::util::nullopt; + return ::arrow::util::nullopt; } return min_max; } From 2c3dd4279cd5fd9d403bc8aa1f4e0ec3323d081c Mon Sep 17 00:00:00 2001 From: Benjamin Kietzman Date: Wed, 11 Nov 2020 13:56:40 -0500 Subject: [PATCH 43/43] parquet: more explicit ::arrow --- cpp/src/parquet/encoding.cc | 269 ++++++++++++++++--------------- cpp/src/parquet/encoding_test.cc | 25 +-- cpp/src/parquet/types.h | 1 + 3 files changed, 149 insertions(+), 146 deletions(-) diff --git a/cpp/src/parquet/encoding.cc b/cpp/src/parquet/encoding.cc index 109f48ea63c..d0b58471c64 100644 --- a/cpp/src/parquet/encoding.cc +++ b/cpp/src/parquet/encoding.cc @@ -99,14 +99,14 @@ class PlainEncoder : public EncoderImpl, virtual public TypedEncoder { void Put(const T* buffer, int num_values) override; - void Put(const arrow::Array& values) override; + void Put(const ::arrow::Array& values) override; void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - PARQUET_ASSIGN_OR_THROW( - auto buffer, arrow::AllocateBuffer(num_values * sizeof(T), this->memory_pool())); + PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), + this->memory_pool())); T* data = reinterpret_cast(buffer->mutable_data()); - int num_valid_values = arrow::util::internal::SpacedCompress( + int num_valid_values = ::arrow::util::internal::SpacedCompress( src, num_values, valid_bits, valid_bits_offset, data); Put(data, num_valid_values); } @@ -127,7 +127,7 @@ class PlainEncoder : public EncoderImpl, virtual public TypedEncoder { } protected: - arrow::BufferBuilder sink_; + ::arrow::BufferBuilder sink_; }; template @@ -145,7 +145,7 @@ inline void PlainEncoder::Put(const ByteArray* src, int num_value } template -void DirectPutImpl(const arrow::Array& values, arrow::BufferBuilder* sink) { +void DirectPutImpl(const ::arrow::Array& values, ::arrow::BufferBuilder* sink) { if (values.type_id() != ArrayType::TypeClass::type_id) { std::string type_name = ArrayType::TypeClass::type_name(); throw ParquetException("direct put to " + type_name + " from " + @@ -172,46 +172,46 @@ void DirectPutImpl(const arrow::Array& values, arrow::BufferBuilder* sink) { } template <> -void PlainEncoder::Put(const arrow::Array& values) { - DirectPutImpl(values, &sink_); +void PlainEncoder::Put(const ::arrow::Array& values) { + DirectPutImpl<::arrow::Int32Array>(values, &sink_); } template <> -void PlainEncoder::Put(const arrow::Array& values) { - DirectPutImpl(values, &sink_); +void PlainEncoder::Put(const ::arrow::Array& values) { + DirectPutImpl<::arrow::Int64Array>(values, &sink_); } template <> -void PlainEncoder::Put(const arrow::Array& values) { +void PlainEncoder::Put(const ::arrow::Array& values) { ParquetException::NYI("direct put to Int96"); } template <> -void PlainEncoder::Put(const arrow::Array& values) { - DirectPutImpl(values, &sink_); +void PlainEncoder::Put(const ::arrow::Array& values) { + DirectPutImpl<::arrow::FloatArray>(values, &sink_); } template <> -void PlainEncoder::Put(const arrow::Array& values) { - DirectPutImpl(values, &sink_); +void PlainEncoder::Put(const ::arrow::Array& values) { + DirectPutImpl<::arrow::DoubleArray>(values, &sink_); } template -void PlainEncoder::Put(const arrow::Array& values) { +void PlainEncoder::Put(const ::arrow::Array& values) { ParquetException::NYI("direct put of " + values.type()->ToString()); } -void AssertBinary(const arrow::Array& values) { - if (values.type_id() != arrow::Type::BINARY && - values.type_id() != arrow::Type::STRING) { +void AssertBinary(const ::arrow::Array& values) { + if (values.type_id() != ::arrow::Type::BINARY && + values.type_id() != ::arrow::Type::STRING) { throw ParquetException("Only BinaryArray and subclasses supported"); } } template <> -inline void PlainEncoder::Put(const arrow::Array& values) { +inline void PlainEncoder::Put(const ::arrow::Array& values) { AssertBinary(values); - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); const int64_t total_bytes = data.value_offset(data.length()) - data.value_offset(0); PARQUET_THROW_NOT_OK(sink_.Reserve(total_bytes + data.length() * sizeof(uint32_t))); @@ -231,12 +231,12 @@ inline void PlainEncoder::Put(const arrow::Array& values) { } } -void AssertFixedSizeBinary(const arrow::Array& values, int type_length) { - if (values.type_id() != arrow::Type::FIXED_SIZE_BINARY && - values.type_id() != arrow::Type::DECIMAL) { +void AssertFixedSizeBinary(const ::arrow::Array& values, int type_length) { + if (values.type_id() != ::arrow::Type::FIXED_SIZE_BINARY && + values.type_id() != ::arrow::Type::DECIMAL) { throw ParquetException("Only FixedSizeBinaryArray and subclasses supported"); } - if (checked_cast(*values.type()).byte_width() != + if (checked_cast(*values.type()).byte_width() != type_length) { throw ParquetException("Size mismatch: " + values.type()->ToString() + " should have been " + std::to_string(type_length) + " wide"); @@ -244,9 +244,9 @@ void AssertFixedSizeBinary(const arrow::Array& values, int type_length) { } template <> -inline void PlainEncoder::Put(const arrow::Array& values) { +inline void PlainEncoder::Put(const ::arrow::Array& values) { AssertFixedSizeBinary(values, descr_->type_length()); - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); if (data.null_count() == 0) { // no nulls, just dump the data @@ -296,32 +296,32 @@ class PlainEncoder : public EncoderImpl, virtual public BooleanEnco void PutSpaced(const bool* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - PARQUET_ASSIGN_OR_THROW( - auto buffer, arrow::AllocateBuffer(num_values * sizeof(T), this->memory_pool())); + PARQUET_ASSIGN_OR_THROW(auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), + this->memory_pool())); T* data = reinterpret_cast(buffer->mutable_data()); - int num_valid_values = arrow::util::internal::SpacedCompress( + int num_valid_values = ::arrow::util::internal::SpacedCompress( src, num_values, valid_bits, valid_bits_offset, data); Put(data, num_valid_values); } - void Put(const arrow::Array& values) override { - if (values.type_id() != arrow::Type::BOOL) { + void Put(const ::arrow::Array& values) override { + if (values.type_id() != ::arrow::Type::BOOL) { throw ParquetException("direct put to boolean from " + values.type()->ToString() + " not supported"); } - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); if (data.null_count() == 0) { PARQUET_THROW_NOT_OK(sink_.Reserve(BitUtil::BytesForBits(data.length()))); // no nulls, just dump the data - arrow::internal::CopyBitmap(data.data()->GetValues(1), data.offset(), - data.length(), sink_.mutable_data(), sink_.length()); + ::arrow::internal::CopyBitmap(data.data()->GetValues(1), data.offset(), + data.length(), sink_.mutable_data(), sink_.length()); sink_.UnsafeAdvance(data.length()); } else { auto n_valid = BitUtil::BytesForBits(data.length() - data.null_count()); PARQUET_THROW_NOT_OK(sink_.Reserve(n_valid)); - arrow::internal::FirstTimeBitmapWriter writer(sink_.mutable_data(), sink_.length(), - n_valid); + ::arrow::internal::FirstTimeBitmapWriter writer(sink_.mutable_data(), + sink_.length(), n_valid); for (int64_t i = 0; i < data.length(); i++) { if (data.IsValid(i)) { @@ -340,8 +340,8 @@ class PlainEncoder : public EncoderImpl, virtual public BooleanEnco private: int bits_available_; std::shared_ptr bits_buffer_; - arrow::BufferBuilder sink_; - arrow::BitUtil::BitWriter bit_writer_; + ::arrow::BufferBuilder sink_; + ::arrow::BitUtil::BitWriter bit_writer_; template void PutImpl(const SequenceType& src, int num_values); @@ -419,17 +419,17 @@ void PlainEncoder::Put(const std::vector& src, int num_values template struct DictEncoderTraits { using c_type = typename DType::c_type; - using MemoTableType = arrow::internal::ScalarMemoTable; + using MemoTableType = ::arrow::internal::ScalarMemoTable; }; template <> struct DictEncoderTraits { - using MemoTableType = arrow::internal::BinaryMemoTable; + using MemoTableType = ::arrow::internal::BinaryMemoTable<::arrow::BinaryBuilder>; }; template <> struct DictEncoderTraits { - using MemoTableType = arrow::internal::BinaryMemoTable; + using MemoTableType = ::arrow::internal::BinaryMemoTable<::arrow::BinaryBuilder>; }; // Initially 1024 elements @@ -465,7 +465,7 @@ class DictEncoderImpl : public EncoderImpl, virtual public DictEncoder { ++buffer; --buffer_len; - arrow::util::RleEncoder encoder(buffer, buffer_len, bit_width()); + ::arrow::util::RleEncoder encoder(buffer, buffer_len, bit_width()); for (int32_t index : buffered_indices_) { if (!encoder.Put(index)) return -1; @@ -486,9 +486,9 @@ class DictEncoderImpl : public EncoderImpl, virtual public DictEncoder { // an extra "RleEncoder::MinBufferSize" bytes. These extra bytes won't be used // but not reserving them would cause the encoder to fail. return 1 + - arrow::util::RleEncoder::MaxBufferSize( + ::arrow::util::RleEncoder::MaxBufferSize( bit_width(), static_cast(buffered_indices_.size())) + - arrow::util::RleEncoder::MinBufferSize(bit_width()); + ::arrow::util::RleEncoder::MinBufferSize(bit_width()); } /// The minimum bit width required to encode the currently buffered indices. @@ -513,8 +513,8 @@ class DictEncoderImpl : public EncoderImpl, virtual public DictEncoder { void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override { - arrow::internal::BitmapReader valid_bits_reader(valid_bits, valid_bits_offset, - num_values); + ::arrow::internal::BitmapReader valid_bits_reader(valid_bits, valid_bits_offset, + num_values); for (int32_t i = 0; i < num_values; i++) { if (valid_bits_reader.IsSet()) { Put(src[i]); @@ -525,18 +525,18 @@ class DictEncoderImpl : public EncoderImpl, virtual public DictEncoder { using TypedEncoder::Put; - void Put(const arrow::Array& values) override; - void PutDictionary(const arrow::Array& values) override; + void Put(const ::arrow::Array& values) override; + void PutDictionary(const ::arrow::Array& values) override; template - void PutIndicesTyped(const arrow::Array& data) { + void PutIndicesTyped(const ::arrow::Array& data) { auto values = data.data()->GetValues(1); size_t buffer_position = buffered_indices_.size(); buffered_indices_.resize(buffer_position + static_cast(data.length() - data.null_count())); if (data.null_count() > 0) { - arrow::internal::BitmapReader valid_bits_reader(data.null_bitmap_data(), - data.offset(), data.length()); + ::arrow::internal::BitmapReader valid_bits_reader(data.null_bitmap_data(), + data.offset(), data.length()); for (int64_t i = 0; i < data.length(); ++i) { if (valid_bits_reader.IsSet()) { buffered_indices_[buffer_position++] = static_cast(values[i]); @@ -550,20 +550,20 @@ class DictEncoderImpl : public EncoderImpl, virtual public DictEncoder { } } - void PutIndices(const arrow::Array& data) override { + void PutIndices(const ::arrow::Array& data) override { switch (data.type()->id()) { - case arrow::Type::UINT8: - case arrow::Type::INT8: - return PutIndicesTyped(data); - case arrow::Type::UINT16: - case arrow::Type::INT16: - return PutIndicesTyped(data); - case arrow::Type::UINT32: - case arrow::Type::INT32: - return PutIndicesTyped(data); - case arrow::Type::UINT64: - case arrow::Type::INT64: - return PutIndicesTyped(data); + case ::arrow::Type::UINT8: + case ::arrow::Type::INT8: + return PutIndicesTyped<::arrow::UInt8Type>(data); + case ::arrow::Type::UINT16: + case ::arrow::Type::INT16: + return PutIndicesTyped<::arrow::UInt16Type>(data); + case ::arrow::Type::UINT32: + case ::arrow::Type::INT32: + return PutIndicesTyped<::arrow::UInt32Type>(data); + case ::arrow::Type::UINT64: + case ::arrow::Type::INT64: + return PutIndicesTyped<::arrow::UInt64Type>(data); default: throw ParquetException("Passed non-integer array to PutIndices"); } @@ -608,7 +608,7 @@ void DictEncoderImpl::WriteDict(uint8_t* buffer) { // ByteArray and FLBA already have the dictionary encoded in their data heaps template <> void DictEncoderImpl::WriteDict(uint8_t* buffer) { - memo_table_.VisitValues(0, [&buffer](const arrow::util::string_view& v) { + memo_table_.VisitValues(0, [&buffer](const ::arrow::util::string_view& v) { uint32_t len = static_cast(v.length()); memcpy(buffer, &len, sizeof(len)); buffer += sizeof(len); @@ -619,7 +619,7 @@ void DictEncoderImpl::WriteDict(uint8_t* buffer) { template <> void DictEncoderImpl::WriteDict(uint8_t* buffer) { - memo_table_.VisitValues(0, [&](const arrow::util::string_view& v) { + memo_table_.VisitValues(0, [&](const ::arrow::util::string_view& v) { DCHECK_EQ(v.length(), static_cast(type_length_)); memcpy(buffer, v.data(), type_length_); buffer += type_length_; @@ -683,18 +683,18 @@ inline void DictEncoderImpl::Put(const FixedLenByteArray& v) { } template <> -void DictEncoderImpl::Put(const arrow::Array& values) { +void DictEncoderImpl::Put(const ::arrow::Array& values) { ParquetException::NYI("Direct put to Int96"); } template <> -void DictEncoderImpl::PutDictionary(const arrow::Array& values) { +void DictEncoderImpl::PutDictionary(const ::arrow::Array& values) { ParquetException::NYI("Direct put to Int96"); } template -void DictEncoderImpl::Put(const arrow::Array& values) { - using ArrayType = typename arrow::CTypeTraits::ArrayType; +void DictEncoderImpl::Put(const ::arrow::Array& values) { + using ArrayType = typename ::arrow::CTypeTraits::ArrayType; const auto& data = checked_cast(values); if (data.null_count() == 0) { // no nulls, just dump the data @@ -711,9 +711,9 @@ void DictEncoderImpl::Put(const arrow::Array& values) { } template <> -void DictEncoderImpl::Put(const arrow::Array& values) { +void DictEncoderImpl::Put(const ::arrow::Array& values) { AssertFixedSizeBinary(values, type_length_); - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); if (data.null_count() == 0) { // no nulls, just dump the data for (int64_t i = 0; i < data.length(); i++) { @@ -730,9 +730,9 @@ void DictEncoderImpl::Put(const arrow::Array& values) { } template <> -void DictEncoderImpl::Put(const arrow::Array& values) { +void DictEncoderImpl::Put(const ::arrow::Array& values) { AssertBinary(values); - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); if (data.null_count() == 0) { // no nulls, just dump the data for (int64_t i = 0; i < data.length(); i++) { @@ -750,7 +750,7 @@ void DictEncoderImpl::Put(const arrow::Array& values) { } template -void AssertCanPutDictionary(DictEncoderImpl* encoder, const arrow::Array& dict) { +void AssertCanPutDictionary(DictEncoderImpl* encoder, const ::arrow::Array& dict) { if (dict.null_count() > 0) { throw ParquetException("Inserted dictionary cannot cannot contain nulls"); } @@ -761,10 +761,10 @@ void AssertCanPutDictionary(DictEncoderImpl* encoder, const arrow::Array& } template -void DictEncoderImpl::PutDictionary(const arrow::Array& values) { +void DictEncoderImpl::PutDictionary(const ::arrow::Array& values) { AssertCanPutDictionary(this, values); - using ArrayType = typename arrow::CTypeTraits::ArrayType; + using ArrayType = typename ::arrow::CTypeTraits::ArrayType; const auto& data = checked_cast(values); dict_encoded_size_ += static_cast(sizeof(typename DType::c_type) * data.length()); @@ -775,11 +775,11 @@ void DictEncoderImpl::PutDictionary(const arrow::Array& values) { } template <> -void DictEncoderImpl::PutDictionary(const arrow::Array& values) { +void DictEncoderImpl::PutDictionary(const ::arrow::Array& values) { AssertFixedSizeBinary(values, type_length_); AssertCanPutDictionary(this, values); - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); dict_encoded_size_ += static_cast(type_length_ * data.length()); for (int64_t i = 0; i < data.length(); i++) { @@ -790,11 +790,11 @@ void DictEncoderImpl::PutDictionary(const arrow::Array& values) { } template <> -void DictEncoderImpl::PutDictionary(const arrow::Array& values) { +void DictEncoderImpl::PutDictionary(const ::arrow::Array& values) { AssertBinary(values); AssertCanPutDictionary(this, values); - const auto& data = checked_cast(values); + const auto& data = checked_cast(values); for (int64_t i = 0; i < data.length(); i++) { auto v = data.GetView(i); @@ -822,15 +822,15 @@ class ByteStreamSplitEncoder : public EncoderImpl, virtual public TypedEncoder FlushValues() override; void Put(const T* buffer, int num_values) override; - void Put(const arrow::Array& values) override; + void Put(const ::arrow::Array& values) override; void PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) override; protected: - arrow::TypedBufferBuilder values_; + ::arrow::TypedBufferBuilder values_; private: - void PutArrowArray(const arrow::Array& values); + void PutArrowArray(const ::arrow::Array& values); }; template @@ -850,8 +850,8 @@ std::shared_ptr ByteStreamSplitEncoder::FlushValues() { uint8_t* output_buffer_raw = output_buffer->mutable_data(); const size_t num_values = values_.length(); const uint8_t* raw_values = reinterpret_cast(values_.data()); - arrow::util::internal::ByteStreamSplitEncode(raw_values, num_values, - output_buffer_raw); + ::arrow::util::internal::ByteStreamSplitEncode(raw_values, num_values, + output_buffer_raw); values_.Reset(); return std::move(output_buffer); } @@ -868,14 +868,14 @@ void ByteStreamSplitEncoder::Put(const ::arrow::Array& values) { template <> void ByteStreamSplitEncoder::PutArrowArray(const ::arrow::Array& values) { - DirectPutImpl(values, - reinterpret_cast(&values_)); + DirectPutImpl<::arrow::FloatArray>(values, + reinterpret_cast<::arrow::BufferBuilder*>(&values_)); } template <> void ByteStreamSplitEncoder::PutArrowArray(const ::arrow::Array& values) { - DirectPutImpl(values, - reinterpret_cast(&values_)); + DirectPutImpl<::arrow::DoubleArray>( + values, reinterpret_cast<::arrow::BufferBuilder*>(&values_)); } template @@ -883,9 +883,9 @@ void ByteStreamSplitEncoder::PutSpaced(const T* src, int num_values, const uint8_t* valid_bits, int64_t valid_bits_offset) { PARQUET_ASSIGN_OR_THROW( - auto buffer, arrow::AllocateBuffer(num_values * sizeof(T), this->memory_pool())); + auto buffer, ::arrow::AllocateBuffer(num_values * sizeof(T), this->memory_pool())); T* data = reinterpret_cast(buffer->mutable_data()); - int num_valid_values = arrow::util::internal::SpacedCompress( + int num_valid_values = ::arrow::util::internal::SpacedCompress( src, num_values, valid_bits, valid_bits_offset, data); Put(data, num_valid_values); } @@ -970,7 +970,7 @@ int PlainDecoder::DecodeArrow( VisitNullBitmapInline( valid_bits, valid_bits_offset, num_values, null_count, [&]() { - builder->UnsafeAppend(arrow::util::SafeLoadAs(data_)); + builder->UnsafeAppend(::arrow::util::SafeLoadAs(data_)); data_ += sizeof(value_type); }, [&]() { builder->UnsafeAppendNull(); }); @@ -997,7 +997,8 @@ int PlainDecoder::DecodeArrow( VisitNullBitmapInline( valid_bits, valid_bits_offset, num_values, null_count, [&]() { - PARQUET_THROW_NOT_OK(builder->Append(arrow::util::SafeLoadAs(data_))); + PARQUET_THROW_NOT_OK( + builder->Append(::arrow::util::SafeLoadAs(data_))); data_ += sizeof(value_type); }, [&]() { PARQUET_THROW_NOT_OK(builder->AppendNull()); }); @@ -1040,7 +1041,7 @@ static inline int64_t ReadByteArray(const uint8_t* data, int64_t data_size, if (ARROW_PREDICT_FALSE(data_size < 4)) { ParquetException::EofException(); } - const int32_t len = arrow::util::SafeLoadAs(data); + const int32_t len = ::arrow::util::SafeLoadAs(data); if (len < 0) { throw ParquetException("Invalid BYTE_ARRAY value"); } @@ -1115,7 +1116,7 @@ class PlainBooleanDecoder : public DecoderImpl, typename EncodingTraits::DictAccumulator* out) override; private: - std::unique_ptr bit_reader_; + std::unique_ptr<::arrow::BitUtil::BitReader> bit_reader_; }; PlainBooleanDecoder::PlainBooleanDecoder(const ColumnDescriptor* descr) @@ -1158,7 +1159,7 @@ inline int PlainBooleanDecoder::DecodeArrow( int PlainBooleanDecoder::Decode(uint8_t* buffer, int max_values) { max_values = std::min(max_values, num_values_); bool val; - arrow::internal::BitmapWriter bit_writer(buffer, 0, max_values); + ::arrow::internal::BitmapWriter bit_writer(buffer, 0, max_values); for (int i = 0; i < max_values; ++i) { if (!bit_reader_->GetValue(1, &val)) { ParquetException::EofException(); @@ -1215,7 +1216,7 @@ struct ArrowBinaryHelper { Status AppendNull() { return builder->AppendNull(); } typename EncodingTraits::Accumulator* out; - arrow::BinaryBuilder* builder; + ::arrow::BinaryBuilder* builder; int64_t chunk_space_remaining; }; @@ -1293,7 +1294,7 @@ class PlainByteArrayDecoder : public PlainDecoder, int DecodeArrow(int num_values, int null_count, const uint8_t* valid_bits, int64_t valid_bits_offset, - arrow::BinaryDictionary32Builder* builder) override { + ::arrow::BinaryDictionary32Builder* builder) override { int result = 0; PARQUET_THROW_NOT_OK(DecodeArrow(num_values, null_count, valid_bits, valid_bits_offset, builder, &result)); @@ -1331,7 +1332,7 @@ class PlainByteArrayDecoder : public PlainDecoder, if (ARROW_PREDICT_FALSE(len_ < 4)) { ParquetException::EofException(); } - auto value_len = arrow::util::SafeLoadAs(data_); + auto value_len = ::arrow::util::SafeLoadAs(data_); if (ARROW_PREDICT_FALSE(value_len < 0 || value_len > INT32_MAX - 4)) { return Status::Invalid("Invalid or corrupted value_len '", value_len, "'"); } @@ -1377,7 +1378,7 @@ class PlainByteArrayDecoder : public PlainDecoder, if (ARROW_PREDICT_FALSE(len_ < 4)) { ParquetException::EofException(); } - auto value_len = arrow::util::SafeLoadAs(data_); + auto value_len = ::arrow::util::SafeLoadAs(data_); if (ARROW_PREDICT_FALSE(value_len < 0 || value_len > INT32_MAX - 4)) { return Status::Invalid("Invalid or corrupted value_len '", value_len, "'"); } @@ -1417,7 +1418,7 @@ class DictDecoderImpl : public DecoderImpl, virtual public DictDecoder { // dictionary is not guaranteed to persist in memory after this call so the // dictionary decoder needs to copy the data out if necessary. explicit DictDecoderImpl(const ColumnDescriptor* descr, - MemoryPool* pool = arrow::default_memory_pool()) + MemoryPool* pool = ::arrow::default_memory_pool()) : DecoderImpl(descr, Encoding::RLE_DICTIONARY), dictionary_(AllocateBuffer(pool, 0)), dictionary_length_(0), @@ -1432,14 +1433,14 @@ class DictDecoderImpl : public DecoderImpl, virtual public DictDecoder { num_values_ = num_values; if (len == 0) { // Initialize dummy decoder to avoid crashes later on - idx_decoder_ = arrow::util::RleDecoder(data, len, /*bit_width=*/1); + idx_decoder_ = ::arrow::util::RleDecoder(data, len, /*bit_width=*/1); return; } uint8_t bit_width = *data; if (ARROW_PREDICT_FALSE(bit_width >= 64)) { throw ParquetException("Invalid or corrupted bit_width"); } - idx_decoder_ = arrow::util::RleDecoder(++data, --len, bit_width); + idx_decoder_ = ::arrow::util::RleDecoder(++data, --len, bit_width); } int Decode(T* buffer, int num_values) override { @@ -1475,11 +1476,11 @@ class DictDecoderImpl : public DecoderImpl, virtual public DictDecoder { int64_t valid_bits_offset, typename EncodingTraits::DictAccumulator* out) override; - void InsertDictionary(arrow::ArrayBuilder* builder) override; + void InsertDictionary(::arrow::ArrayBuilder* builder) override; int DecodeIndicesSpaced(int num_values, int null_count, const uint8_t* valid_bits, int64_t valid_bits_offset, - arrow::ArrayBuilder* builder) override { + ::arrow::ArrayBuilder* builder) override { if (num_values > 0) { // TODO(wesm): Refactor to batch reads for improved memory use. It is not // trivial because the null_count is relative to the entire bitmap @@ -1497,20 +1498,20 @@ class DictDecoderImpl : public DecoderImpl, virtual public DictDecoder { /// XXX(wesm): Cannot append "valid bits" directly to the builder std::vector valid_bytes(num_values); - arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); + ::arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); for (int64_t i = 0; i < num_values; ++i) { valid_bytes[i] = static_cast(bit_reader.IsSet()); bit_reader.Next(); } - auto binary_builder = checked_cast(builder); + auto binary_builder = checked_cast<::arrow::BinaryDictionary32Builder*>(builder); PARQUET_THROW_NOT_OK( binary_builder->AppendIndices(indices_buffer, num_values, valid_bytes.data())); num_values_ -= num_values - null_count; return num_values - null_count; } - int DecodeIndices(int num_values, arrow::ArrayBuilder* builder) override { + int DecodeIndices(int num_values, ::arrow::ArrayBuilder* builder) override { num_values = std::min(num_values, num_values_); if (num_values > 0) { // TODO(wesm): Refactor to batch reads for improved memory use. This is @@ -1524,7 +1525,7 @@ class DictDecoderImpl : public DecoderImpl, virtual public DictDecoder { if (num_values != idx_decoder_.GetBatch(indices_buffer, num_values)) { ParquetException::EofException(); } - auto binary_builder = checked_cast(builder); + auto binary_builder = checked_cast<::arrow::BinaryDictionary32Builder*>(builder); PARQUET_THROW_NOT_OK(binary_builder->AppendIndices(indices_buffer, num_values)); num_values_ -= num_values; return num_values; @@ -1566,7 +1567,7 @@ class DictDecoderImpl : public DecoderImpl, virtual public DictDecoder { // BinaryDictionary32Builder std::shared_ptr indices_scratch_space_; - arrow::util::RleDecoder idx_decoder_; + ::arrow::util::RleDecoder idx_decoder_; }; template @@ -1718,9 +1719,9 @@ int DictDecoderImpl::DecodeArrow( int num_values, int null_count, const uint8_t* valid_bits, int64_t valid_bits_offset, typename EncodingTraits::DictAccumulator* builder) { auto value_type = - checked_cast(*builder->type()).value_type(); + checked_cast(*builder->type()).value_type(); auto byte_width = - checked_cast(*value_type).byte_width(); + checked_cast(*value_type).byte_width(); if (byte_width != descr_->type_length()) { throw ParquetException("Byte width mismatch: builder was " + std::to_string(byte_width) + " but decoder was " + @@ -1771,17 +1772,17 @@ int DictDecoderImpl::DecodeArrow( } template -void DictDecoderImpl::InsertDictionary(arrow::ArrayBuilder* builder) { +void DictDecoderImpl::InsertDictionary(::arrow::ArrayBuilder* builder) { ParquetException::NYI("InsertDictionary only implemented for BYTE_ARRAY types"); } template <> -void DictDecoderImpl::InsertDictionary(arrow::ArrayBuilder* builder) { - auto binary_builder = checked_cast(builder); +void DictDecoderImpl::InsertDictionary(::arrow::ArrayBuilder* builder) { + auto binary_builder = checked_cast<::arrow::BinaryDictionary32Builder*>(builder); // Make a BinaryArray referencing the internal dictionary data - auto arr = std::make_shared(dictionary_length_, byte_array_offsets_, - byte_array_data_); + auto arr = std::make_shared<::arrow::BinaryArray>( + dictionary_length_, byte_array_offsets_, byte_array_data_); PARQUET_THROW_NOT_OK(binary_builder->InsertMemoValues(*arr)); } @@ -1793,7 +1794,7 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl, int DecodeArrow(int num_values, int null_count, const uint8_t* valid_bits, int64_t valid_bits_offset, - arrow::BinaryDictionary32Builder* builder) override { + ::arrow::BinaryDictionary32Builder* builder) override { int result = 0; if (null_count == 0) { PARQUET_THROW_NOT_OK(DecodeArrowNonNull(num_values, builder, &result)); @@ -1827,7 +1828,7 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl, ArrowBinaryHelper helper(out); - arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); + ::arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); auto dict_values = reinterpret_cast(dictionary_->data()); int values_decoded = 0; @@ -1918,7 +1919,7 @@ class DictByteArrayDecoderImpl : public DictDecoderImpl, int32_t indices[kBufferSize]; RETURN_NOT_OK(builder->Reserve(num_values)); - arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); + ::arrow::internal::BitmapReader bit_reader(valid_bits, valid_bits_offset, num_values); auto dict_values = reinterpret_cast(dictionary_->data()); @@ -2002,7 +2003,7 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecodernum_values_ = num_values; - decoder_ = arrow::BitUtil::BitReader(data, len); + decoder_ = ::arrow::BitUtil::BitReader(data, len); values_current_block_ = 0; values_current_mini_block_ = 0; } @@ -2103,7 +2104,7 @@ class DeltaBitPackDecoder : public DecoderImpl, virtual public TypedDecoder { public: explicit DeltaLengthByteArrayDecoder(const ColumnDescriptor* descr, - MemoryPool* pool = arrow::default_memory_pool()) + MemoryPool* pool = ::arrow::default_memory_pool()) : DecoderImpl(descr, Encoding::DELTA_LENGTH_BYTE_ARRAY), len_decoder_(nullptr, pool), pool_(pool) {} @@ -2132,7 +2133,7 @@ class DeltaLengthByteArrayDecoder : public DecoderImpl, void SetData(int num_values, const uint8_t* data, int len) override { num_values_ = num_values; if (len == 0) return; - int total_lengths_len = arrow::util::SafeLoadAs(data); + int total_lengths_len = ::arrow::util::SafeLoadAs(data); data += 4; this->len_decoder_.SetData(num_values, data, total_lengths_len); data_ = data + total_lengths_len; @@ -2178,7 +2179,7 @@ class DeltaByteArrayDecoder : public DecoderImpl, virtual public TypedDecoder { public: explicit DeltaByteArrayDecoder(const ColumnDescriptor* descr, - MemoryPool* pool = arrow::default_memory_pool()) + MemoryPool* pool = ::arrow::default_memory_pool()) : DecoderImpl(descr, Encoding::DELTA_BYTE_ARRAY), prefix_len_decoder_(nullptr, pool), suffix_decoder_(nullptr, pool), @@ -2187,7 +2188,7 @@ class DeltaByteArrayDecoder : public DecoderImpl, virtual void SetData(int num_values, const uint8_t* data, int len) { num_values_ = num_values; if (len == 0) return; - int prefix_len_length = arrow::util::SafeLoadAs(data); + int prefix_len_length = ::arrow::util::SafeLoadAs(data); data += 4; len -= 4; prefix_len_decoder_.SetData(num_values, data, prefix_len_length); @@ -2280,8 +2281,8 @@ int ByteStreamSplitDecoder::Decode(T* buffer, int max_values) { const int num_decoded_previously = num_values_in_buffer_ - num_values_; const uint8_t* data = data_ + num_decoded_previously; - arrow::util::internal::ByteStreamSplitDecode(data, values_to_decode, - num_values_in_buffer_, buffer); + ::arrow::util::internal::ByteStreamSplitDecode(data, values_to_decode, + num_values_in_buffer_, buffer); num_values_ -= values_to_decode; len_ -= sizeof(T) * values_to_decode; return values_to_decode; @@ -2307,8 +2308,8 @@ int ByteStreamSplitDecoder::DecodeArrow( // Use fast decoding into intermediate buffer. This will also decode // some null values, but it's fast enough that we don't care. T* decode_out = EnsureDecodeBuffer(values_decoded); - arrow::util::internal::ByteStreamSplitDecode(data, values_decoded, - num_values_in_buffer_, decode_out); + ::arrow::util::internal::ByteStreamSplitDecode(data, values_decoded, + num_values_in_buffer_, decode_out); // XXX If null_count is 0, we could even append in bulk or decode directly into // builder @@ -2329,7 +2330,7 @@ int ByteStreamSplitDecoder::DecodeArrow( const size_t byte_index = b * num_values_in_buffer_ + offset; gathered_byte_data[b] = data[byte_index]; } - builder->UnsafeAppend(arrow::util::SafeLoadAs(&gathered_byte_data[0])); + builder->UnsafeAppend(::arrow::util::SafeLoadAs(&gathered_byte_data[0])); ++offset; }, [&]() { builder->UnsafeAppendNull(); }); diff --git a/cpp/src/parquet/encoding_test.cc b/cpp/src/parquet/encoding_test.cc index 7d107328f38..7e440fa9a03 100644 --- a/cpp/src/parquet/encoding_test.cc +++ b/cpp/src/parquet/encoding_test.cc @@ -341,7 +341,7 @@ class TestDictionaryEncoding : public TestEncodingBase { static constexpr int TYPE = Type::type_num; void CheckRoundtrip() { - std::vector valid_bits(arrow::BitUtil::BytesForBits(num_values_) + 1, 255); + std::vector valid_bits(::arrow::BitUtil::BytesForBits(num_values_) + 1, 255); auto base_encoder = MakeEncoder(Type::type_num, Encoding::PLAIN, true, descr_.get()); auto encoder = @@ -788,31 +788,31 @@ class EncodingAdHocTyped : public ::testing::Test { }; template -std::shared_ptr EncodingAdHocTyped::arrow_type() { +std::shared_ptr<::arrow::DataType> EncodingAdHocTyped::arrow_type() { return ::arrow::TypeTraits::type_singleton(); } template <> -std::shared_ptr EncodingAdHocTyped::arrow_type() { +std::shared_ptr<::arrow::DataType> EncodingAdHocTyped::arrow_type() { return ::arrow::fixed_size_binary(sizeof(uint64_t)); } template -std::shared_ptr EncodingAdHocTyped::GetValues(int seed) { +std::shared_ptr<::arrow::Array> EncodingAdHocTyped::GetValues(int seed) { ::arrow::random::RandomArrayGenerator rag(seed); return rag.Numeric(size_, 0, 10, null_probability_); } template <> -std::shared_ptr EncodingAdHocTyped::GetValues(int seed) { +std::shared_ptr<::arrow::Array> EncodingAdHocTyped::GetValues(int seed) { ::arrow::random::RandomArrayGenerator rag(seed); return rag.Boolean(size_, 0.1, null_probability_); } template <> -std::shared_ptr EncodingAdHocTyped::GetValues(int seed) { +std::shared_ptr<::arrow::Array> EncodingAdHocTyped::GetValues(int seed) { ::arrow::random::RandomArrayGenerator rag(seed); - std::shared_ptr values; + std::shared_ptr<::arrow::Array> values; ARROW_EXPECT_OK( rag.UInt64(size_, 0, std::numeric_limits::max(), null_probability_) ->View(arrow_type()) @@ -881,7 +881,7 @@ TEST(DictEncodingAdHoc, PutDictionaryPutIndices) { auto indices = ::arrow::ArrayFromJSON(index_ty, "[0, 1, 2]"); auto indices_nulls = ::arrow::ArrayFromJSON(index_ty, "[null, 0, 1, null, 2]"); - auto expected = ::arrow::ArrayFromJSON(arrow::binary(), + auto expected = ::arrow::ArrayFromJSON(::arrow::binary(), "[\"foo\", \"bar\", \"baz\", null, " "\"foo\", \"bar\", null, \"baz\"]"); @@ -995,8 +995,9 @@ TEST_F(DictEncoding, CheckDecodeIndicesSpaced) { ASSERT_ARRAYS_EQUAL(*actual, *expected_dict_); // Check that null indices are zero-initialized - const auto& dict_actual = checked_cast(*actual); - const auto& indices = checked_cast(*dict_actual.indices()); + const auto& dict_actual = checked_cast(*actual); + const auto& indices = + checked_cast(*dict_actual.indices()); auto raw_values = indices.raw_values(); for (int64_t i = 0; i < indices.length(); ++i) { @@ -1054,11 +1055,11 @@ class TestByteStreamSplitEncoding : public TestEncodingBase { } { - std::vector valid_bits(arrow::BitUtil::BytesForBits(num_values_), 0); + std::vector valid_bits(::arrow::BitUtil::BytesForBits(num_values_), 0); std::vector expected_filtered_output; const int every_nth = 5; expected_filtered_output.reserve((num_values_ + every_nth - 1) / every_nth); - arrow::internal::BitmapWriter writer{valid_bits.data(), 0, num_values_}; + ::arrow::internal::BitmapWriter writer{valid_bits.data(), 0, num_values_}; // Set every fifth bit. for (int i = 0; i < num_values_; ++i) { if (i % every_nth == 0) { diff --git a/cpp/src/parquet/types.h b/cpp/src/parquet/types.h index 51fb13b2332..21cef0f4da8 100644 --- a/cpp/src/parquet/types.h +++ b/cpp/src/parquet/types.h @@ -27,6 +27,7 @@ #include "arrow/util/string_view.h" #include "parquet/platform.h" +#include "parquet/type_fwd.h" namespace arrow { namespace util {