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/16 20:34:04 UTC
[arrow] branch master updated: ARROW-3795: [R] Support for
retrieving NAs from INT64 arrays
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 29657d8 ARROW-3795: [R] Support for retrieving NAs from INT64 arrays
29657d8 is described below
commit 29657d851146fb25645cb9a5ffbee6854b0f6800
Author: Romain Francois <ro...@purrple.cat>
AuthorDate: Fri Nov 16 15:33:57 2018 -0500
ARROW-3795: [R] Support for retrieving NAs from INT64 arrays
``` r
library(arrow)
#>
#> Attaching package: 'arrow'
#> The following object is masked from 'package:utils':
#>
#> timestamp
#> The following objects are masked from 'package:base':
#>
#> array, table
x <- bit64::as.integer64(c(NA))
a <- array(x)
a$as_vector()
#> integer64
#> [1] <NA>
```
<sup>Created on 2018-11-16 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1.9000)</sup>
Author: Romain Francois <ro...@purrple.cat>
Closes #2982 from romainfrancois/ARROW-3795/fix-int64 and squashes the following commits:
a8cf8ca60 <Romain Francois> Array<int64>$as_vector() supports all NA arrays correctly.
---
r/DESCRIPTION | 2 +-
r/src/array.cpp | 4 ++--
r/tests/testthat/test-Array.R | 6 ++++++
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/r/DESCRIPTION b/r/DESCRIPTION
index 0ef5f55..9b72979 100644
--- a/r/DESCRIPTION
+++ b/r/DESCRIPTION
@@ -32,7 +32,7 @@ Remotes:
RcppCore/Rcpp,
r-lib/withr
Roxygen: list(markdown = TRUE)
-RoxygenNote: 6.1.0.9000
+RoxygenNote: 6.1.1
Suggests:
testthat,
lubridate,
diff --git a/r/src/array.cpp b/r/src/array.cpp
index 3af4934..beaa1e2 100644
--- a/r/src/array.cpp
+++ b/r/src/array.cpp
@@ -34,7 +34,7 @@ inline bool isna<REALSXP>(double x) {
}
// the integer64 sentinel
-static const int64_t NA_INT64 = std::numeric_limits<int64_t>::min();
+constexpr int64_t NA_INT64 = std::numeric_limits<int64_t>::min();
template <int RTYPE, typename Type>
std::shared_ptr<Array> SimpleArray(SEXP x) {
@@ -801,7 +801,7 @@ struct Converter_Int64 {
void Ingest(const std::shared_ptr<arrow::Array>& array, R_xlen_t start, R_xlen_t n) {
auto null_count = array->null_count();
if (null_count == n) {
- std::fill_n(data.begin() + start, n, NA_INT64);
+ std::fill_n(reinterpret_cast<int64_t*>(data.begin()) + start, n, NA_INT64);
} else {
auto p_values = GetValuesSafely<int64_t>(array->data(), 1, array->offset());
STOP_IF_NULL(p_values);
diff --git a/r/tests/testthat/test-Array.R b/r/tests/testthat/test-Array.R
index a3e5134..ca97c98 100644
--- a/r/tests/testthat/test-Array.R
+++ b/r/tests/testthat/test-Array.R
@@ -259,6 +259,12 @@ test_that("array supports integer64", {
expect_true(a$IsNull(3L))
})
+test_that("array$as_vector() correctly handles all NA inte64 (ARROW-3795)", {
+ x <- bit64::as.integer64(NA)
+ a <- array(x)
+ expect_true(is.na(a$as_vector()))
+})
+
test_that("array supports difftime", {
time <- hms::hms(56, 34, 12)
a <- array(time, time)