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:
// ... create context ctx
// Open at a timestamp
uint64_t timestamp = 1561492235844; // In ms
tiledb_array_alloc(ctx, "<array-uri>", &array);
tiledb_array_set_open_timestamp_end(ctx, array, timestamp);
tiledb_array_open(ctx, array, TILEDB_READ);
// ... create context ctx
// Open at a timestamp
uint64_t timestamp = 1561492235844; // In ms
Array array(ctx, "<array-uri>", TILEDB_READ, TemporalPolicy(TimeTravel, timestamp));
// Or, open encrypted array with key at timestamp
const char key[] = "0123456789abcdeF0123456789abcdeF";
Array array(ctx, "<array-uri>", TILEDB_READ, TemporalPolicy(TimeTravel, timestamp), EncryptionAlgorithm(AESGCM, key));
timestamp = 1561492235844 # time in ms
# `tiledb.open` supports the `timestamp` keyword argument
A = tiledb.open(uri, timestamp=timestamp)
# `timestamp` may also be specified as a (start, end) tuple
A = tiledb.open(uri, timestamp=(start_ts, end_ts))
# Or, open encrypted array with key at timestamp
key = "0123456789abcdeF0123456789abcdeF"
A = tiledb.open(uri, key=key, timestamp=timestamp)
# time traveling is accessible via the lower-level API as well as the
# higher level api. we first show the lower-level
# 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)
# we can also pass datetime objects directly to the array access
# here we open an array at a given timestamp range, we can also
# use only one of the start or end timestamps
arr <- tiledb_array(uri,
timestamp_start = as.POSIXct("2021-01-01 00:00:00"),
timestamp_end = as.POSIXct("2021-01-31 23:59:99.999"))
// ... 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)
// ... 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)
// ... create context ctx
// Open at a timestamp
ulong timestamp = 1561492235844; // In ms
using Array array = new Array(ctx, "<array-uri>");
array.SetOpenTimestampEnd(timestamp);
array.Open(QueryType.Read);
Last updated