Skip to content

Commit e2717d9

Browse files
authored
Reset timestamp slots for tiledb_array_open_at() (#842)
* Reset timestamp slots for 'tiledb_array_open_at()' * Update DESCRIPTION and NEWS.md
1 parent 01de444 commit e2717d9

4 files changed

Lines changed: 65 additions & 1 deletion

File tree

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.33.0.1
3+
Version: 0.33.0.2
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
@@ -4,6 +4,8 @@
44

55
* 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))
66

7+
* `tiledb_array_open_at()` now resets timestamp slots to `<origin, timestamp>` before opening the array (@cgiachalis in [#842](https://github.com/TileDB-Inc/TileDB-R/pull/842))
8+
79
# tiledb 0.33.0
810

911
* 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

R/Array.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ tiledb_array_open_at <- function(arr, type = c("READ", "WRITE"), timestamp) {
106106
)
107107
type <- match.arg(type)
108108
ctx <- tiledb_get_context()
109+
110+
arr@timestamp_start <- as.POSIXct(double(), origin = "1970-01-01")
111+
arr@timestamp_end <- timestamp
112+
109113
if (.hasSlot(arr, "encryption_key") && length(arr@encryption_key) > 0) {
110114
arr@ptr <- libtiledb_array_open_at_with_key(ctx@ptr, arr@uri, type, arr@encryption_key, timestamp)
111115
} else {

inst/tinytest/test_tiledbarray.R

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,64 @@ if (tiledb_version(TRUE) >= "2.10.0") {
10351035
expect_equal(nrow(A[]), 6)
10361036
}
10371037

1038+
## Repeat test process as above but using 'tiledb_array_open_at()'
1039+
1040+
tmp <- tempfile()
1041+
dir.create(tmp)
1042+
dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 10L), 5L, "INT32"),
1043+
tiledb_dim("cols", c(1L, 10L), 5L, "INT32")))
1044+
schema <- tiledb_array_schema(dom, attrs=c(tiledb_attr("a", type = "INT32")), sparse = TRUE)
1045+
invisible( tiledb_array_create(tmp, schema) )
1046+
1047+
I <- c(1, 2, 2)
1048+
J <- c(1, 4, 3)
1049+
data <- c(1L, 2L, 3L)
1050+
now1 <- Sys.time()
1051+
1052+
A <- tiledb_array(uri = tmp)
1053+
A <- tiledb_array_open_at(A, type = "WRITE", timestamp = now1)
1054+
expect_true(tiledb_array_is_open_for_writing(A))
1055+
A[I, J] <- data
1056+
1057+
twot <- 1 + isMacOS*5
1058+
onet <- twot/2
1059+
Sys.sleep(twot)
1060+
1061+
now2 <- Sys.time()
1062+
I <- c(8, 6, 9)
1063+
J <- c(5, 7, 8)
1064+
data <- c(11L, 22L, 33L)
1065+
A <- tiledb_array_open_at(A, type = "WRITE", timestamp = now2)
1066+
A[I, J] <- data
1067+
1068+
# tiledb_array_open_at reset timestamp slots to <origin, timestamp_end>
1069+
expect_equal(A@timestamp_start, as.POSIXct(double(), origin = "1970-01-01"))
1070+
expect_equal(A@timestamp_end, now2)
1071+
1072+
A <- tiledb_array_close(A)
1073+
1074+
return_as(A) <- "data.frame"
1075+
A <- tiledb_array_open_at(A, type = "READ", timestamp = now1 - onet)
1076+
expect_true(tiledb_array_is_open_for_reading(A))
1077+
expect_equal(nrow(A[]), 0)
1078+
1079+
# This must be reset with tiledb_array_open_at
1080+
A@timestamp_start <- now1 + onet
1081+
A <- tiledb_array_open_at(A, type = "READ", timestamp = now1 + onet)
1082+
expect_equal(nrow(A[]), 3)
1083+
1084+
# Check we have <origin, timestamp_end>
1085+
expect_equal(A@timestamp_start, as.POSIXct(double(), origin = "1970-01-01"))
1086+
expect_equal(A@timestamp_end, now1 + onet)
1087+
1088+
A <- tiledb_array_open_at(A, type = "READ", timestamp = now2 - onet)
1089+
expect_equal(nrow(A[]), 3)
1090+
1091+
A <- tiledb_array_open_at(A, type = "READ", timestamp = now2 + onet)
1092+
expect_equal(nrow(A[]), 6)
1093+
1094+
rm(A)
1095+
10381096
## n=118
10391097
## as.matrix
10401098
tmp <- tempfile()

0 commit comments

Comments
 (0)