neverchanje commented on a change in pull request #688:
URL: https://github.com/apache/incubator-pegasus/pull/688#discussion_r566777738
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,19 +23,49 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts,
uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:",
"stored_tts_url_info:"};
Review comment:
```suggestion
const std::vector<std::string> cleaned_hash_key_prefix =
{"raw_tts_audio:", "stored_tts_url_info:"};
```
##########
File path: src/server/key_ttl_compaction_filter.h
##########
@@ -23,12 +23,38 @@
#include <atomic>
#include <rocksdb/compaction_filter.h>
#include <rocksdb/merge_operator.h>
+#include <base/pegasus_key_schema.h>
#include "base/pegasus_utils.h"
#include "base/pegasus_value_schema.h"
namespace pegasus {
namespace server {
+inline bool need_clean_key(const rocksdb::Slice &key, uint32_t expire_ts,
uint32_t now_ts)
+{
+ std::vector<std::string> cleaned_hash_key_prefix = {"raw_tts_audio:",
"stored_tts_url_info:"};
+
+ uint32_t oneday_sec = 24 * 60 * 60;
+ // includes expire_tx == 0
+ if (expire_ts < now_ts + 3 * oneday_sec) {
+ return false;
+ }
+
+ std::string hash_key, sort_key;
+ pegasus_restore_key(dsn::blob(key.data(), 0, key.size()), hash_key,
sort_key);
+ for (const auto &key_prefix : cleaned_hash_key_prefix) {
+ if (hash_key.length() >= key_prefix.length() &&
+ 0 == hash_key.compare(0, key_prefix.length(), key_prefix)) {
+ static int count = 0;
+ if (count++ / 1000 == 0) {
Review comment:
```suggestion
if (count++ % 1000 == 0) {
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]