You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/11/28 15:37:33 UTC
[arrow] branch master updated: ARROW-3823: [R] + buffer.complex
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 13c63bd ARROW-3823: [R] + buffer.complex
13c63bd is described below
commit 13c63bdec9675f08b1631e0514dcf2a890d7e36b
Author: Romain Francois <ro...@purrple.cat>
AuthorDate: Wed Nov 28 09:37:27 2018 -0600
ARROW-3823: [R] + buffer.complex
Should be pretty straightforward to review
Author: Romain Francois <ro...@purrple.cat>
Closes #3045 from romainfrancois/ARROW-3823/buffer-complex and squashes the following commits:
f2bd70102 <Romain Francois> buffer.complex
---
r/R/buffer.R | 6 ++++++
r/src/buffer.cpp | 2 ++
r/tests/testthat/test-buffer.R | 7 +++++++
3 files changed, 15 insertions(+)
diff --git a/r/R/buffer.R b/r/R/buffer.R
index 0101a7e..9684a97 100644
--- a/r/R/buffer.R
+++ b/r/R/buffer.R
@@ -59,3 +59,9 @@ buffer.numeric <- function(x) {
buffer.integer <- function(x) {
shared_ptr(`arrow::Buffer`, r___RBuffer__initialize(x))
}
+
+#' @export
+buffer.complex <- function(x) {
+ shared_ptr(`arrow::Buffer`, r___RBuffer__initialize(x))
+}
+
diff --git a/r/src/buffer.cpp b/r/src/buffer.cpp
index 8f4ca8e..b4f003b 100644
--- a/r/src/buffer.cpp
+++ b/r/src/buffer.cpp
@@ -46,6 +46,8 @@ std::shared_ptr<arrow::Buffer> r___RBuffer__initialize(SEXP x) {
return std::make_shared<arrow::r::RBuffer<REALSXP>>(x);
case INTSXP:
return std::make_shared<arrow::r::RBuffer<INTSXP>>(x);
+ case CPLXSXP:
+ return std::make_shared<arrow::r::RBuffer<CPLXSXP>>(x);
default:
Rcpp::stop(
tfm::format("R object of type %s not supported", Rf_type2char(TYPEOF(x))));
diff --git a/r/tests/testthat/test-buffer.R b/r/tests/testthat/test-buffer.R
index f003862..aa712b0 100644
--- a/r/tests/testthat/test-buffer.R
+++ b/r/tests/testthat/test-buffer.R
@@ -37,3 +37,10 @@ test_that("arrow::Buffer can be created from numeric vector", {
expect_is(buf, "arrow::Buffer")
expect_equal(buf$size(), 17 * 8)
})
+
+test_that("arrow::Buffer can be created from complex vector", {
+ vec <- complex(3)
+ buf <- buffer(vec)
+ expect_is(buf, "arrow::Buffer")
+ expect_equal(buf$size(), 3 * 16)
+})