@@ -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
10401098tmp <- tempfile()
0 commit comments