Skip to content

Commit 4cf4aa5

Browse files
authored
Fix tiledb_config_unset (#841)
* Fix 'tiledb_config_unset()' to return S4 class 'tiledb_config' with a ptr slot * Added unit tests to check the expected object and its value has been reset * Fix typos, style and roxygenise in Config.R * Update DESCRIPTION and NEWS.md
1 parent ae107bc commit 4cf4aa5

14 files changed

Lines changed: 62 additions & 45 deletions

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: tiledb
22
Type: Package
3-
Version: 0.32.0.7
3+
Version: 0.32.0.8
44
Title: Modern Database Engine for Complex Data Based on Multi-Dimensional Arrays
55
Authors@R: c(
66
person("TileDB, Inc.", role = c("aut", "cph")),

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
* `tiledb_group_open()` now respects and defaults to the first option in `type` argument (@cgiachalis in [#838](https://github.com/TileDB-Inc/TileDB-R/issues/838))
1414

15+
* `tiledb_config_unset()` now correctly returns the modified configuration object (@cgiachalis in [#841](https://github.com/TileDB-Inc/TileDB-R/issues/841))
16+
1517
## Documentation
1618

1719
* The package documentation website was updated (@cgiachalis in [#822](https://github.com/TileDB-Inc/TileDB-R/pull/822), [#826](https://github.com/TileDB-Inc/TileDB-R/pull/826))

R/Config.R

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22
#
3-
# Copyright (c) 2017-2023 TileDB Inc.
3+
# Copyright (c) 2017-2025 TileDB Inc.
44
#
55
# Permission is hereby granted, free of charge, to any person obtaining a copy
66
# of this software and associated documentation files (the "Software"), to deal
@@ -34,7 +34,7 @@ tiledb_config.from_ptr <- function(ptr) {
3434
new("tiledb_config", ptr = ptr)
3535
}
3636

37-
#' Creates a `tiledb_config` object
37+
#' Creates a TileDB Config object
3838
#'
3939
#' Note that for actually setting persistent values, the (altered) config
4040
#' object needs to used to create (or update) the \code{tiledb_ctx} object. Similarly,
@@ -70,12 +70,13 @@ tiledb_config <- function(config = NA_character_) {
7070

7171
#' Gets a config parameter value
7272
#'
73-
#' @param x `tiledb_config` object
73+
#' @param x A `tiledb_config` object
7474
#' @param i parameter key string
7575
#' @param j parameter key string, currently unused.
7676
#' @param ... Extra parameter for method signature, currently unused.
7777
#' @param drop Optional logical switch to drop dimensions, default FALSE, currently unused.
78-
#' @return a config string value if parameter exists, else NA
78+
#' @return A config string value if parameter exists, else NA
79+
#'
7980
#' @examples
8081
#' \dontshow{
8182
#' ctx <- tiledb_ctx(limitTileDBCores())
@@ -97,11 +98,11 @@ setMethod("[", "tiledb_config", function(x, i, j, ..., drop = FALSE) {
9798

9899
#' Sets a config parameter value
99100
#'
100-
#' @param x `tiledb_config` object
101+
#' @param x A `tiledb_config` object
101102
#' @param i parameter key string
102103
#' @param j parameter key string
103104
#' @param value value to set, will be converted into a stringa
104-
#' @return updated `tiledb_config` object
105+
#' @return The updated `tiledb_config` object
105106
#' @examples
106107
#' \dontshow{
107108
#' ctx <- tiledb_ctx(limitTileDBCores())
@@ -134,7 +135,7 @@ setMethod("[<-", "tiledb_config", function(x, i, j, value) {
134135

135136
#' Prints the config object to STDOUT
136137
#'
137-
#' @param object `tiledb_config` object
138+
#' @param object A `tiledb_config` object
138139
#' @examples
139140
#' \dontshow{
140141
#' ctx <- tiledb_ctx(limitTileDBCores())
@@ -146,9 +147,9 @@ setMethod("show", signature(object = "tiledb_config"), function(object) {
146147
libtiledb_config_dump(object@ptr)
147148
})
148149

149-
#' Save a `tiledb_config` object ot a local text file
150+
#' Save a TileDB Config object to a local text file
150151
#'
151-
#' @param config The `tiledb_config` object
152+
#' @param config A `tiledb_config` object
152153
#' @param path The path to config file to be created
153154
#' @return path to created config file
154155
#' @examples
@@ -170,9 +171,9 @@ tiledb_config_save <- function(config, path) {
170171
libtiledb_config_save_to_file(config@ptr, path)
171172
}
172173

173-
#' Load a saved `tiledb_config` file from disk
174+
#' Load a saved TileDB Config file from disk
174175
#'
175-
#' @param path path to the config file
176+
#' @param path The path to the config file to be loaded
176177
#' @examples
177178
#' \dontshow{
178179
#' ctx <- tiledb_ctx(limitTileDBCores())
@@ -190,11 +191,12 @@ tiledb_config_load <- function(path) {
190191
tiledb_config.from_ptr(ptr)
191192
}
192193

193-
#' Convert a `tiledb_config` object to a R vector
194+
#' Convert a TileDB Config object to a R vector
195+
#'
196+
#' @param x A `tiledb_config` object
197+
#' @param mode A character value `"any"`, currently unused
194198
#'
195-
#' @param x `tiledb_config` object
196-
#' @param mode Character value `"any"`, currently unused
197-
#' @return a character vector of config parameter names, values
199+
#' @return A character vector of config parameter names, values
198200
#' @examples
199201
#' \dontshow{
200202
#' ctx <- tiledb_ctx(limitTileDBCores())
@@ -208,8 +210,9 @@ as.vector.tiledb_config <- function(x, mode = "any") {
208210
libtiledb_config_vector(x@ptr)
209211
}
210212

211-
#' Convert a `tiledb_config` object to a R data.frame
212-
#' @param x `tiledb_config` object
213+
#' Convert a TileDB Config object to `data.frame`
214+
#'
215+
#' @param x A `tiledb_config` object
213216
#' @param ... Extra parameter for method signature, currently unused.
214217
#' @return a data.frame wth parameter, value columns
215218
#' @examples
@@ -230,7 +233,7 @@ as.data.frame.tiledb_config <- function(x, ...) {
230233
#' By default, TileDB will use all available cores on a given machine. In multi-user or
231234
#' multi-process settings, one may want to reduce the number of core. This function will
232235
#' take a given number, or default to smaller of the \sQuote{Ncpus} options value or the
233-
#' \sQuote{"OMP_THREAD_LIMIT"} enviroment variable (or two as hard fallback).
236+
#' \sQuote{"OMP_THREAD_LIMIT"} environment variable (or two as hard fallback).
234237
#'
235238
#' As this function returns a config object, its intended use is as argument to the context
236239
#' creating functions: \code{ctx <- tiledb_ctx(limitTileDBCores())}. To check that the values
@@ -263,16 +266,17 @@ limitTileDBCores <- function(ncores, verbose = FALSE) {
263266

264267
#' Unset a TileDB Config parameter to its default value
265268
#'
266-
#' @param config A TileDB Config object
269+
#' @param config A `tiledb_config` object
267270
#' @param param A character variable with the parameter name
268-
#' @return The modified TileDB Config object
271+
#' @return The modified `tiledb_config` object
269272
#' @export
270273
tiledb_config_unset <- function(config, param) {
271274
stopifnot(
272275
`The 'config' argument must be a tiledb_config object` = is(config, "tiledb_config"),
273276
`The 'param' argument must be of type character` = is.character(param)
274277
)
275-
libtiledb_config_unset(config@ptr, param)
278+
ptr <- libtiledb_config_unset(config@ptr, param)
279+
tiledb_config.from_ptr(ptr)
276280
}
277281

278282
#' Display the 'AsBuilt' JSON string

inst/tinytest/test_config.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ expect_equal(tiledb:::libtiledb_config_get(cfg@ptr, param)[[1]], newval)
7070

7171
tiledb:::libtiledb_config_unset(cfg@ptr, param) # resets, not unsets
7272
expect_equal(tiledb:::libtiledb_config_get(cfg@ptr, param)[[1]], origval)
73+
74+
# test 'tiledb_config_unset()'
75+
origval <- cfg["sm.group.timestamp_end"]
76+
77+
# new value
78+
cfg["sm.group.timestamp_end"] <- 1000
79+
80+
cfg <- tiledb_config_unset(cfg, "sm.group.timestamp_end")
81+
expect_equal(is(cfg), "tiledb_config")
82+
expect_equal(cfg["sm.group.timestamp_end"], origval)
83+
7384
#})
7485

7586

man/as.data.frame.tiledb_config.Rd

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/as.vector.tiledb_config.Rd

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/limitTileDBCores.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/show-tiledb_config-method.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/sub-tiledb_config-ANY-method.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/subset-tiledb_config-ANY-ANY-ANY-method.Rd

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)