luwei16 commented on code in PR #38489:
URL: https://github.com/apache/doris/pull/38489#discussion_r1700036853


##########
be/src/http/action/compaction_score_action.cpp:
##########
@@ -0,0 +1,125 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+#include "http/action/compaction_score_action.h"
+
+#include <gen_cpp/Types_types.h>
+#include <glog/logging.h>
+#include <rapidjson/document.h>
+#include <rapidjson/prettywriter.h>
+#include <rapidjson/stringbuffer.h>
+
+#include <cstdint>
+#include <cstdlib>
+#include <exception>
+#include <memory>
+#include <string>
+#include <string_view>
+
+#include "common/status.h"
+#include "http/http_channel.h"
+#include "http/http_headers.h"
+#include "http/http_request.h"
+#include "http/http_status.h"
+#include "olap/olap_common.h"
+#include "olap/tablet_fwd.h"
+#include "olap/tablet_manager.h"
+
+namespace doris {
+
+constexpr std::string_view TABLET_ID = "tablet_id";
+constexpr std::string_view BASE_COMPACTION_SCORE = "base_compaction_score";
+constexpr std::string_view CUMULATIVE_COMPACTION_SCORE = 
"cumu_compaction_score";
+
+CompactionScoreAction::CompactionScoreAction(ExecEnv* exec_env, 
TPrivilegeHier::type hier,
+                                             TPrivilegeType::type type,
+                                             StorageEngine& storage_engine)
+        : HttpHandlerWithAuth(exec_env, hier, type), 
_storage_engine(storage_engine) {}
+
+static rapidjson::Value jsonfy_tablet_compaction_score(
+        const TabletSharedPtr& tablet, rapidjson::MemoryPoolAllocator<>& 
allocator) {
+    rapidjson::Value node;
+    node.SetObject();
+
+    rapidjson::Value tablet_id_key;
+    tablet_id_key.SetString(TABLET_ID.data(), TABLET_ID.length(), allocator);
+    rapidjson::Value tablet_id_val;
+    auto tablet_id_str = std::to_string(tablet->tablet_id());
+    tablet_id_val.SetString(tablet_id_str.c_str(), tablet_id_str.length(), 
allocator);
+
+    auto add_compaction_score = [&tablet, &allocator, &node](std::string_view 
key_name,
+                                                             CompactionType 
type) {
+        rapidjson::Value score_key;
+        score_key.SetString(key_name.data(), key_name.size());
+
+        rapidjson::Value score_val;
+        auto score =

Review Comment:
   no need to distinguish between base and cumu



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to