(#5621) using KeyMayExist instead of Get when visit rocksdb (#5622)

This commit is contained in:
wangbo
2021-04-19 09:25:59 +08:00
committed by GitHub
parent b6c0767754
commit 6f000c2ea4
3 changed files with 18 additions and 5 deletions

View File

@ -102,6 +102,21 @@ OLAPStatus OlapMeta::get(const int column_family_index, const std::string& key,
return OLAP_SUCCESS;
}
bool OlapMeta::key_may_exist(const int column_family_index, const std::string& key,
std::string* value) {
DorisMetrics::instance()->meta_read_request_total->increment(1);
rocksdb::ColumnFamilyHandle* handle = _handles[column_family_index];
int64_t duration_ns = 0;
bool is_exist = false;
{
SCOPED_RAW_TIMER(&duration_ns);
is_exist = _db->KeyMayExist(ReadOptions(), handle, Slice(key), value);
}
DorisMetrics::instance()->meta_read_request_duration_us->increment(duration_ns / 1000);
return is_exist;
}
OLAPStatus OlapMeta::put(const int column_family_index, const std::string& key,
const std::string& value) {
DorisMetrics::instance()->meta_write_request_total->increment(1);

View File

@ -37,6 +37,8 @@ public:
OLAPStatus get(const int column_family_index, const std::string& key, std::string* value);
bool key_may_exist(const int column_family_index, const std::string& key, std::string* value);
OLAPStatus put(const int column_family_index, const std::string& key, const std::string& value);
OLAPStatus remove(const int column_family_index, const std::string& key);

View File

@ -38,11 +38,7 @@ bool RowsetMetaManager::check_rowset_meta(OlapMeta* meta, TabletUid tablet_uid,
const RowsetId& rowset_id) {
std::string key = ROWSET_PREFIX + tablet_uid.to_string() + "_" + rowset_id.to_string();
std::string value;
OLAPStatus s = meta->get(META_COLUMN_FAMILY_INDEX, key, &value);
if (s != OLAP_SUCCESS) {
return false;
}
return true;
return meta->key_may_exist(META_COLUMN_FAMILY_INDEX, key, &value);;
}
OLAPStatus RowsetMetaManager::get_rowset_meta(OlapMeta* meta, TabletUid tablet_uid,