Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r] Push ndim down to C++ #3066

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apis/r/R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ has_current_domain <- function(uri, ctxxp) {
.Call(`_tiledbsoma_has_current_domain`, uri, ctxxp)
}

ndim <- function(uri, ctxxp) {
.Call(`_tiledbsoma_ndim`, uri, ctxxp)
}

resize <- function(uri, new_shape, ctxxp) {
invisible(.Call(`_tiledbsoma_resize`, uri, new_shape, ctxxp))
}
Expand Down
3 changes: 1 addition & 2 deletions apis/r/R/TileDBArray.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ TileDBArray <- R6::R6Class(
#' @description Retrieve number of dimensions (lifecycle: maturing)
#' @return A scalar with the number of dimensions
ndim = function() {
dims <- tiledb::dimensions(self$tiledb_schema())
length(dims)
ndim(self$uri, private$.soma_context)
},

#' @description Retrieve the array attributes (lifecycle: maturing)
Expand Down
13 changes: 13 additions & 0 deletions apis/r/src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,18 @@ BEGIN_RCPP
return rcpp_result_gen;
END_RCPP
}
// ndim
Rcpp::NumericVector ndim(const std::string& uri, Rcpp::XPtr<somactx_wrap_t> ctxxp);
RcppExport SEXP _tiledbsoma_ndim(SEXP uriSEXP, SEXP ctxxpSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const std::string& >::type uri(uriSEXP);
Rcpp::traits::input_parameter< Rcpp::XPtr<somactx_wrap_t> >::type ctxxp(ctxxpSEXP);
rcpp_result_gen = Rcpp::wrap(ndim(uri, ctxxp));
return rcpp_result_gen;
END_RCPP
}
// resize
void resize(const std::string& uri, Rcpp::NumericVector new_shape, Rcpp::XPtr<somactx_wrap_t> ctxxp);
RcppExport SEXP _tiledbsoma_resize(SEXP uriSEXP, SEXP new_shapeSEXP, SEXP ctxxpSEXP) {
Expand Down Expand Up @@ -642,6 +654,7 @@ static const R_CallMethodDef CallEntries[] = {
{"_tiledbsoma_maybe_soma_joinid_shape", (DL_FUNC) &_tiledbsoma_maybe_soma_joinid_shape, 2},
{"_tiledbsoma_maybe_soma_joinid_maxshape", (DL_FUNC) &_tiledbsoma_maybe_soma_joinid_maxshape, 2},
{"_tiledbsoma_has_current_domain", (DL_FUNC) &_tiledbsoma_has_current_domain, 2},
{"_tiledbsoma_ndim", (DL_FUNC) &_tiledbsoma_ndim, 2},
{"_tiledbsoma_resize", (DL_FUNC) &_tiledbsoma_resize, 3},
{"_tiledbsoma_tiledbsoma_upgrade_shape", (DL_FUNC) &_tiledbsoma_tiledbsoma_upgrade_shape, 3},
{"_tiledbsoma_sr_setup", (DL_FUNC) &_tiledbsoma_sr_setup, 10},
Expand Down
12 changes: 11 additions & 1 deletion apis/r/src/rinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ SEXP soma_array_reader(
//' @param level A character value with logging level understood by
//\sQuote{spdlog} ' such as \dQuote{trace}, \dQuote{debug}, \dQuote{info}, or
//\dQuote{warn}. ' @return Nothing is returned as the function is invoked for
//the side-effect. ' @export
// the side-effect. ' @export
// [[Rcpp::export]]
void set_log_level(const std::string& level) {
spdl::setup("R", level);
Expand Down Expand Up @@ -319,6 +319,16 @@ Rcpp::LogicalVector has_current_domain(
return retval;
}

// [[Rcpp::export]]
Rcpp::NumericVector ndim(
const std::string& uri, Rcpp::XPtr<somactx_wrap_t> ctxxp) {
auto sr = tdbs::SOMAArray::open(OpenMode::read, uri, ctxxp->ctxptr);
auto lib_retval = sr->ndim();
sr->close();

return Rcpp::NumericVector::create(lib_retval);
}

// [[Rcpp::export]]
void resize(
const std::string& uri,
Expand Down
Loading