Time Traveling

You can open or reopen an array at a particular timestamp, if for example you'd like to see a view of the array in the past. See Time Traveling for more details. You can do so as follows:

C
C++
Python
R
Java
Go
C
// ... create context ctx
// Open at a timestamp
uint64_t timestamp = 1561492235844; // In ms
tiledb_array_alloc(ctx, "<array-uri>", &array);
tiledb_array_open_at(ctx, array, TILEDB_READ, timestamp);
// Or, open encrypted array with key at timestamp
const char key[] = "0123456789abcdeF0123456789abcdeF";
tiledb_array_t* array;
tiledb_array_alloc(ctx, "<array-uri>", &array);
tiledb_array_open_at_with_key(
ctx, array, TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
C++
// ... create context ctx
// Open at a timestamp
uint64_t timestamp = 1561492235844; // In ms
Array array(ctx, "<array-uri>", TILEDB_READ, timestamp);
// Or, open encrypted array with key at timestamp
const char key[] = "0123456789abcdeF0123456789abcdeF";
Array array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
Python
timestamp = 1561492235844 # time in ms
# Array constructors support a `timestamp` keyword argument
A = tiledb.DenseArray(uri, timestamp=timestamp)
A = tiledb.SparseArray(uri, timestamp=timestamp)
# Or, open encrypted array with key at timestamp
key = "0123456789abcdeF0123456789abcdeF"
A = tiledb.DenseArray(uri, key=key, timestamp=timestamp)
A = tiledb.SparseArray(uri, key=key, timestamp=timestamp)
R
# time traveling is currently only accessible via the lower-level API
# we use the R Datetime type; internally TileDB uses milliseconds since epoch
tstamp <- Sys.time() - 60*60 # one hour ago
ctx <- tiledb_ctx()
arrptr <- tiledb:::libtiledb_array_open_at(ctx@ptr, uridense, "READ", tstamp)
subarr <- c(1L,2L, 2L,4L)
qryptr <- tiledb:::libtiledb_query(ctx@ptr, arrptr, "READ")
qryptr <- tiledb:::libtiledb_query_set_subarray(qryptr, subarr)
qryptr <- tiledb:::libtiledb_query_set_layout(qryptr, "ROW_MAJOR")
a <- integer(6) # reserve space
qryptr <- tiledb:::libtiledb_query_set_buffer(qryptr, "a", a)
qryptr <- tiledb:::libtiledb_query_submit(qryptr)
res <- tiledb:::libtiledb_array_close(arrptr)
a
# we can do the same with encrypted arrays
encryption_key <- "0123456789abcdeF0123456789abcdeF"
arrptr <- tiledb:::libtiledb_array_open_at_with_key(ctx@ptr, uridense, "READ",
encryption_tstamp)
Java
// ... create context ctx
// Open at a timestamp
BigInteger timestamp = BigInteger.valueOf(1561492235844L); // In ms
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, timestamp);
// Or, open encrypted array with key at timestamp
String key = "0123456789abcdeF0123456789abcdeF";
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, EncryptionType.TILEDB_AES_256_GCM, key.getBytes(), timestamp)
Go
// ... create context ctx
// Open at a timestamp
var timestamp uint64 = 1561492235844; // In ms
array.OpenAt(TILEDB_READ, timestamp)
// Or, open encrypted array with key at timestamp
var key := "0123456789abcdeF0123456789abcdeF"
array.OpenWithKey(TILEDB_READ, TILEDB_AES_256_GCM, key)