diff --git a/include/nemo_const.h b/include/nemo_const.h index c0c3980..19c182d 100644 --- a/include/nemo_const.h +++ b/include/nemo_const.h @@ -32,6 +32,11 @@ enum OPERATION { kDEL_KEY, kCLEAN_RANGE, kCLEAN_ALL, + kCLEAN_KV, + kCLEAN_HASH, + kCLEAN_ZSET, + kCLEAN_SET, + kCLEAN_LIST, }; // Usage Type diff --git a/src/nemo_admin.cc b/src/nemo_admin.cc index f2c11c7..cd6d4f3 100644 --- a/src/nemo_admin.cc +++ b/src/nemo_admin.cc @@ -516,27 +516,32 @@ Status Nemo::DoCompact(DBType type) { return Status::InvalidArgument(""); } - current_task_type_ = OPERATION::kCLEAN_ALL; - Status s; rocksdb::CompactRangeOptions ops; ops.exclusive_manual_compaction = false; - if (type == kALL || type == kKV_DB) { + if (type == kKV_DB) { + current_task_type_ = OPERATION::kCLEAN_KV; + s = kv_db_->CompactRange(ops, NULL, NULL); + } else if (type == kHASH_DB) { + current_task_type_ = OPERATION::kCLEAN_HASH; + s = hash_db_->CompactRange(ops, NULL, NULL); + } else if (type == kZSET_DB) { + current_task_type_ = OPERATION::kCLEAN_ZSET; + s = zset_db_->CompactRange(ops, NULL, NULL); + } else if (type == kSET_DB) { + current_task_type_ = OPERATION::kCLEAN_SET; + s = set_db_->CompactRange(ops, NULL, NULL); + } else if (type == kLIST_DB) { + current_task_type_ = OPERATION::kCLEAN_LIST; + s = list_db_->CompactRange(ops, NULL, NULL); + } else { + current_task_type_ = OPERATION::kCLEAN_ALL; s = kv_db_->CompactRange(ops, NULL, NULL); - } - if (type == kALL || type == kHASH_DB) { s = hash_db_->CompactRange(ops, NULL, NULL); - } - if (type == kALL || type == kZSET_DB) { s = zset_db_->CompactRange(ops, NULL, NULL); - } - if (type == kALL || type == kSET_DB) { s = set_db_->CompactRange(ops, NULL, NULL); - } - if (type == kALL || type == kLIST_DB) { s = list_db_->CompactRange(ops, NULL, NULL); } - current_task_type_ = OPERATION::kNONE_OP; return s; } @@ -560,6 +565,16 @@ std::string Nemo::GetCurrentTaskType() { return "Key"; case kCLEAN_ALL: return "All"; + case kCLEAN_KV: + return "String"; + case kCLEAN_HASH: + return "Hash"; + case kCLEAN_ZSET: + return "ZSet"; + case kCLEAN_SET: + return "Set"; + case kCLEAN_LIST: + return "List"; case kNONE_OP: default: return "No";