Skip to content

Commit ab8be40

Browse files
committed
modify delete_bitmap_action
1 parent 637b433 commit ab8be40

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

be/src/http/action/delete_bitmap_action.cpp

+32-17
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ DeleteBitmapAction::DeleteBitmapAction(DeleteBitmapActionType ctype, ExecEnv* ex
6767
_engine(engine),
6868
_delete_bitmap_action_type(ctype) {}
6969

70-
static Status _check_param(HttpRequest* req, uint64_t* tablet_id) {
70+
static Status _check_param(HttpRequest* req, uint64_t* tablet_id, bool* verbose) {
7171
const auto& req_tablet_id = req->param(TABLET_ID_KEY);
7272
if (req_tablet_id.empty()) {
7373
return Status::InternalError("tablet id is empty!");
@@ -77,17 +77,18 @@ static Status _check_param(HttpRequest* req, uint64_t* tablet_id) {
7777
} catch (const std::exception& e) {
7878
return Status::InternalError("convert tablet_id failed, {}", e.what());
7979
}
80+
if (*tablet_id == 0) {
81+
return Status::InternalError("check param failed: invalid tablet_id");
82+
}
83+
*verbose = iequal(req->param("verbose"), "true");
8084
return Status::OK();
8185
}
8286

8387
Status DeleteBitmapAction::_handle_show_local_delete_bitmap_count(HttpRequest* req,
8488
std::string* json_result) {
8589
uint64_t tablet_id = 0;
86-
// check & retrieve tablet_id from req if it contains
87-
RETURN_NOT_OK_STATUS_WITH_WARN(_check_param(req, &tablet_id), "check param failed");
88-
if (tablet_id == 0) {
89-
return Status::InternalError("check param failed: missing tablet_id");
90-
}
90+
bool verbose = false;
91+
RETURN_NOT_OK_STATUS_WITH_WARN(_check_param(req, &tablet_id, &verbose), "check param failed");
9192

9293
BaseTabletSPtr tablet = nullptr;
9394
if (config::is_cloud_mode()) {
@@ -98,17 +99,33 @@ Status DeleteBitmapAction::_handle_show_local_delete_bitmap_count(HttpRequest* r
9899
if (tablet == nullptr) {
99100
return Status::NotFound("Tablet not found. tablet_id={}", tablet_id);
100101
}
101-
auto count = tablet->tablet_meta()->delete_bitmap().get_delete_bitmap_count();
102-
auto cardinality = tablet->tablet_meta()->delete_bitmap().cardinality();
103-
auto size = tablet->tablet_meta()->delete_bitmap().get_size();
104-
LOG(INFO) << "show_local_delete_bitmap_count,tablet_id=" << tablet_id << ",count=" << count
105-
<< ",cardinality=" << cardinality << ",size=" << size;
106-
102+
auto dm = tablet->tablet_meta()->delete_bitmap().snapshot();
103+
auto count = dm.get_delete_bitmap_count();
104+
auto cardinality = dm.cardinality();
105+
auto size = dm.get_size();
106+
LOG(INFO) << "show_local_delete_bitmap_count for tablet_id=" << tablet_id << ", count=" << count
107+
<< ", cardinality=" << cardinality << ", size=" << size;
107108
rapidjson::Document root;
108109
root.SetObject();
109110
root.AddMember("delete_bitmap_count", count, root.GetAllocator());
110111
root.AddMember("cardinality", cardinality, root.GetAllocator());
111112
root.AddMember("size", size, root.GetAllocator());
113+
if (verbose) {
114+
rapidjson::Document dm_arr;
115+
dm_arr.SetArray();
116+
for (auto& [id, bitmap] : dm.delete_bitmap) {
117+
auto& [rowset_id, segment_id, version] = id;
118+
std::stringstream ss;
119+
ss << "rowset: " << rowset_id.to_string() << ", segment: " << segment_id
120+
<< ", version: " << version << ". cardinality: " << bitmap.cardinality()
121+
<< ", size: " << bitmap.getSizeInBytes();
122+
std::string str = ss.str();
123+
rapidjson::Value value;
124+
value.SetString(str.c_str(), cast_set<uint32_t>(str.length()), dm_arr.GetAllocator());
125+
dm_arr.PushBack(value, dm_arr.GetAllocator());
126+
}
127+
root.AddMember("delete_bitmap", dm_arr, root.GetAllocator());
128+
}
112129

113130
// to json string
114131
rapidjson::StringBuffer strbuf;
@@ -122,11 +139,9 @@ Status DeleteBitmapAction::_handle_show_local_delete_bitmap_count(HttpRequest* r
122139
Status DeleteBitmapAction::_handle_show_ms_delete_bitmap_count(HttpRequest* req,
123140
std::string* json_result) {
124141
uint64_t tablet_id = 0;
125-
// check & retrieve tablet_id from req if it contains
126-
RETURN_NOT_OK_STATUS_WITH_WARN(_check_param(req, &tablet_id), "check param failed");
127-
if (tablet_id == 0) {
128-
return Status::InternalError("check param failed: missing tablet_id");
129-
}
142+
bool verbose = false;
143+
RETURN_NOT_OK_STATUS_WITH_WARN(_check_param(req, &tablet_id, &verbose), "check param failed");
144+
130145
TabletMetaSharedPtr tablet_meta;
131146
auto st = _engine.to_cloud().meta_mgr().get_tablet_meta(tablet_id, &tablet_meta);
132147
if (!st.ok()) {

0 commit comments

Comments
 (0)