gavinchou commented on code in PR #39208:
URL: https://github.com/apache/doris/pull/39208#discussion_r1713382543
##########
cloud/src/meta-service/meta_service_http.cpp:
##########
Review Comment:
add usage and an example to the PR description
curl ...
##########
cloud/src/meta-service/meta_service_http.cpp:
##########
@@ -350,6 +355,70 @@ static HttpResponse process_get_value(MetaServiceImpl*
service, brpc::Controller
return process_http_get_value(service->txn_kv().get(),
ctrl->http_request().uri());
}
+// show all key ranges and their count.
+static HttpResponse process_show_meta_ranges(MetaServiceImpl* service,
brpc::Controller* ctrl) {
+ auto txn_kv = std::dynamic_pointer_cast<FdbTxnKv>(service->txn_kv());
+ if (!txn_kv) {
+ return http_json_reply(MetaServiceCode::INVALID_ARGUMENT,
+ "this method only support fdb txn kv");
+ }
+
+ std::vector<std::string> partition_boundaries;
+ TxnErrorCode code =
txn_kv->get_partition_boundaries(&partition_boundaries);
+ if (code != TxnErrorCode::TXN_OK) {
+ auto msg = fmt::format("failed to get boundaries, code={}", code);
+ return http_json_reply(MetaServiceCode::UNDEFINED_ERR, msg);
+ }
+
+ std::unordered_map<std::string, size_t> partition_count;
Review Comment:
what does a partition mean?
also add comment for the map<>
##########
cloud/src/meta-service/txn_kv.cpp:
##########
@@ -78,12 +79,67 @@ TxnErrorCode
FdbTxnKv::create_txn(std::unique_ptr<Transaction>* txn) {
return ret;
}
+TxnErrorCode
FdbTxnKv::create_txn_with_system_access(std::unique_ptr<Transaction>* txn) {
+ auto t = std::make_unique<fdb::Transaction>(database_);
+ TxnErrorCode code = t->init();
+ if (code == TxnErrorCode::TXN_OK) {
+ code = t->enable_access_system_keys();
+ }
+ if (code != TxnErrorCode::TXN_OK) {
+ LOG(WARNING) << "failed to init txn, ret=" << code;
+ }
+
+ *txn = std::move(t);
+ return TxnErrorCode::TXN_OK;
+}
+
std::unique_ptr<FullRangeGetIterator> FdbTxnKv::full_range_get(std::string
begin, std::string end,
FullRangeGetIteratorOptions opts) {
return std::make_unique<fdb::FullRangeGetIterator>(std::move(begin),
std::move(end),
std::move(opts));
}
+TxnErrorCode FdbTxnKv::get_partition_boundaries(std::vector<std::string>*
boundaries) {
+ boundaries->clear();
+
+ std::unique_ptr<Transaction> txn;
+ TxnErrorCode code = create_txn_with_system_access(&txn);
+ if (code != TxnErrorCode::TXN_OK) {
+ return code;
+ }
+
+ std::string prefix(boundary_prefix());
+ std::string begin_key = prefix + "/";
Review Comment:
what is the magic "/" and "0"?
##########
cloud/src/meta-service/txn_kv.cpp:
##########
@@ -78,12 +79,67 @@ TxnErrorCode
FdbTxnKv::create_txn(std::unique_ptr<Transaction>* txn) {
return ret;
}
+TxnErrorCode
FdbTxnKv::create_txn_with_system_access(std::unique_ptr<Transaction>* txn) {
+ auto t = std::make_unique<fdb::Transaction>(database_);
+ TxnErrorCode code = t->init();
+ if (code == TxnErrorCode::TXN_OK) {
+ code = t->enable_access_system_keys();
+ }
+ if (code != TxnErrorCode::TXN_OK) {
Review Comment:
what if the code is not OK when calling `t->init()`?
line 93 seems incorrect.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]