diff --git a/apis/r/DESCRIPTION b/apis/r/DESCRIPTION index 34ec4f0198..58a89016da 100644 --- a/apis/r/DESCRIPTION +++ b/apis/r/DESCRIPTION @@ -48,7 +48,8 @@ Imports: tibble LinkingTo: Rcpp, - RcppSpdlog + RcppSpdlog, + RcppInt64 Additional_repositories: https://ghrr.github.io/drat Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 diff --git a/apis/r/src/rinterface.cpp b/apis/r/src/rinterface.cpp index 082ebdb92f..812a52859b 100644 --- a/apis/r/src/rinterface.cpp +++ b/apis/r/src/rinterface.cpp @@ -1,5 +1,6 @@ #include // for R interface to C++ #include // for C interface to Arrow +#include // for fromInteger64 // we currently get deprecation warnings by default which are noisy #ifndef TILEDB_NO_API_DEPRECATION_WARNINGS @@ -233,5 +234,5 @@ bool check_arrow_array_tag(Rcpp::XPtr xp) { Rcpp::NumericVector shape(const std::string& uri, Rcpp::Nullable config = R_NilValue) { auto sr = tdbs::SOMAArray::open(OpenMode::read, uri, "unnamed", config_vector_to_map(Rcpp::wrap(config))); - return makeInteger64(sr->shape()); + return Rcpp::toInteger64(sr->shape()); } diff --git a/apis/r/src/rutilities.cpp b/apis/r/src/rutilities.cpp index 9fa81545d9..ddd6ee69a3 100644 --- a/apis/r/src/rutilities.cpp +++ b/apis/r/src/rutilities.cpp @@ -6,6 +6,7 @@ #include // for R interface to C++ #include // for C interface to Arrow +#include // for fromInteger64 // We get these via nanoarrow and must cannot include carrow.h again #define ARROW_SCHEMA_AND_ARRAY_DEFINED 1 @@ -26,7 +27,7 @@ void apply_dim_points(tdbs::SOMAArray *sr, bool suitable = false; if (tp == TILEDB_UINT64) { Rcpp::NumericVector payload = lst[nm]; - std::vector iv = getInt64Vector(payload); + std::vector iv = Rcpp::fromInteger64(payload, false); std::vector uv(iv.size()); const std::pair pr = dm->domain(); for (size_t i=0; i iv = getInt64Vector(payload); + std::vector iv = Rcpp::fromInteger64(payload, false); const std::pair pr = dm->domain(); for (size_t i=0; i= pr.first && iv[i] <= pr.second) { @@ -103,8 +104,8 @@ void apply_dim_ranges(tdbs::SOMAArray* sr, std::vector> vp(mm.nrow()); const std::pair pr = dm->domain(); for (int i=0; i(makeScalarInteger64(lo[i])); - uint64_t h = static_cast(makeScalarInteger64(hi[i])); + uint64_t l = static_cast(Rcpp::fromInteger64(lo[i])); + uint64_t h = static_cast(Rcpp::fromInteger64(hi[i])); vp[i] = std::make_pair(std::max(l,pr.first), std::min(h, pr.second)); spdl::info("[apply_dim_ranges] Applying dim point {} on {} with {} - {}", i, nm, l, h) ; suitable = l < pr.second && h > pr.first; // lower must be less than max, higher more than min @@ -112,8 +113,8 @@ void apply_dim_ranges(tdbs::SOMAArray* sr, if (suitable) sr->set_dim_ranges(nm, vp); } else if (tp == TILEDB_INT64) { Rcpp::NumericMatrix mm = lst[nm]; - std::vector lo = getInt64Vector(mm.column(0)); - std::vector hi = getInt64Vector(mm.column(1)); + std::vector lo = Rcpp::fromInteger64(mm.column(0), false); + std::vector hi = Rcpp::fromInteger64(mm.column(1), false); std::vector> vp(mm.nrow()); const std::pair pr = dm->domain(); for (int i=0; i& vec) { - size_t n = vec.size(); - - Rcpp::NumericVector num(n); - std::memcpy(&(num[0]), vec.data(), n * sizeof(double)); - - num.attr("class") = "integer64"; - return (num); -} - -// Convert to a scalar int64_t -// -inline int64_t makeScalarInteger64(const double val) { - int64_t newval; - memcpy(&newval, &val, sizeof(double)); - return newval; -} - -// Create a int64_t vector from a NumericVector -// -inline std::vector getInt64Vector(Rcpp::NumericVector vec) { - size_t n = vec.size(); - std::vector num(n); - std::memcpy(&(num[0]), &(vec[0]), n * sizeof(double)); - return num; -} - +#define TILEDB_VERSION TileDB_Version(TILEDB_VERSION_MAJOR, \ + TILEDB_VERSION_MINOR, \ + TILEDB_VERSION_PATCH) // Applies (named list of) vectors of points to the named dimensions void apply_dim_points(