There are cases where it is very useful to write at a specific timestamp (e.g., in the past or the future). TileDB allows you to do that by simply opening the array for writing at the desired timestamp, similar to reads:
#include <tiledb/tiledb.h>
// ... create TileDB context
// Open array for writing at a timestamp
tiledb_array_t* array;
tiledb_array_alloc(ctx, array_name, &array);
tiledb_array_open_at(ctx, array, TILEDB_WRITE, timestamp);
// or use tiledb_array_open_at_with_key for encrypted arrays
// Create the query
tiledb_query_t* query;
tiledb_query_alloc(ctx, array, TILEDB_WRITE, &query);
// ... perform the write as usual
// Close array
tiledb_array_close(ctx, array);
// Clean up
tiledb_array_free(&array);
tiledb_query_free(&query);
#include <tiledb/tiledb>
using namespace tiledb;
// Create context
Context ctx;
// Open array for writing at a timestamp
Array array(ctx, array_name, TILEDB_WRITE, timestamp);
// Or array(ctx, array_name, TILEDB_WRITE, TILEDB_AES_256_GCM, key, sizeof(key), timestamp)
// for encrypted arrays
// Create the query
Query query(ctx, array);
// ... perform the query
// Close the array
array.close();
import tiledb
# ... create array with required schema
# ... decide the timestamp you would like to write to
with tiledb.open(path, mode='w', ctx=ctx, timestamp=timestamp) as T:
# the data written will be written at `timestamp`
T[:] = A
# 'at' uses Sys.time() from R in seconds, and shifts back 10 minutes
at <- Sys.time() - 10*60
# 'arr' is an already created array, could also be encrypted and carry key
arr <- tiledb_array_open_at(arr, "WRITE", Sys.time() - 600)
# arr is now open for writing, any suitable content can be written the usual way
// Create context
Context ctx = new Context();
// Open array for writing at a timestamp
Array array = new Array(ctx, "<array-uri>", TILEDB_WRITE, timestamp);
// Or new Array(ctx, "<array-uri>", TILEDB_WRITE, TILEDB_AES_256_GCM, key, timestamp)
// for encrypted arrays
// Create the query
Query query(ctx, array);
// ... perform the query
// Close the array
array.close();
// Create context
ctx, _ := tiledb.NewContext(nil)
// Open array for writing
array, _ := tiledb.NewArray(ctx, "array_name")
// Open array for writing at a timestamp
array.OpenAt(TILEDB_WRITE, uint64(time.Now().UnixNano()/1000000))