Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<origin, timestamp>` 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
Expand Down
4 changes: 4 additions & 0 deletions R/Array.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
58 changes: 58 additions & 0 deletions inst/tinytest/test_tiledbarray.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 <origin, timestamp_end>
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 <origin, timestamp_end>
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()
Expand Down