torwig commented on code in PR #2174:
URL: https://github.com/apache/kvrocks/pull/2174#discussion_r1527465445
##########
src/search/indexer.cc:
##########
@@ -38,7 +38,7 @@ StatusOr<FieldValueRetriever>
FieldValueRetriever::Create(SearchOnDataType type,
Hash db(storage, ns);
std::string ns_key = db.AppendNamespacePrefix(key);
HashMetadata metadata(false);
- auto s = db.GetMetadata(ns_key, &metadata);
+ auto s = db.GetMetadata(Database::GetOptions{}, ns_key, &metadata);
Review Comment:
From the perspective that we use the same snapshot to retrieve the metadata
and perform other read-related work down the code, the change LGTM.
##########
src/storage/redis_db.cc:
##########
@@ -84,25 +84,25 @@ rocksdb::Status Database::ParseMetadata(RedisTypes types,
Slice *bytes, Metadata
return s;
}
-rocksdb::Status Database::GetMetadata(RedisTypes types, const Slice &ns_key,
Metadata *metadata) {
+rocksdb::Status Database::GetMetadata(GetOptions options, RedisTypes types,
const Slice &ns_key, Metadata *metadata) {
std::string raw_value;
Slice rest;
- return GetMetadata(types, ns_key, &raw_value, metadata, &rest);
+ return GetMetadata(options, types, ns_key, &raw_value, metadata, &rest);
}
-rocksdb::Status Database::GetMetadata(RedisTypes types, const Slice &ns_key,
std::string *raw_value, Metadata *metadata,
+rocksdb::Status Database::GetMetadata(GetOptions options, RedisTypes types,
const Slice &ns_key, std::string *raw_value, Metadata *metadata,
Slice *rest) {
- auto s = GetRawMetadata(ns_key, raw_value);
+ auto s = GetRawMetadata(options, ns_key, raw_value);
*rest = *raw_value;
if (!s.ok()) return s;
return ParseMetadata(types, rest, metadata);
}
-rocksdb::Status Database::GetRawMetadata(const Slice &ns_key, std::string
*bytes) {
- LatestSnapShot ss(storage_);
- rocksdb::ReadOptions read_options;
- read_options.snapshot = ss.GetSnapShot();
- return storage_->Get(read_options, metadata_cf_handle_, ns_key, bytes);
+rocksdb::Status Database::GetRawMetadata(GetOptions options, const Slice
&ns_key, std::string *bytes) {
+ rocksdb::ReadOptions opts;
Review Comment:
That's a good question. We obtained a snapshot, got only the metadata from
it and then threw it away.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]