From 78c84cfdca2f248c86802d75e59918d3fc76a480 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Fri, 24 Oct 2025 16:40:24 -0400 Subject: [PATCH 01/18] (WIP) Add internal RCpp functions for Profile --- R/RcppExports.R | 28 +++++++++++++++ src/RcppExports.cpp | 87 +++++++++++++++++++++++++++++++++++++++++++++ src/libtiledb.cpp | 80 +++++++++++++++++++++++++++++++++++++++++ src/libtiledb.h | 7 ++++ 4 files changed, 202 insertions(+) diff --git a/R/RcppExports.R b/R/RcppExports.R index dc816c62a4..2bf528ad95 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1233,6 +1233,34 @@ libtiledb_current_domain_is_empty <- function(cd) { .Call(`_tiledb_libtiledb_current_domain_is_empty`, cd) } +libtiledb_profile_new <- function(name = NULL, dir = NULL) { + .Call(`_tiledb_libtiledb_profile_new`, name, dir) +} + +libtiledb_profile_load <- function(name = NULL, dir = NULL) { + .Call(`_tiledb_libtiledb_profile_load`, name, dir) +} + +libtiledb_profile_name <- function(profile) { + .Call(`_tiledb_libtiledb_profile_name`, profile) +} + +libtiledb_profile_dir <- function(profile) { + .Call(`_tiledb_libtiledb_profile_dir`, profile) +} + +libtiledb_profile_set_param <- function(profile, param, value) { + invisible(.Call(`_tiledb_libtiledb_profile_set_param`, profile, param, value)) +} + +libtiledb_profile_get_param <- function(profile, param) { + .Call(`_tiledb_libtiledb_profile_get_param`, profile, param) +} + +libtiledb_profile_save <- function(profile) { + invisible(.Call(`_tiledb_libtiledb_profile_save`, profile)) +} + vecbuf_to_shmem <- function(dir, name, buf, sz, numvar) { invisible(.Call(`_tiledb_vecbuf_to_shmem`, dir, name, buf, sz, numvar)) } diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 9a838b9d0c..885dff0b16 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -3678,6 +3678,86 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// libtiledb_profile_new +XPtr libtiledb_profile_new(Nullable name, Nullable dir); +RcppExport SEXP _tiledb_libtiledb_profile_new(SEXP nameSEXP, SEXP dirSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< Nullable >::type name(nameSEXP); + Rcpp::traits::input_parameter< Nullable >::type dir(dirSEXP); + rcpp_result_gen = Rcpp::wrap(libtiledb_profile_new(name, dir)); + return rcpp_result_gen; +END_RCPP +} +// libtiledb_profile_load +XPtr libtiledb_profile_load(Nullable name, Nullable dir); +RcppExport SEXP _tiledb_libtiledb_profile_load(SEXP nameSEXP, SEXP dirSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< Nullable >::type name(nameSEXP); + Rcpp::traits::input_parameter< Nullable >::type dir(dirSEXP); + rcpp_result_gen = Rcpp::wrap(libtiledb_profile_load(name, dir)); + return rcpp_result_gen; +END_RCPP +} +// libtiledb_profile_name +std::string libtiledb_profile_name(XPtr profile); +RcppExport SEXP _tiledb_libtiledb_profile_name(SEXP profileSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< XPtr >::type profile(profileSEXP); + rcpp_result_gen = Rcpp::wrap(libtiledb_profile_name(profile)); + return rcpp_result_gen; +END_RCPP +} +// libtiledb_profile_dir +std::string libtiledb_profile_dir(XPtr profile); +RcppExport SEXP _tiledb_libtiledb_profile_dir(SEXP profileSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< XPtr >::type profile(profileSEXP); + rcpp_result_gen = Rcpp::wrap(libtiledb_profile_dir(profile)); + return rcpp_result_gen; +END_RCPP +} +// libtiledb_profile_set_param +void libtiledb_profile_set_param(XPtr profile, const std::string& param, const std::string& value); +RcppExport SEXP _tiledb_libtiledb_profile_set_param(SEXP profileSEXP, SEXP paramSEXP, SEXP valueSEXP) { +BEGIN_RCPP + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< XPtr >::type profile(profileSEXP); + Rcpp::traits::input_parameter< const std::string& >::type param(paramSEXP); + Rcpp::traits::input_parameter< const std::string& >::type value(valueSEXP); + libtiledb_profile_set_param(profile, param, value); + return R_NilValue; +END_RCPP +} +// libtiledb_profile_get_param +Nullable libtiledb_profile_get_param(XPtr profile, const std::string& param); +RcppExport SEXP _tiledb_libtiledb_profile_get_param(SEXP profileSEXP, SEXP paramSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< XPtr >::type profile(profileSEXP); + Rcpp::traits::input_parameter< const std::string& >::type param(paramSEXP); + rcpp_result_gen = Rcpp::wrap(libtiledb_profile_get_param(profile, param)); + return rcpp_result_gen; +END_RCPP +} +// libtiledb_profile_save +void libtiledb_profile_save(XPtr profile); +RcppExport SEXP _tiledb_libtiledb_profile_save(SEXP profileSEXP) { +BEGIN_RCPP + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< XPtr >::type profile(profileSEXP); + libtiledb_profile_save(profile); + return R_NilValue; +END_RCPP +} // vecbuf_to_shmem void vecbuf_to_shmem(std::string dir, std::string name, XPtr buf, int sz, int numvar); RcppExport SEXP _tiledb_vecbuf_to_shmem(SEXP dirSEXP, SEXP nameSEXP, SEXP bufSEXP, SEXP szSEXP, SEXP numvarSEXP) { @@ -4059,6 +4139,13 @@ static const R_CallMethodDef CallEntries[] = { {"_tiledb_libtiledb_current_domain_set_ndrectangle", (DL_FUNC) &_tiledb_libtiledb_current_domain_set_ndrectangle, 2}, {"_tiledb_libtiledb_current_domain_get_ndrectangle", (DL_FUNC) &_tiledb_libtiledb_current_domain_get_ndrectangle, 1}, {"_tiledb_libtiledb_current_domain_is_empty", (DL_FUNC) &_tiledb_libtiledb_current_domain_is_empty, 1}, + {"_tiledb_libtiledb_profile_new", (DL_FUNC) &_tiledb_libtiledb_profile_new, 2}, + {"_tiledb_libtiledb_profile_load", (DL_FUNC) &_tiledb_libtiledb_profile_load, 2}, + {"_tiledb_libtiledb_profile_name", (DL_FUNC) &_tiledb_libtiledb_profile_name, 1}, + {"_tiledb_libtiledb_profile_dir", (DL_FUNC) &_tiledb_libtiledb_profile_dir, 1}, + {"_tiledb_libtiledb_profile_set_param", (DL_FUNC) &_tiledb_libtiledb_profile_set_param, 3}, + {"_tiledb_libtiledb_profile_get_param", (DL_FUNC) &_tiledb_libtiledb_profile_get_param, 2}, + {"_tiledb_libtiledb_profile_save", (DL_FUNC) &_tiledb_libtiledb_profile_save, 1}, {"_tiledb_vecbuf_to_shmem", (DL_FUNC) &_tiledb_vecbuf_to_shmem, 5}, {"_tiledb_vlcbuf_to_shmem", (DL_FUNC) &_tiledb_vlcbuf_to_shmem, 4}, {"_tiledb_querybuf_from_shmem", (DL_FUNC) &_tiledb_querybuf_from_shmem, 2}, diff --git a/src/libtiledb.cpp b/src/libtiledb.cpp index 5f9407fc4b..a4fa19557c 100644 --- a/src/libtiledb.cpp +++ b/src/libtiledb.cpp @@ -26,6 +26,7 @@ #include #include #include +#include using namespace Rcpp; @@ -5925,3 +5926,82 @@ bool libtiledb_current_domain_is_empty(XPtr cd) { return false; #endif } + + +/** + * Profile (2.29.0 or later) + */ + + +// [[Rcpp::export]] +XPtr libtiledb_profile_new(Nullable name = R_NilValue, Nullable dir = R_NilValue) { + std::optional name_ = std::nullopt; + std::optional dir_ = std::nullopt; + if (name.isNotNull()) { + name_ = as(name); + } + if (name.isNotNull()) { + dir_ = as(dir); + } + return make_xptr(new tiledb::Profile(name_, dir_)); +} + +// [[Rcpp::export]] +XPtr libtiledb_profile_load(Nullable name = R_NilValue, Nullable dir = R_NilValue) { + std::optional name_ = std::nullopt; + std::optional dir_ = std::nullopt; + if (name.isNotNull()) { + name_ = as(name); + } + if (name.isNotNull()) { + dir_ = as(dir); + } + return make_xptr(new tiledb::Profile(tiledb::Profile::load(name_, dir_))); +} + +// [[Rcpp:export]] +void libtiledb_profile_remove(Nullable name = R_NilValue, Nullable dir = R_NilValue) { + std::optional name_ = std::nullopt; + std::optional dir_ = std::nullopt; + if (name.isNotNull()) { + name_ = as(name); + } + if (name.isNotNull()) { + dir_ = as(dir); + } + return tiledb::Profile::remove(name_, dir_); +} + +// [[Rcpp::export]] +std::string libtiledb_profile_name(XPtr profile) { + return profile->name(); +} + +// [[Rcpp::export]] +std::string libtiledb_profile_dir(XPtr profile) { + return profile->dir(); +} + +// [[Rcpp::export]] +void libtiledb_profile_set_param(XPtr profile, const std::string& param, const std::string& value) { + return profile->set_param(param, value); +} + +// [[Rcpp::export]] +Nullable libtiledb_profile_get_param(XPtr profile, const std::string& param) { + auto maybe_value = profile->get_param(param); + if (maybe_value.has_value()) { + return wrap(maybe_value.value()); + } + return R_NilValue; +} + +// [[Rcpp::export]] +void libtiledb_profile_save(XPtr profile) { + return profile->save(); +} + +// [[Rcpp:export]] +std::string libtiledb_profile_dump(XPtr profile) { + return profile->dump(); +} diff --git a/src/libtiledb.h b/src/libtiledb.h index 153aa4334e..2d204273af 100644 --- a/src/libtiledb.h +++ b/src/libtiledb.h @@ -120,12 +120,15 @@ const tiledb_xptr_object tiledb_xptr_object_subarray{200}; const tiledb_xptr_object tiledb_xptr_column_buffer{210}; const tiledb_xptr_object tiledb_xptr_array_buffers{220}; const tiledb_xptr_object tiledb_xptr_map_to_col_buf_t{230}; +const tiledb_xptr_object tiledb_xptr_profile{240}; // the definitions above are internal to tiledb-r but we need a new value here // if we want tag the external pointer const tiledb_xptr_object tiledb_arrow_array_t{300}; const tiledb_xptr_object tiledb_arrow_schema_t{310}; + + // templated checkers for external pointer tags template const int32_t XPtrTagType = tiledb_xptr_default; // clang++ wants a value @@ -188,6 +191,8 @@ template <> inline const int32_t XPtrTagType = tiledb_arrow_array_t; template <> inline const int32_t XPtrTagType = tiledb_arrow_schema_t; +template <> inline const int32_t XPtrTagType = tiledb_xptr_profile; + constexpr const char *xptrObjToString(tiledb_xptr_object xp) { switch (xp) { case tiledb_xptr_default: @@ -238,6 +243,8 @@ constexpr const char *xptrObjToString(tiledb_xptr_object xp) { return "ArrayBuffers"; case tiledb_xptr_map_to_col_buf_t: return "map_to_col_buf_t"; + case tiledb_xptr_profile: + return "Profile"; case tiledb_arrow_array_t: return "ArrowArray"; case tiledb_arrow_schema_t: From 0314ee3ec64804cd2401c24a2af5e73654d8ded1 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 11:45:35 -0400 Subject: [PATCH 02/18] Fix optional string conversion and export typo --- R/RcppExports.R | 4 ++++ src/RcppExports.cpp | 12 ++++++++++++ src/libtiledb.cpp | 43 +++++++++++++++++-------------------------- 3 files changed, 33 insertions(+), 26 deletions(-) diff --git a/R/RcppExports.R b/R/RcppExports.R index 2bf528ad95..7b2c32affa 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1261,6 +1261,10 @@ libtiledb_profile_save <- function(profile) { invisible(.Call(`_tiledb_libtiledb_profile_save`, profile)) } +libtiledb_profile_dump <- function(profile) { + .Call(`_tiledb_libtiledb_profile_dump`, profile) +} + vecbuf_to_shmem <- function(dir, name, buf, sz, numvar) { invisible(.Call(`_tiledb_vecbuf_to_shmem`, dir, name, buf, sz, numvar)) } diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 885dff0b16..7acaae79d9 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -3758,6 +3758,17 @@ BEGIN_RCPP return R_NilValue; END_RCPP } +// libtiledb_profile_dump +std::string libtiledb_profile_dump(XPtr profile); +RcppExport SEXP _tiledb_libtiledb_profile_dump(SEXP profileSEXP) { +BEGIN_RCPP + Rcpp::RObject rcpp_result_gen; + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< XPtr >::type profile(profileSEXP); + rcpp_result_gen = Rcpp::wrap(libtiledb_profile_dump(profile)); + return rcpp_result_gen; +END_RCPP +} // vecbuf_to_shmem void vecbuf_to_shmem(std::string dir, std::string name, XPtr buf, int sz, int numvar); RcppExport SEXP _tiledb_vecbuf_to_shmem(SEXP dirSEXP, SEXP nameSEXP, SEXP bufSEXP, SEXP szSEXP, SEXP numvarSEXP) { @@ -4146,6 +4157,7 @@ static const R_CallMethodDef CallEntries[] = { {"_tiledb_libtiledb_profile_set_param", (DL_FUNC) &_tiledb_libtiledb_profile_set_param, 3}, {"_tiledb_libtiledb_profile_get_param", (DL_FUNC) &_tiledb_libtiledb_profile_get_param, 2}, {"_tiledb_libtiledb_profile_save", (DL_FUNC) &_tiledb_libtiledb_profile_save, 1}, + {"_tiledb_libtiledb_profile_dump", (DL_FUNC) &_tiledb_libtiledb_profile_dump, 1}, {"_tiledb_vecbuf_to_shmem", (DL_FUNC) &_tiledb_vecbuf_to_shmem, 5}, {"_tiledb_vlcbuf_to_shmem", (DL_FUNC) &_tiledb_vlcbuf_to_shmem, 4}, {"_tiledb_querybuf_from_shmem", (DL_FUNC) &_tiledb_querybuf_from_shmem, 2}, diff --git a/src/libtiledb.cpp b/src/libtiledb.cpp index a4fa19557c..7fea16fd8b 100644 --- a/src/libtiledb.cpp +++ b/src/libtiledb.cpp @@ -5932,43 +5932,33 @@ bool libtiledb_current_domain_is_empty(XPtr cd) { * Profile (2.29.0 or later) */ +std::optional as_optional_string(Nullable param) { + if (param.isNull()) { + return std::nullopt; + } + CharacterVector tmp(param); + return std::string(tmp[0]); +} + // [[Rcpp::export]] XPtr libtiledb_profile_new(Nullable name = R_NilValue, Nullable dir = R_NilValue) { - std::optional name_ = std::nullopt; - std::optional dir_ = std::nullopt; - if (name.isNotNull()) { - name_ = as(name); - } - if (name.isNotNull()) { - dir_ = as(dir); - } - return make_xptr(new tiledb::Profile(name_, dir_)); + auto name_ = as_optional_string(name); + auto dir_ = as_optional_string(dir); + return make_xptr(new tiledb::Profile(name_, dir_)); } // [[Rcpp::export]] XPtr libtiledb_profile_load(Nullable name = R_NilValue, Nullable dir = R_NilValue) { - std::optional name_ = std::nullopt; - std::optional dir_ = std::nullopt; - if (name.isNotNull()) { - name_ = as(name); - } - if (name.isNotNull()) { - dir_ = as(dir); - } + auto name_ = as_optional_string(name); + auto dir_ = as_optional_string(dir); return make_xptr(new tiledb::Profile(tiledb::Profile::load(name_, dir_))); } // [[Rcpp:export]] void libtiledb_profile_remove(Nullable name = R_NilValue, Nullable dir = R_NilValue) { - std::optional name_ = std::nullopt; - std::optional dir_ = std::nullopt; - if (name.isNotNull()) { - name_ = as(name); - } - if (name.isNotNull()) { - dir_ = as(dir); - } + auto name_ = as_optional_string(name); + auto dir_ = as_optional_string(dir); return tiledb::Profile::remove(name_, dir_); } @@ -6001,7 +5991,8 @@ void libtiledb_profile_save(XPtr profile) { return profile->save(); } -// [[Rcpp:export]] +// [[Rcpp::export]] std::string libtiledb_profile_dump(XPtr profile) { return profile->dump(); } + From 06f80e19f659d7687253764adca35014a98da1ff Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 11:46:05 -0400 Subject: [PATCH 03/18] Add Profile R code --- R/Profile.R | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 R/Profile.R diff --git a/R/Profile.R b/R/Profile.R new file mode 100644 index 0000000000..c7ddc8b943 --- /dev/null +++ b/R/Profile.R @@ -0,0 +1,80 @@ +# +# Copyright (c) TileDB Inc. under the MIT License +# + +#' An S4 class for a TileDB Profile object +#' +#' @slot ptr An external pointer to the underlying implementation +#' @exportClass tiledb_profile +setClass("tiledb_profile", + slots = list(ptr = "externalptr") +) + +setMethod( + "raw_dump", + signature(object = "tiledb_profile"), + definition = function(object) libtiledb_profile_dump(object@ptr) +) + +#' Create a 'tiledb_profile' object +#' +#' @param name (optional) Name for the profile. +#' @param dir (optional) Directory to create the profile in. +#' @return 'tiledb_profile' object +#' @export tiledb_profile +tiledb_profile <- function(name = NULL, dir = NULL) { + stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) + stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) + ptr <- libtiledb_profile_new(name, dir) + profile <- new("tiledb_profile", ptr = ptr) + invisible(profile) +} + + +tiledb_profile_load <- function(name = NULL, dir = NULL) { + stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) + stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) + ptr <- libtiledb_profile_load(name, dir) + profile <- new("tiledb_profile", ptr = ptr) + invisible(profile) +} + +tiledb_profile_remove <- function(name = NULL, dir = NULL) { + stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) + stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) + libtiledb_profile_remove(name, dir) + return() +} + +tiledb_profile_name <- function(profile) { + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) + name <- libtiledb_profile_name(profile@ptr) + return(name) +} + +tiledb_profile_dir <- function(profile) { + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) + dir <- libtiledb_profile_dir(profile@ptr) + return(dir) +} + +tiledb_profile_set_param <- function(profile, param, value) { + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) + stopifnot(`The 'param' arugment must have character type` = is.character(param)) + stopifnot(`The 'value' arugment must have character type` = is.character(value)) + libtiledb_profile_set_param(profile@ptr, param, value) + return() +} + +tiledb_profile_get_param <- function(profile, param) { + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) + stopifnot(`The 'param' arugment must have character type` = is.character(param)) + value <- libtiledb_profile_get_param(profile@ptr, param) + return(value) +} + +tiledb_profile_save <- function(profile) { + stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) + libtiledb_profile_save(profile) + return() +} From 3e073e1a3676c6247bdaf4d51e3fb98caac345a6 Mon Sep 17 00:00:00 2001 From: Julia Dark <24235303+jp-dark@users.noreply.github.com> Date: Tue, 28 Oct 2025 12:56:39 -0400 Subject: [PATCH 04/18] Clean-up return types Co-authored-by: Paul Hoffman --- R/Profile.R | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/R/Profile.R b/R/Profile.R index c7ddc8b943..49e1120b96 100644 --- a/R/Profile.R +++ b/R/Profile.R @@ -27,7 +27,7 @@ tiledb_profile <- function(name = NULL, dir = NULL) { stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) ptr <- libtiledb_profile_new(name, dir) profile <- new("tiledb_profile", ptr = ptr) - invisible(profile) + return(profile) } @@ -36,14 +36,14 @@ tiledb_profile_load <- function(name = NULL, dir = NULL) { stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) ptr <- libtiledb_profile_load(name, dir) profile <- new("tiledb_profile", ptr = ptr) - invisible(profile) + return(profile) } tiledb_profile_remove <- function(name = NULL, dir = NULL) { stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) libtiledb_profile_remove(name, dir) - return() + return(invisible(NULL)) } tiledb_profile_name <- function(profile) { @@ -63,7 +63,7 @@ tiledb_profile_set_param <- function(profile, param, value) { stopifnot(`The 'param' arugment must have character type` = is.character(param)) stopifnot(`The 'value' arugment must have character type` = is.character(value)) libtiledb_profile_set_param(profile@ptr, param, value) - return() + return(invisible(NULL)) } tiledb_profile_get_param <- function(profile, param) { @@ -76,5 +76,5 @@ tiledb_profile_get_param <- function(profile, param) { tiledb_profile_save <- function(profile) { stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) libtiledb_profile_save(profile) - return() + return(invisible(NULL)) } From b3300d9efd7d41162f590861418085bebf088490 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 14:58:40 -0400 Subject: [PATCH 05/18] Update Profile Roxygen2 and fix typo --- NAMESPACE | 9 +++++++ R/Profile.R | 46 ++++++++++++++++++++++++++++----- man/tiledb_profile-class.Rd | 15 +++++++++++ man/tiledb_profile.Rd | 19 ++++++++++++++ man/tiledb_profile_dir.Rd | 14 ++++++++++ man/tiledb_profile_get_param.Rd | 17 ++++++++++++ man/tiledb_profile_load.Rd | 19 ++++++++++++++ man/tiledb_profile_name.Rd | 14 ++++++++++ man/tiledb_profile_remove.Rd | 16 ++++++++++++ man/tiledb_profile_save.Rd | 14 ++++++++++ man/tiledb_profile_set_param.Rd | 16 ++++++++++++ 11 files changed, 193 insertions(+), 6 deletions(-) create mode 100644 man/tiledb_profile-class.Rd create mode 100644 man/tiledb_profile.Rd create mode 100644 man/tiledb_profile_dir.Rd create mode 100644 man/tiledb_profile_get_param.Rd create mode 100644 man/tiledb_profile_load.Rd create mode 100644 man/tiledb_profile_name.Rd create mode 100644 man/tiledb_profile_remove.Rd create mode 100644 man/tiledb_profile_save.Rd create mode 100644 man/tiledb_profile_set_param.Rd diff --git a/NAMESPACE b/NAMESPACE index 29f1cb29ba..112555b22f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -240,6 +240,14 @@ export(tiledb_object_mv) export(tiledb_object_rm) export(tiledb_object_type) export(tiledb_object_walk) +export(tiledb_profile) +export(tiledb_profile_dir) +export(tiledb_profile_get_param) +export(tiledb_profile_load) +export(tiledb_profile_name) +export(tiledb_profile_remove) +export(tiledb_profile_save) +export(tiledb_profile_set_param) export(tiledb_put_metadata) export(tiledb_query) export(tiledb_query_add_range) @@ -342,6 +350,7 @@ exportClasses(tiledb_filter_list) exportClasses(tiledb_fragment_info) exportClasses(tiledb_group) exportClasses(tiledb_ndrectangle) +exportClasses(tiledb_profile) exportClasses(tiledb_query) exportClasses(tiledb_query_condition) exportClasses(tiledb_subarray) diff --git a/R/Profile.R b/R/Profile.R index 49e1120b96..a9ce7aad2a 100644 --- a/R/Profile.R +++ b/R/Profile.R @@ -18,10 +18,10 @@ setMethod( #' Create a 'tiledb_profile' object #' -#' @param name (optional) Name for the profile. -#' @param dir (optional) Directory to create the profile in. -#' @return 'tiledb_profile' object -#' @export tiledb_profile +#' @param name (optional) Name for the profile +#' @param dir (optional) Directory to create the profile in +#' @return A new 'tiledb_profile' object +#' @export tiledb_profile <- function(name = NULL, dir = NULL) { stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) @@ -30,7 +30,12 @@ tiledb_profile <- function(name = NULL, dir = NULL) { return(profile) } - +#' Load a saved 'tiledb_profile' object +#' +#' @param name (optional) Name of the profile to load +#' @param dir (optional) Directory where the profile to load is saved +#' @return The loaded 'tiledb_profile' object +#' @export tiledb_profile_load <- function(name = NULL, dir = NULL) { stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) @@ -39,6 +44,11 @@ tiledb_profile_load <- function(name = NULL, dir = NULL) { return(profile) } +#' Remove a saved 'tiledb_profile' +#' +#' @param name (optional) Name of the profile to remove +#' @param dir (optional) Directory where the profile to remove is saved +#' @export tiledb_profile_remove <- function(name = NULL, dir = NULL) { stopifnot(`The 'name' for the profile must be null or a character type` = is.null(name) || is.character(name)) stopifnot(`The 'dir' for the profile must be null or a character type` = is.null(name) || is.character(name)) @@ -46,18 +56,31 @@ tiledb_profile_remove <- function(name = NULL, dir = NULL) { return(invisible(NULL)) } +#' Get the name of a 'tiledb_profile' object +#' +#' @return The name of the 'tiledb_profile' object +#' @export tiledb_profile_name <- function(profile) { stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) name <- libtiledb_profile_name(profile@ptr) return(name) } +#' Get the directory of a 'tiledb_profile' object +#' +#' @return The directory of the 'tiledb_profile' object +#' @export tiledb_profile_dir <- function(profile) { stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) dir <- libtiledb_profile_dir(profile@ptr) return(dir) } +#' Set a parameter on the 'tiledb_profile' object +#' +#' @param param The key for the new parameter +#' @param value The value for the new parameter +#' @export tiledb_profile_set_param <- function(profile, param, value) { stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) stopifnot(`The 'param' arugment must have character type` = is.character(param)) @@ -66,6 +89,11 @@ tiledb_profile_set_param <- function(profile, param, value) { return(invisible(NULL)) } +#' Get the value of a parameter set on the 'tiledb_profile' object +#' +#' @param param The key for the parameter to fetch +#' @return The value of the requested parameter or NULL if no such parameter exists +#' @export tiledb_profile_get_param <- function(profile, param) { stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) stopifnot(`The 'param' arugment must have character type` = is.character(param)) @@ -73,8 +101,14 @@ tiledb_profile_get_param <- function(profile, param) { return(value) } +#' Save the 'tiledb_profile' object +#' +#' This will save the 'tiledb_profile' with the name and directory set at creation. +#' +#' @param profile The 'tiledb_profile' object to save +#' @export tiledb_profile_save <- function(profile) { stopifnot(`The 'profile' argument must be a tiledb_profile object` = is(profile, "tiledb_profile")) - libtiledb_profile_save(profile) + libtiledb_profile_save(profile@ptr) return(invisible(NULL)) } diff --git a/man/tiledb_profile-class.Rd b/man/tiledb_profile-class.Rd new file mode 100644 index 0000000000..c9ba7ed7fd --- /dev/null +++ b/man/tiledb_profile-class.Rd @@ -0,0 +1,15 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\docType{class} +\name{tiledb_profile-class} +\alias{tiledb_profile-class} +\title{An S4 class for a TileDB Profile object} +\description{ +An S4 class for a TileDB Profile object +} +\section{Slots}{ + +\describe{ +\item{\code{ptr}}{An external pointer to the underlying implementation} +}} + diff --git a/man/tiledb_profile.Rd b/man/tiledb_profile.Rd new file mode 100644 index 0000000000..0421cc1143 --- /dev/null +++ b/man/tiledb_profile.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile} +\alias{tiledb_profile} +\title{Create a 'tiledb_profile' object} +\usage{ +tiledb_profile(name = NULL, dir = NULL) +} +\arguments{ +\item{name}{(optional) Name for the profile} + +\item{dir}{(optional) Directory to create the profile in} +} +\value{ +A new 'tiledb_profile' object +} +\description{ +Create a 'tiledb_profile' object +} diff --git a/man/tiledb_profile_dir.Rd b/man/tiledb_profile_dir.Rd new file mode 100644 index 0000000000..bb40e5e7bf --- /dev/null +++ b/man/tiledb_profile_dir.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_dir} +\alias{tiledb_profile_dir} +\title{Get the directory of a 'tiledb_profile' object} +\usage{ +tiledb_profile_dir(profile) +} +\value{ +The directory of the 'tiledb_profile' object +} +\description{ +Get the directory of a 'tiledb_profile' object +} diff --git a/man/tiledb_profile_get_param.Rd b/man/tiledb_profile_get_param.Rd new file mode 100644 index 0000000000..3364708151 --- /dev/null +++ b/man/tiledb_profile_get_param.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_get_param} +\alias{tiledb_profile_get_param} +\title{Get the value of a parameter set on the 'tiledb_profile' object} +\usage{ +tiledb_profile_get_param(profile, param) +} +\arguments{ +\item{param}{The key for the parameter to fetch} +} +\value{ +The value of the requested parameter or NULL if no such parameter exists +} +\description{ +Get the value of a parameter set on the 'tiledb_profile' object +} diff --git a/man/tiledb_profile_load.Rd b/man/tiledb_profile_load.Rd new file mode 100644 index 0000000000..8b472eb2cb --- /dev/null +++ b/man/tiledb_profile_load.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_load} +\alias{tiledb_profile_load} +\title{Load a saved 'tiledb_profile' object} +\usage{ +tiledb_profile_load(name = NULL, dir = NULL) +} +\arguments{ +\item{name}{(optional) Name of the profile to load} + +\item{dir}{(optional) Directory where the profile to load is saved} +} +\value{ +The loaded 'tiledb_profile' object +} +\description{ +Load a saved 'tiledb_profile' object +} diff --git a/man/tiledb_profile_name.Rd b/man/tiledb_profile_name.Rd new file mode 100644 index 0000000000..be7c057d48 --- /dev/null +++ b/man/tiledb_profile_name.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_name} +\alias{tiledb_profile_name} +\title{Get the name of a 'tiledb_profile' object} +\usage{ +tiledb_profile_name(profile) +} +\value{ +The name of the 'tiledb_profile' object +} +\description{ +Get the name of a 'tiledb_profile' object +} diff --git a/man/tiledb_profile_remove.Rd b/man/tiledb_profile_remove.Rd new file mode 100644 index 0000000000..0fde303448 --- /dev/null +++ b/man/tiledb_profile_remove.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_remove} +\alias{tiledb_profile_remove} +\title{Remove a saved 'tiledb_profile'} +\usage{ +tiledb_profile_remove(name = NULL, dir = NULL) +} +\arguments{ +\item{name}{(optional) Name of the profile to remove} + +\item{dir}{(optional) Directory where the profile to remove is saved} +} +\description{ +Remove a saved 'tiledb_profile' +} diff --git a/man/tiledb_profile_save.Rd b/man/tiledb_profile_save.Rd new file mode 100644 index 0000000000..24c174f837 --- /dev/null +++ b/man/tiledb_profile_save.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_save} +\alias{tiledb_profile_save} +\title{Save the 'tiledb_profile' object} +\usage{ +tiledb_profile_save(profile) +} +\arguments{ +\item{profile}{The 'tiledb_profile' object to save} +} +\description{ +This will save the 'tiledb_profile' with the name and directory set at creation. +} diff --git a/man/tiledb_profile_set_param.Rd b/man/tiledb_profile_set_param.Rd new file mode 100644 index 0000000000..7a5ff5afe1 --- /dev/null +++ b/man/tiledb_profile_set_param.Rd @@ -0,0 +1,16 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{tiledb_profile_set_param} +\alias{tiledb_profile_set_param} +\title{Set a parameter on the 'tiledb_profile' object} +\usage{ +tiledb_profile_set_param(profile, param, value) +} +\arguments{ +\item{param}{The key for the new parameter} + +\item{value}{The value for the new parameter} +} +\description{ +Set a parameter on the 'tiledb_profile' object +} From c6dedafbba59461d4506a7a570259c31c810acf5 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 15:59:01 -0400 Subject: [PATCH 06/18] Fix typo in Rcpp::export --- R/RcppExports.R | 4 ++++ src/RcppExports.cpp | 12 ++++++++++++ src/libtiledb.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/R/RcppExports.R b/R/RcppExports.R index 7b2c32affa..57941ae0c8 100644 --- a/R/RcppExports.R +++ b/R/RcppExports.R @@ -1241,6 +1241,10 @@ libtiledb_profile_load <- function(name = NULL, dir = NULL) { .Call(`_tiledb_libtiledb_profile_load`, name, dir) } +libtiledb_profile_remove <- function(name = NULL, dir = NULL) { + invisible(.Call(`_tiledb_libtiledb_profile_remove`, name, dir)) +} + libtiledb_profile_name <- function(profile) { .Call(`_tiledb_libtiledb_profile_name`, profile) } diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index 7acaae79d9..64dd06ac00 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -3702,6 +3702,17 @@ BEGIN_RCPP return rcpp_result_gen; END_RCPP } +// libtiledb_profile_remove +void libtiledb_profile_remove(Nullable name, Nullable dir); +RcppExport SEXP _tiledb_libtiledb_profile_remove(SEXP nameSEXP, SEXP dirSEXP) { +BEGIN_RCPP + Rcpp::RNGScope rcpp_rngScope_gen; + Rcpp::traits::input_parameter< Nullable >::type name(nameSEXP); + Rcpp::traits::input_parameter< Nullable >::type dir(dirSEXP); + libtiledb_profile_remove(name, dir); + return R_NilValue; +END_RCPP +} // libtiledb_profile_name std::string libtiledb_profile_name(XPtr profile); RcppExport SEXP _tiledb_libtiledb_profile_name(SEXP profileSEXP) { @@ -4152,6 +4163,7 @@ static const R_CallMethodDef CallEntries[] = { {"_tiledb_libtiledb_current_domain_is_empty", (DL_FUNC) &_tiledb_libtiledb_current_domain_is_empty, 1}, {"_tiledb_libtiledb_profile_new", (DL_FUNC) &_tiledb_libtiledb_profile_new, 2}, {"_tiledb_libtiledb_profile_load", (DL_FUNC) &_tiledb_libtiledb_profile_load, 2}, + {"_tiledb_libtiledb_profile_remove", (DL_FUNC) &_tiledb_libtiledb_profile_remove, 2}, {"_tiledb_libtiledb_profile_name", (DL_FUNC) &_tiledb_libtiledb_profile_name, 1}, {"_tiledb_libtiledb_profile_dir", (DL_FUNC) &_tiledb_libtiledb_profile_dir, 1}, {"_tiledb_libtiledb_profile_set_param", (DL_FUNC) &_tiledb_libtiledb_profile_set_param, 3}, diff --git a/src/libtiledb.cpp b/src/libtiledb.cpp index 7fea16fd8b..01ea2080dc 100644 --- a/src/libtiledb.cpp +++ b/src/libtiledb.cpp @@ -5955,7 +5955,7 @@ XPtr libtiledb_profile_load(Nullable name = R_ return make_xptr(new tiledb::Profile(tiledb::Profile::load(name_, dir_))); } -// [[Rcpp:export]] +// [[Rcpp::export]] void libtiledb_profile_remove(Nullable name = R_NilValue, Nullable dir = R_NilValue) { auto name_ = as_optional_string(name); auto dir_ = as_optional_string(dir); From c4a7a33e39ef259528f5ebc18b9be2dcf21a6dfd Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 16:10:37 -0400 Subject: [PATCH 07/18] Add basic profile test --- inst/tinytest/test_profile.R | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 inst/tinytest/test_profile.R diff --git a/inst/tinytest/test_profile.R b/inst/tinytest/test_profile.R new file mode 100644 index 0000000000..234be73a31 --- /dev/null +++ b/inst/tinytest/test_profile.R @@ -0,0 +1,78 @@ +library(tinytest) +library(tiledb) + +# Use base directory to prevent over-writing user profiles. +base_dir <- tempdir() +dir1 <- file.path(base_dir, "tiledb_profile/") + + +# 1. Test creating profiles. +profile1 <- tiledb_profile() +profile2 <- tiledb_profile("profile2") +profile3 <- tiledb_profile(dir=dir1) +profile4 <- tiledb_profile("profile4", dir1) + +expect_equal(tiledb_profile_name(profile1), "default") +expect_equal(tiledb_profile_name(profile2), "profile2") +expect_equal(tiledb_profile_name(profile3), "default") +expect_equal(tiledb_profile_name(profile4), "profile4") + +expect_true(dir.exists(tiledb_profile_dir(profile1))) +expect_true(dir.exists(tiledb_profile_dir(profile2))) +expect_equal(tiledb_profile_dir(profile3), dir1) +expect_equal(tiledb_profile_dir(profile4), dir1) + + +# 2. Test setting/getting profile parameters. +key1 <- "username" +key2 <- "server_address" +key3 <- "rest.token" +expected_value1 <- "my_username" +expected_value2 <- "https://my.address" +expected_value3 <- "123456" + +tiledb_profile_set_param(profile4, key1, expected_value1) +tiledb_profile_set_param(profile4, key2, expected_value2) +tiledb_profile_set_param(profile4, key3, expected_value3) + +actual_value1 <- tiledb_profile_get_param(profile4, key1) +actual_value2 <- tiledb_profile_get_param(profile4, key2) +actual_value3 <- tiledb_profile_get_param(profile4, key3) +actual_non_value <- tiledb_profile_get_param(profile4, "not_a_parameter") + +expect_equal(actual_value1, expected_value1) +expect_equal(actual_value2, expected_value2) +expect_equal(actual_value3, expected_value3) +expect_true(is.null(actual_non_value)) + +# 3. Test save, load, and remove. +# IMPORTANT: Do not save a profile to a location that might over-write an actual profile. +tiledb_profile_save(profile3) +tiledb_profile_save(profile4) + +# -- Check can load profile3 +profile_loaded <- tiledb_profile_load(dir=dir1) + +# -- Remove profile2. Check can no longer load. +tiledb_profile_remove(dir=dir1) +expect_error(tiledb_profile_load(dir=dir1)) + +# -- Check loaded profile4 +profile_loaded <- tiledb_profile_load("profile4", dir1) +expect_equal(tiledb_profile_name(profile_loaded), "profile4") +expect_equal(tiledb_profile_name(profile_loaded), "profile4") +loaded_value1 <- tiledb_profile_get_param(profile_loaded, key1) +loaded_value2 <- tiledb_profile_get_param(profile_loaded, key2) +loaded_value3 <- tiledb_profile_get_param(profile_loaded, key3) +loaded_non_value <- tiledb_profile_get_param(profile_loaded, "not_a_parameter") +expect_equal(loaded_value1, expected_value1) +expect_equal(loaded_value2, expected_value2) +expect_equal(loaded_value3, expected_value3) +expect_true(is.null(loaded_non_value)) + +# -- Remove profile4 +tiledb_profile_remove("profile4", dir1) + +# -- Check cannot load profile2 or profile4. +expect_error(tiledb_profile_load(dir=dir1)) +expect_error(tiledb_profile_load("profile4", dir1)) From cb44dc69c748d2f1f741f89c8d2eba77c2105a78 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 16:44:02 -0400 Subject: [PATCH 08/18] Add test for using profile in config --- inst/tinytest/test_config_profile.R | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 inst/tinytest/test_config_profile.R diff --git a/inst/tinytest/test_config_profile.R b/inst/tinytest/test_config_profile.R new file mode 100644 index 0000000000..7f35e8eadc --- /dev/null +++ b/inst/tinytest/test_config_profile.R @@ -0,0 +1,36 @@ +library(tinytest) +library(tiledb) + +# Use base directory to prevent over-writing user profiles. +name <- "test_profile" +dir <- file.path(tempdir(), "tiledb_config_profile/") + +# Create profile +profile <- tiledb_profile(name, dir) + +# Set some parameters +token <- "12345" +server_address <- "https://profile_address.com" +tiledb_profile_set_param(profile, "rest.token", token) +tiledb_profile_set_param(profile, "rest.server_address", server_address) + +# Save the profile +tiledb_profile_save(profile) + + +# Create a config and set the profile directory +config <- tiledb_config(c(profile_name = name, profile_dir = dir)) +config_profile_name <- config["profile_name"] +config_profile_dir <- config["profile_dir"] +config_rest_token <- config["rest.token"] +config_rest_server_address <- config["rest.server_address"] + +# Test that the config parameters are set correctly +expect_equal(config["profile_name"], c(profile_name = name)) +expect_equal(config["profile_dir"], c(profile_dir = dir)) +expect_equal(config["rest.token"], c(rest.token = token)) +expect_equal(config["rest.server_address"], c(rest.server_address = server_address)) + + +# Remove the profile +tiledb_profile_remove(name, dir) From 8b1a960addd11aaad8689b9807d2762d7296dea6 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 16:48:37 -0400 Subject: [PATCH 09/18] Fix test --- inst/tinytest/test_profile.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/inst/tinytest/test_profile.R b/inst/tinytest/test_profile.R index 234be73a31..05c42feba1 100644 --- a/inst/tinytest/test_profile.R +++ b/inst/tinytest/test_profile.R @@ -17,8 +17,7 @@ expect_equal(tiledb_profile_name(profile2), "profile2") expect_equal(tiledb_profile_name(profile3), "default") expect_equal(tiledb_profile_name(profile4), "profile4") -expect_true(dir.exists(tiledb_profile_dir(profile1))) -expect_true(dir.exists(tiledb_profile_dir(profile2))) +# Skipping checks for default directory since it is platform dependent. expect_equal(tiledb_profile_dir(profile3), dir1) expect_equal(tiledb_profile_dir(profile4), dir1) From 7e3c0e2d9b5e181dcf3cd8c02d53f59e4350cd74 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 17:22:09 -0400 Subject: [PATCH 10/18] Fix test for windows paths --- inst/tinytest/test_profile.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inst/tinytest/test_profile.R b/inst/tinytest/test_profile.R index 05c42feba1..c29072c393 100644 --- a/inst/tinytest/test_profile.R +++ b/inst/tinytest/test_profile.R @@ -3,7 +3,7 @@ library(tiledb) # Use base directory to prevent over-writing user profiles. base_dir <- tempdir() -dir1 <- file.path(base_dir, "tiledb_profile/") +dir1 <- file.path(base_dir, "tiledb_profile") # 1. Test creating profiles. @@ -18,8 +18,9 @@ expect_equal(tiledb_profile_name(profile3), "default") expect_equal(tiledb_profile_name(profile4), "profile4") # Skipping checks for default directory since it is platform dependent. -expect_equal(tiledb_profile_dir(profile3), dir1) -expect_equal(tiledb_profile_dir(profile4), dir1) +dir1_extra_slash <- file.path(base_dir, "tiledb_profile/") +expect_true(tiledb_profile_dir(profile3) == dir1 || tiledb_profile_dir(profile3) == dir1_extra_slash) +expect_true(tiledb_profile_dir(profile4) == dir1 || tiledb_profile_dir(profile4) == dir1_extra_slash) # 2. Test setting/getting profile parameters. From 18471345b8825d4ad3522389ecec06ef68e90d22 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 28 Oct 2025 17:25:17 -0400 Subject: [PATCH 11/18] Update pkgdown index --- pkgdown/_pkgdown.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 35d1051e40..59cd294c49 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -95,6 +95,9 @@ reference: contents: - starts_with("tiledb_query") - matches("parse_query_condition") +- title: Profile + contents: + - starts_with("tiledb_profile") - matches("tiledb_get_query_status") - matches("tiledb_error_message") - matches("completedBatched") From 5a8d1c063e3e907af93c42b4abcaf7b039d6b3dc Mon Sep 17 00:00:00 2001 From: Julia Dark <24235303+jp-dark@users.noreply.github.com> Date: Tue, 28 Oct 2025 19:28:38 -0400 Subject: [PATCH 12/18] Properly normalize paths in tests Co-authored-by: Paul Hoffman --- inst/tinytest/test_profile.R | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/inst/tinytest/test_profile.R b/inst/tinytest/test_profile.R index c29072c393..d49efad0eb 100644 --- a/inst/tinytest/test_profile.R +++ b/inst/tinytest/test_profile.R @@ -18,9 +18,26 @@ expect_equal(tiledb_profile_name(profile3), "default") expect_equal(tiledb_profile_name(profile4), "profile4") # Skipping checks for default directory since it is platform dependent. -dir1_extra_slash <- file.path(base_dir, "tiledb_profile/") -expect_true(tiledb_profile_dir(profile3) == dir1 || tiledb_profile_dir(profile3) == dir1_extra_slash) -expect_true(tiledb_profile_dir(profile4) == dir1 || tiledb_profile_dir(profile4) == dir1_extra_slash) +# Normalize paths on Windows to UNIX-style +profile3_dir <- normalizePath( + path = tiledb_profile_dir(profile3), + winslash = "/", + mustWork = FALSE +) +expect_identical( + # trim trailing slashes + current = sub(pattern = "/+$", replacement = "", x = profile3_dir), + target = dir1 +) +profile4_dir <- normalizePath( + path = tiledb_profile_dir(profile4), + winslash = "/", + mustWork = FALSE +) +expect_identical( + current = sub(pattern = "/+$", replacement = "", x = profile4_dir), + target = dir1 +) # 2. Test setting/getting profile parameters. From c78b12819b0f9887c984a6c6d744779c2a75842e Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Wed, 29 Oct 2025 09:37:11 -0400 Subject: [PATCH 13/18] Normalize expected dir in test as well --- inst/tinytest/test_profile.R | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/inst/tinytest/test_profile.R b/inst/tinytest/test_profile.R index d49efad0eb..43c876ff5d 100644 --- a/inst/tinytest/test_profile.R +++ b/inst/tinytest/test_profile.R @@ -19,24 +19,29 @@ expect_equal(tiledb_profile_name(profile4), "profile4") # Skipping checks for default directory since it is platform dependent. # Normalize paths on Windows to UNIX-style -profile3_dir <- normalizePath( - path = tiledb_profile_dir(profile3), - winslash = "/", +expected_dir <- normalizePath( + path = dir1, + winslash = "/", + mustWork = FALSE +) +actual_dir_profile3 <- normalizePath( + path = tiledb_profile_dir(profile3), + winslash = "/", mustWork = FALSE ) expect_identical( # trim trailing slashes - current = sub(pattern = "/+$", replacement = "", x = profile3_dir), - target = dir1 + current = sub(pattern = "/+$", replacement = "", x = actual_dir_profile3), + target = expected_dir ) -profile4_dir <- normalizePath( - path = tiledb_profile_dir(profile4), - winslash = "/", +actual_dir_profile4 <- normalizePath( + path = tiledb_profile_dir(profile4), + winslash = "/", mustWork = FALSE ) expect_identical( - current = sub(pattern = "/+$", replacement = "", x = profile4_dir), - target = dir1 + current = sub(pattern = "/+$", replacement = "", x = actual_dir_profile4), + target = expected_dir ) From 8cba0322038d41ec5adbd1863be1055825f2974c Mon Sep 17 00:00:00 2001 From: Julia Dark <24235303+jp-dark@users.noreply.github.com> Date: Wed, 29 Oct 2025 14:12:16 -0400 Subject: [PATCH 14/18] Fix update to pkgdown yaml Co-authored-by: Paul Hoffman --- pkgdown/_pkgdown.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 59cd294c49..2720630359 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -95,12 +95,12 @@ reference: contents: - starts_with("tiledb_query") - matches("parse_query_condition") -- title: Profile - contents: - - starts_with("tiledb_profile") - matches("tiledb_get_query_status") - matches("tiledb_error_message") - matches("completedBatched") + - title: Profile + contents: + - starts_with("tiledb_profile") - matches("createBatched") - matches("fetchBatched") - matches("statusBatched") From e1f01428faa83fb6ca4ffad150cfab59ec04dc8d Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Wed, 29 Oct 2025 14:17:26 -0400 Subject: [PATCH 15/18] Update roxygen docs --- R/Profile.R | 10 ++++++++++ man/raw_dump-tiledb_profile-method.Rd | 14 ++++++++++++++ man/tiledb_profile_dir.Rd | 3 +++ man/tiledb_profile_get_param.Rd | 2 ++ man/tiledb_profile_name.Rd | 3 +++ man/tiledb_profile_set_param.Rd | 2 ++ 6 files changed, 34 insertions(+) create mode 100644 man/raw_dump-tiledb_profile-method.Rd diff --git a/R/Profile.R b/R/Profile.R index a9ce7aad2a..b1539b9600 100644 --- a/R/Profile.R +++ b/R/Profile.R @@ -10,6 +10,12 @@ setClass("tiledb_profile", slots = list(ptr = "externalptr") ) +#' Raw display of a profile object +#' +#' This method uses the display method provided by the underlying library. +#' +#' @param object A profile object +#' @export setMethod( "raw_dump", signature(object = "tiledb_profile"), @@ -58,6 +64,7 @@ tiledb_profile_remove <- function(name = NULL, dir = NULL) { #' Get the name of a 'tiledb_profile' object #' +#' @param profile A TileDB profile object #' @return The name of the 'tiledb_profile' object #' @export tiledb_profile_name <- function(profile) { @@ -68,6 +75,7 @@ tiledb_profile_name <- function(profile) { #' Get the directory of a 'tiledb_profile' object #' +#' @param profile A TileDB profile object #' @return The directory of the 'tiledb_profile' object #' @export tiledb_profile_dir <- function(profile) { @@ -78,6 +86,7 @@ tiledb_profile_dir <- function(profile) { #' Set a parameter on the 'tiledb_profile' object #' +#' @param profile A TileDB profile object #' @param param The key for the new parameter #' @param value The value for the new parameter #' @export @@ -91,6 +100,7 @@ tiledb_profile_set_param <- function(profile, param, value) { #' Get the value of a parameter set on the 'tiledb_profile' object #' +#' @param profile A TileDB profile object #' @param param The key for the parameter to fetch #' @return The value of the requested parameter or NULL if no such parameter exists #' @export diff --git a/man/raw_dump-tiledb_profile-method.Rd b/man/raw_dump-tiledb_profile-method.Rd new file mode 100644 index 0000000000..b2dede88cc --- /dev/null +++ b/man/raw_dump-tiledb_profile-method.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/Profile.R +\name{raw_dump,tiledb_profile-method} +\alias{raw_dump,tiledb_profile-method} +\title{Raw display of a profile object} +\usage{ +\S4method{raw_dump}{tiledb_profile}(object) +} +\arguments{ +\item{object}{A profile object} +} +\description{ +This method uses the display method provided by the underlying library. +} diff --git a/man/tiledb_profile_dir.Rd b/man/tiledb_profile_dir.Rd index bb40e5e7bf..d97eea44d7 100644 --- a/man/tiledb_profile_dir.Rd +++ b/man/tiledb_profile_dir.Rd @@ -6,6 +6,9 @@ \usage{ tiledb_profile_dir(profile) } +\arguments{ +\item{profile}{A TileDB profile object} +} \value{ The directory of the 'tiledb_profile' object } diff --git a/man/tiledb_profile_get_param.Rd b/man/tiledb_profile_get_param.Rd index 3364708151..ad7a2d1c20 100644 --- a/man/tiledb_profile_get_param.Rd +++ b/man/tiledb_profile_get_param.Rd @@ -7,6 +7,8 @@ tiledb_profile_get_param(profile, param) } \arguments{ +\item{profile}{A TileDB profile object} + \item{param}{The key for the parameter to fetch} } \value{ diff --git a/man/tiledb_profile_name.Rd b/man/tiledb_profile_name.Rd index be7c057d48..7659b3af99 100644 --- a/man/tiledb_profile_name.Rd +++ b/man/tiledb_profile_name.Rd @@ -6,6 +6,9 @@ \usage{ tiledb_profile_name(profile) } +\arguments{ +\item{profile}{A TileDB profile object} +} \value{ The name of the 'tiledb_profile' object } diff --git a/man/tiledb_profile_set_param.Rd b/man/tiledb_profile_set_param.Rd index 7a5ff5afe1..54a9eb2829 100644 --- a/man/tiledb_profile_set_param.Rd +++ b/man/tiledb_profile_set_param.Rd @@ -7,6 +7,8 @@ tiledb_profile_set_param(profile, param, value) } \arguments{ +\item{profile}{A TileDB profile object} + \item{param}{The key for the new parameter} \item{value}{The value for the new parameter} From 354527826011835c8942a301a8e1293ab3bcb85c Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Wed, 29 Oct 2025 14:28:06 -0400 Subject: [PATCH 16/18] Fix pkgdown.yml --- pkgdown/_pkgdown.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 2720630359..adf66b68e1 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -98,12 +98,12 @@ reference: - matches("tiledb_get_query_status") - matches("tiledb_error_message") - matches("completedBatched") - - title: Profile - contents: - - starts_with("tiledb_profile") - matches("createBatched") - matches("fetchBatched") - matches("statusBatched") +- title: Profile + contents: + - starts_with("tiledb_profile") - title: Group contents: - starts_with("tiledb_group") From a520af9f80aac1b5bf5be454a5eaa28eee7815c7 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Wed, 29 Oct 2025 14:42:10 -0400 Subject: [PATCH 17/18] Add Profile S4 methods to pkgdown index --- pkgdown/_pkgdown.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index adf66b68e1..a72c4303e2 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -104,6 +104,7 @@ reference: - title: Profile contents: - starts_with("tiledb_profile") + - ends_with("tiledb_profile-method") - title: Group contents: - starts_with("tiledb_group") From 5103065a3724df37911c3c3835133e8f013d9ee0 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Thu, 30 Oct 2025 15:15:06 -0400 Subject: [PATCH 18/18] Update version and news --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4a090f7624..094b720e6e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tiledb Type: Package -Version: 0.33.1 +Version: 0.33.1.1 Title: Modern Database Engine for Complex Data Based on Multi-Dimensional Arrays Authors@R: c( person("TileDB, Inc.", role = c("aut", "cph")), diff --git a/NEWS.md b/NEWS.md index f487cd9ad9..1f022521cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # tiledb (development version) +## Improvements + +* Add support for creating, loading, saving, and removing Profiles ([#856](https://github.com/TileDB-Inc/TileDB-R/pull/856)) + # tiledb 0.33.1 * This release of the R package builds against [TileDB 2.29.1](https://github.com/TileDB-Inc/TileDB/releases/tag/2.29.1), and has also been tested against earlier releases as well as the development version