diff --git a/apis/r/R/RcppExports.R b/apis/r/R/RcppExports.R index a4c0f9aaf0..f5906c2c9b 100644 --- a/apis/r/R/RcppExports.R +++ b/apis/r/R/RcppExports.R @@ -198,6 +198,10 @@ ndim <- function(uri, ctxxp) { .Call(`_tiledbsoma_ndim`, uri, ctxxp) } +c_dimnames <- function(uri, ctxxp) { + .Call(`_tiledbsoma_c_dimnames`, uri, ctxxp) +} + resize <- function(uri, new_shape, ctxxp) { invisible(.Call(`_tiledbsoma_resize`, uri, new_shape, ctxxp)) } diff --git a/apis/r/R/TileDBArray.R b/apis/r/R/TileDBArray.R index 8ed0bfd571..fb7719544e 100644 --- a/apis/r/R/TileDBArray.R +++ b/apis/r/R/TileDBArray.R @@ -260,12 +260,7 @@ TileDBArray <- R6::R6Class( #' @description Retrieve dimension names (lifecycle: maturing) #' @return A character vector with the array's dimension names dimnames = function() { - vapply( - self$dimensions(), - FUN = tiledb::name, - FUN.VALUE = vector("character", 1L), - USE.NAMES = FALSE - ) + c_dimnames(self$uri, private$.soma_context) }, #' @description Retrieve attribute names (lifecycle: maturing) diff --git a/apis/r/src/RcppExports.cpp b/apis/r/src/RcppExports.cpp index dceab26f3e..332271939d 100644 --- a/apis/r/src/RcppExports.cpp +++ b/apis/r/src/RcppExports.cpp @@ -428,6 +428,18 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// c_dimnames +Rcpp::CharacterVector c_dimnames(const std::string& uri, Rcpp::XPtr ctxxp); +RcppExport SEXP _tiledbsoma_c_dimnames(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 >::type ctxxp(ctxxpSEXP); + rcpp_result_gen = Rcpp::wrap(c_dimnames(uri, ctxxp)); + return rcpp_result_gen; +END_RCPP +} // resize void resize(const std::string& uri, Rcpp::NumericVector new_shape, Rcpp::XPtr ctxxp); RcppExport SEXP _tiledbsoma_resize(SEXP uriSEXP, SEXP new_shapeSEXP, SEXP ctxxpSEXP) { @@ -655,6 +667,7 @@ static const R_CallMethodDef CallEntries[] = { {"_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_c_dimnames", (DL_FUNC) &_tiledbsoma_c_dimnames, 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}, diff --git a/apis/r/src/rinterface.cpp b/apis/r/src/rinterface.cpp index ced9ba4951..3cb7acf25e 100644 --- a/apis/r/src/rinterface.cpp +++ b/apis/r/src/rinterface.cpp @@ -331,6 +331,21 @@ Rcpp::NumericVector ndim( return Rcpp::NumericVector::create(lib_retval); } +// [[Rcpp::export]] +Rcpp::CharacterVector c_dimnames( + const std::string& uri, Rcpp::XPtr ctxxp) { + auto sr = tdbs::SOMAArray::open(OpenMode::read, uri, ctxxp->ctxptr); + auto lib_retval = sr->dimension_names(); + sr->close(); + + size_t n = lib_retval.size(); + Rcpp::CharacterVector retval(n); + for (size_t i = 0; i < n; i++) { + retval[i] = lib_retval[i]; + } + return retval; +} + // [[Rcpp::export]] void resize( const std::string& uri,