Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor time travel test using absolute timestamps #716

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions R/Array.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
#'
#' @export
tiledb_array_create <- function(uri, schema, encryption_key) {
stopifnot(`The 'uri' argument must be a string scalar` = !missing(uri) && is.scalar(uri, "character"),
`The 'schema' argument must be a tiledb_array_schema object` = !missing(schema) && is(schema, "tiledb_array_schema"))
stopifnot("The 'uri' argument must be a string scalar" = !missing(uri) && is.scalar(uri, "character"),
"The 'schema' argument must be a tiledb_array_schema object" = !missing(schema) && is(schema, "tiledb_array_schema"))
if (missing(encryption_key)) {
invisible(libtiledb_array_create(uri, schema@ptr))
} else {
Expand Down
17 changes: 8 additions & 9 deletions inst/tinytest/test_timetravel.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,26 +172,25 @@ 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, timestamp_start=now1)
now1 <- as.POSIXct(60, tz="UTC") # the epoch plus one minute
A <- tiledb_array(uri = tmp, timestamp_start=now1, timestamp_end=now1)
A[I, J] <- data

deltat <- 0.1
deltat <- 1 # delta of 1 second
epst <- deltat/2
Sys.sleep(deltat)

I <- c(8, 6, 9)
J <- c(5, 7, 8)
data <- c(11L, 22L, 33L)
now2 <- Sys.time()
A <- tiledb_array(uri = tmp, timestamp_start=now2)
A <- tiledb_array(uri = tmp, timestamp_start=now2, timestamp_end=now2)
A[I, J] <- data

A <- tiledb_array(uri = tmp, return_as="data.frame", timestamp_end=now1 - epst)
expect_equal(nrow(A[]), 0)
expect_equal(nrow(A[]), 0) # no rows before start
A <- tiledb_array(uri = tmp, return_as="data.frame", timestamp_start=now1 + epst)
expect_equal(nrow(A[]), 3)
expect_equal(nrow(A[]), 3) # three rows in first write at now1
A <- tiledb_array(uri = tmp, return_as="data.frame", timestamp_start=now1 - epst, timestamp_end=now2 - epst)
expect_equal(nrow(A[]), 3)
expect_equal(nrow(A[]), 3) # three rows if end before now2
A <- tiledb_array(uri = tmp, return_as="data.frame", timestamp_start=now1 - epst, timestamp_end=now2 + epst)
expect_true(nrow(A[]) >= 3)
expect_true(nrow(A[]) >= 3) # all data from before now1 to after now2
1 change: 1 addition & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ all: $(OBJECTS) $(LIB_CON) $(SHLIB)
$(LIB_CON): connection/connection.o
@mkdir -p $(LIB_CON_DIR)
@$(SHLIB_LINK) $(SHLIB_LIBADD) $(LIBR) -o $@ $^
@rm $^

clean:
rm -f $(SHLIB) $(OBJECTS) $(LIB_CON) connection/connection.o
Expand Down
Loading