online delete for postgres working

This commit is contained in:
CJ Cobb
2021-05-13 18:51:34 +00:00
parent 24816c021d
commit 0babf5bc44
3 changed files with 79 additions and 92 deletions

View File

@@ -1359,6 +1359,16 @@ CassandraBackend::open(bool readOnly)
? config_["threads"].as_int64()
: std::thread::hardware_concurrency();
int ttl = config_.contains("ttl") ? config_["ttl"].as_int64() * 2 : 0;
int keysTtl, keysIncr = pow(2, indexer_.getKeyShift()) * 4 * 2;
while (keysTtl < ttl)
{
keysTtl += keysIncr;
}
int booksTtl, booksIncr = pow(2, indexer_.getBookShift()) * 4 * 2;
while (booksTtl < ttl)
{
booksTtl += booksIncr;
}
rc = cass_cluster_set_num_threads_io(cluster, threads);
if (rc != CASS_OK)
@@ -1530,7 +1540,9 @@ CassandraBackend::open(bool readOnly)
query.str("");
query << "CREATE TABLE IF NOT EXISTS " << tablePrefix << "keys"
<< " ( sequence bigint, key blob, PRIMARY KEY "
"(sequence, key))";
"(sequence, key))"
" WITH default_time_to_live = "
<< keysTtl;
if (!executeSimpleStatement(query.str()))
continue;
@@ -1546,7 +1558,8 @@ CassandraBackend::open(bool readOnly)
"blob>, PRIMARY KEY "
"((book, sequence), quality_key)) WITH CLUSTERING ORDER BY "
"(quality_key "
"ASC)";
"ASC) AND default_time_to_live = "
<< booksTtl;
if (!executeSimpleStatement(query.str()))
continue;
query.str("");