From c3bfb9cea7330e05db408a7cd83355c45ca1b5d5 Mon Sep 17 00:00:00 2001 From: Constantinos Giachalis Date: Wed, 10 Sep 2025 15:54:02 +0300 Subject: [PATCH 1/2] Reset timestamp slots for 'tiledb_array_open_at()' --- R/Array.R | 4 +++ inst/tinytest/test_tiledbarray.R | 58 ++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/R/Array.R b/R/Array.R index 56ec593df5..8e4edf44fe 100644 --- a/R/Array.R +++ b/R/Array.R @@ -106,6 +106,10 @@ tiledb_array_open_at <- function(arr, type = c("READ", "WRITE"), timestamp) { ) type <- match.arg(type) ctx <- tiledb_get_context() + + arr@timestamp_start <- as.POSIXct(double(), origin = "1970-01-01") + arr@timestamp_end <- timestamp + if (.hasSlot(arr, "encryption_key") && length(arr@encryption_key) > 0) { arr@ptr <- libtiledb_array_open_at_with_key(ctx@ptr, arr@uri, type, arr@encryption_key, timestamp) } else { diff --git a/inst/tinytest/test_tiledbarray.R b/inst/tinytest/test_tiledbarray.R index cf42a8cd51..517022bea9 100644 --- a/inst/tinytest/test_tiledbarray.R +++ b/inst/tinytest/test_tiledbarray.R @@ -1035,6 +1035,64 @@ if (tiledb_version(TRUE) >= "2.10.0") { expect_equal(nrow(A[]), 6) } +## Repeat test process as above but using 'tiledb_array_open_at()' + +tmp <- tempfile() +dir.create(tmp) +dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 10L), 5L, "INT32"), + tiledb_dim("cols", c(1L, 10L), 5L, "INT32"))) +schema <- tiledb_array_schema(dom, attrs=c(tiledb_attr("a", type = "INT32")), sparse = TRUE) +invisible( tiledb_array_create(tmp, schema) ) + +I <- c(1, 2, 2) +J <- c(1, 4, 3) +data <- c(1L, 2L, 3L) +now1 <- Sys.time() + +A <- tiledb_array(uri = tmp) +A <- tiledb_array_open_at(A, type = "WRITE", timestamp = now1) +expect_true(tiledb_array_is_open_for_writing(A)) +A[I, J] <- data + +twot <- 1 + isMacOS*5 +onet <- twot/2 +Sys.sleep(twot) + +now2 <- Sys.time() +I <- c(8, 6, 9) +J <- c(5, 7, 8) +data <- c(11L, 22L, 33L) +A <- tiledb_array_open_at(A, type = "WRITE", timestamp = now2) +A[I, J] <- data + +# tiledb_array_open_at reset timestamp slots to +expect_equal(A@timestamp_start, as.POSIXct(double(), origin = "1970-01-01")) +expect_equal(A@timestamp_end, now2) + +A <- tiledb_array_close(A) + +return_as(A) <- "data.frame" +A <- tiledb_array_open_at(A, type = "READ", timestamp = now1 - onet) +expect_true(tiledb_array_is_open_for_reading(A)) +expect_equal(nrow(A[]), 0) + +# This must be reset with tiledb_array_open_at +A@timestamp_start <- now1 + onet +A <- tiledb_array_open_at(A, type = "READ", timestamp = now1 + onet) +expect_equal(nrow(A[]), 3) + +# Check we have +expect_equal(A@timestamp_start, as.POSIXct(double(), origin = "1970-01-01")) +expect_equal(A@timestamp_end, now1 + onet) + +A <- tiledb_array_open_at(A, type = "READ", timestamp = now2 - onet) +expect_equal(nrow(A[]), 3) + +A <- tiledb_array_open_at(A, type = "READ", timestamp = now2 + onet) +expect_equal(nrow(A[]), 6) + +rm(A) + ## n=118 ## as.matrix tmp <- tempfile() From b20a4d17a02e04fbcb1df838d51c4c80e36d4dfa Mon Sep 17 00:00:00 2001 From: Constantinos Giachalis Date: Tue, 30 Sep 2025 19:17:37 +0300 Subject: [PATCH 2/2] Update DESCRIPTION and NEWS.md [ci skip] --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index b7469d1864..7a9c0130e1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tiledb Type: Package -Version: 0.33.0.1 +Version: 0.33.0.2 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 03dfb27ed5..d87d090457 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ * The factor levels are now remapped as expected when updating an array with values that include no additional factor levels (@cgiachalis in [#844](https://github.com/TileDB-Inc/TileDB-R/pull/844)) +* `tiledb_array_open_at()` now resets timestamp slots to `` before opening the array (@cgiachalis in [#842](https://github.com/TileDB-Inc/TileDB-R/pull/842)) + # tiledb 0.33.0 * This release of the R package builds against [TileDB 2.29.0](https://github.com/TileDB-Inc/TileDB/releases/tag/2.29.0), and has also been tested against earlier releases as well as the development version