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
1
// ... create context ctx
2
3
// Open at a timestamp
4
uint64_t timestamp = 1561492235844; // In ms
5
tiledb_array_alloc(ctx, "<array-uri>", &array);
6
tiledb_array_open_at(ctx, array, TILEDB_READ, timestamp);
7
8
// Or, open encrypted array with key at timestamp
9
const char key[] = "0123456789abcdeF0123456789abcdeF";
10
tiledb_array_t* array;
11
tiledb_array_alloc(ctx, "<array-uri>", &array);
12
tiledb_array_open_at_with_key(
13
ctx, array, TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
Copied!
1
// ... create context ctx
2
3
// Open at a timestamp
4
uint64_t timestamp = 1561492235844; // In ms
5
Array array(ctx, "<array-uri>", TILEDB_READ, timestamp);
6
7
// Or, open encrypted array with key at timestamp
8
const char key[] = "0123456789abcdeF0123456789abcdeF";
9
Array array(ctx, "<array-uri>", TILEDB_READ, TILEDB_AES_256_GCM, key, sizeof(key), timestamp);
Copied!
1
timestamp = 1561492235844 # time in ms
2
3
# `tiledb.open` supports the `timestamp` keyword argument
4
A = tiledb.open(uri, timestamp=timestamp)
5
6
# `timestamp` may also be specified as a (start, end) tuple
7
A = tiledb.open(uri, timestamp=(start_ts, end_ts))
8
9
# Or, open encrypted array with key at timestamp
10
key = "0123456789abcdeF0123456789abcdeF"
11
A = tiledb.open(uri, key=key, timestamp=timestamp)
Copied!
1
# time traveling is accessible via the lower-level API as well as the
2
# higher level api. we first show the lower-level
3
# we use the R Datetime type; internally TileDB uses milliseconds since epoch
4
tstamp <- Sys.time() - 60*60 # one hour ago
5
6
ctx <- tiledb_ctx()
7
arrptr <- tiledb:::libtiledb_array_open_at(ctx@ptr, uridense, "READ", tstamp)
8
subarr <- c(1L,2L, 2L,4L)
9
qryptr <- tiledb:::libtiledb_query(ctx@ptr, arrptr, "READ")
10
qryptr <- tiledb:::libtiledb_query_set_subarray(qryptr, subarr)
11
qryptr <- tiledb:::libtiledb_query_set_layout(qryptr, "ROW_MAJOR")
12
a <- integer(6) # reserve space
13
qryptr <- tiledb:::libtiledb_query_set_buffer(qryptr, "a", a)
14
qryptr <- tiledb:::libtiledb_query_submit(qryptr)
15
res <- tiledb:::libtiledb_array_close(arrptr)
16
a
17
18
# we can do the same with encrypted arrays
19
encryption_key <- "0123456789abcdeF0123456789abcdeF"
20
arrptr <- tiledb:::libtiledb_array_open_at_with_key(ctx@ptr, uridense, "READ",
21
encryption_tstamp)
22
23
# we can also pass datetime objects directly to the array access
24
# here we open an array at a given timestamp range, we can also
25
# use only one of the start or end timestamps
26
arr <- tiledb_array(uri,
27
timestamp_start = as.POSIXct("2021-01-01 00:00:00"),
28
timestamp_end = as.POSIXct("2021-01-31 23:59:99.999"))
29
30
Copied!
1
// ... create context ctx
2
3
// Open at a timestamp
4
BigInteger timestamp = BigInteger.valueOf(1561492235844L); // In ms
5
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, timestamp);
6
7
// Or, open encrypted array with key at timestamp
8
String key = "0123456789abcdeF0123456789abcdeF";
9
Array array = new Array(ctx, "<array-uri>", TILEDB_READ, EncryptionType.TILEDB_AES_256_GCM, key.getBytes(), timestamp)
Copied!
1
// ... create context ctx
2
3
// Open at a timestamp
4
var timestamp uint64 = 1561492235844; // In ms
5
array.OpenAt(TILEDB_READ, timestamp)
6
7
// Or, open encrypted array with key at timestamp
8
var key := "0123456789abcdeF0123456789abcdeF"
9
array.OpenWithKey(TILEDB_READ, TILEDB_AES_256_GCM, key)
Copied!
Copy link