Skip to content

Commit

Permalink
support multiple CurrentTaskType
Browse files Browse the repository at this point in the history
  • Loading branch information
Axlgrep committed Apr 24, 2018
1 parent a27a04c commit 34ef0cf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 12 deletions.
5 changes: 5 additions & 0 deletions include/nemo_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ enum OPERATION {
kDEL_KEY,
kCLEAN_RANGE,
kCLEAN_ALL,
kCLEAN_KV,
kCLEAN_HASH,
kCLEAN_ZSET,
kCLEAN_SET,
kCLEAN_LIST,
};

// Usage Type
Expand Down
39 changes: 27 additions & 12 deletions src/nemo_admin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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";
Expand Down

0 comments on commit 34ef0cf

Please sign in to comment.