Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
TangSiyang2001 committed Sep 9, 2024
1 parent 876c765 commit 356ef16
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
14 changes: 11 additions & 3 deletions be/src/http/action/compaction_score_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <iterator>
#include <limits>
#include <memory>
#include <ranges>
#include <span>
#include <stdexcept>
#include <string>
Expand All @@ -50,6 +49,7 @@
#include "http/http_status.h"
#include "olap/tablet_fwd.h"
#include "olap/tablet_manager.h"
#include "util/stopwatch.hpp"

namespace doris {

Expand Down Expand Up @@ -102,10 +102,19 @@ struct CloudCompactionScoresAccessor final : CompactionScoresAccessor {

Status sync_meta() {
auto tablets = get_all_tablets();
LOG(INFO) << "start to sync meta from ms";

MonotonicStopWatch stopwatch;
stopwatch.start();

for (const auto& tablet : tablets) {
RETURN_IF_ERROR(tablet->sync_meta());
RETURN_IF_ERROR(tablet->sync_rowsets());
}

stopwatch.stop();
LOG(INFO) << "sync meta finish, time=" << stopwatch.elapsed_time() << "ns";

return Status::OK();
}

Expand Down Expand Up @@ -215,10 +224,9 @@ Status CompactionScoreAction::_handle(size_t top_n, bool sync_meta, std::string*
rapidjson::Document root;
root.SetArray();
auto& allocator = root.GetAllocator();
std::ranges::for_each(scores | std::views::take(top_n), [&root, &allocator](const auto& score) {
std::for_each(scores.begin(), scores.begin() + top_n, [&](const auto& score) {
root.PushBack(jsonfy_tablet_compaction_score(score, allocator), allocator);
});

rapidjson::StringBuffer str_buf;
rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(str_buf);
root.Accept(writer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ suite("test_compaction_score_action") {
for (int i=0;i<backendId_to_backendIP.size();i++){
def beHttpAddress =backendId_to_backendIP.entrySet()[i].getValue()+":"+backendId_to_backendHttpPort.entrySet()[i].getValue()
if (isCloudMode()) {
def (code, text, err) = curl("GET",beHttpAddress+"/api/compaction_score?top_n=1&sync_meta=true")
def (code, text, err) = curl("GET",beHttpAddress+ "/api/compaction_score?top_n=1&sync_meta=true")
def score_str = parseJson(text).get(0).get("compaction_score")
def score = Integer.parseInt(score_str)
assertTrue(score >= 90)
} else {
def (code, text, err) = curl("GET",beHttpAddress+"/api/compaction_score?top_n=1")
def score_str = parseJson(text).get(0).get("compaction_score")
def score = Integer.parseInt(score_str)
assertTrue(score >= 90)
}
def (code, text, err) = curl("GET",beHttpAddress+"/api/compaction_score?top_n=1")
def score_str = parseJson(text).get(0).get("compaction_score")
def score = Integer.parseInt(score_str)
assertTrue(score >= 90)
}

}

0 comments on commit 356ef16

Please sign in to comment.