Skip to content

Commit

Permalink
(apache#5621) using KeyMayExist instead of Get when visit rocksdb (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
wangbo authored Apr 19, 2021
1 parent b6c0767 commit 6f000c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
15 changes: 15 additions & 0 deletions be/src/olap/olap_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions be/src/olap/olap_meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class OlapMeta {

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);
Expand Down
6 changes: 1 addition & 5 deletions be/src/olap/rowset/rowset_meta_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6f000c2

Please sign in to comment.