forked from apache/doris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update update udpate
- Loading branch information
Showing
6 changed files
with
204 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# 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. | ||
|
||
# where to put generated libraries | ||
set(LIBRARY_OUTPUT_PATH "${BUILD_DIR}/src/my-tools") | ||
|
||
# where to put generated binaries | ||
set(EXECUTABLE_OUTPUT_PATH "${BUILD_DIR}/src/my-tools") | ||
|
||
add_executable(my_tool | ||
my_tool.cpp | ||
) | ||
|
||
# pch_reuse(my_tool) | ||
|
||
# This permits libraries loaded by dlopen to link to the symbols in the program. | ||
set_target_properties(my_tool PROPERTIES ENABLE_EXPORTS 1) | ||
|
||
target_link_libraries(my_tool | ||
${DORIS_LINK_LIBS} | ||
) | ||
|
||
install(DIRECTORY DESTINATION ${OUTPUT_DIR}/lib/) | ||
install(TARGETS my_tool DESTINATION ${OUTPUT_DIR}/lib/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
// 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 <fmt/format.h> | ||
#include <gen_cpp/olap_file.pb.h> | ||
#include <gflags/gflags.h> | ||
|
||
#include <cstdint> | ||
#include <string> | ||
|
||
#include "common/status.h" | ||
#include "olap/olap_meta.h" | ||
#include "olap/rowset/rowset_meta.h" | ||
#include "olap/rowset/rowset_meta_manager.h" | ||
#include "olap/tablet_meta_manager.h" | ||
|
||
DEFINE_string(operation, "", "valid operation: show"); | ||
DEFINE_string(root_path, "", "root path"); | ||
|
||
std::string get_usage(const std::string& progname) { | ||
std::stringstream ss; | ||
ss << progname << " is the Doris inverted index file tool.\n"; | ||
ss << "Usage:\n"; | ||
ss << "./my_tool"; | ||
return ss.str(); | ||
} | ||
|
||
void print_meta_detail(doris::OlapMeta& meta) { | ||
using namespace doris; | ||
|
||
// rowset meta | ||
int64_t rowset_meta_size_sum {}; | ||
Status res; | ||
// auto load_rowset_func = [&rowset_meta_size_sum](TabletUid tablet_uid, RowsetId rowset_id, | ||
// const std::string& meta_str) -> bool { | ||
// rowset_meta_size_sum += meta_str.size(); | ||
// std::cout << fmt::format("collect rowset meta: rowset_id={}, size={}\n", | ||
// rowset_id.to_string(), meta_str.size()); | ||
// return true; | ||
// }; | ||
|
||
// Status res = RowsetMetaManager::traverse_rowset_metas(&meta, load_rowset_func); | ||
// if (!res.ok()) { | ||
// std::cout << fmt::format("failed to traverse rowset meta.\n"); | ||
// } | ||
|
||
// std::cout << fmt::format("finish collect rowset meta\n"); | ||
|
||
// tablet_meta | ||
int64_t tablet_meta_size_sum {}; | ||
int64_t delete_bitmap_size_sum {}; | ||
std::map<int64_t, int64_t> tablets_delete_bitmap_size; | ||
auto load_tablet_func = [&tablet_meta_size_sum, &delete_bitmap_size_sum, | ||
&tablets_delete_bitmap_size](int64_t tablet_id, int32_t schema_hash, | ||
const std::string& value) -> bool { | ||
tablet_meta_size_sum += value.size(); | ||
std::cout << fmt::format("collect tablet meta: tablet_id={}, size={}\n", tablet_id, | ||
value.size()); | ||
TabletMetaPB tablet_meta_pb; | ||
bool parsed = tablet_meta_pb.ParseFromString(value); | ||
if (!parsed) { | ||
std::cout << fmt::format("failed to parse tablet mete. tablet_id={}\n", tablet_id); | ||
} | ||
|
||
if (tablet_meta_pb.has_delete_bitmap()) { | ||
auto sz = tablet_meta_pb.ByteSizeLong(); | ||
tablets_delete_bitmap_size[tablet_id] = sz; | ||
delete_bitmap_size_sum += sz; | ||
std::cout << fmt::format("collect delete bitmap: tablet_id={}, delete_bitmap_size={)\n", | ||
tablet_id, sz); | ||
} | ||
|
||
return true; | ||
}; | ||
|
||
res = TabletMetaManager::traverse_headers(&meta, load_tablet_func); | ||
if (!res.ok()) { | ||
std::cout << fmt::format("failed to traverse tablet meta.\n"); | ||
} | ||
|
||
std::cout << fmt::format( | ||
" ======================== tablet delete bitmaps size ======================== \n"); | ||
for (const auto& [tablet_id, size] : tablets_delete_bitmap_size) { | ||
std::cout << fmt::format("tablet_id={}, size={}\n", tablet_id, size); | ||
} | ||
|
||
// pending delete bitmaps | ||
std::vector<DeleteBitmapPB> delete_bitmap_pbs; | ||
int64_t pending_delete_bitmap_size_sum {}; | ||
auto collect_delete_bitmap_func = | ||
[&delete_bitmap_pbs, &tablets_delete_bitmap_size, &pending_delete_bitmap_size_sum]( | ||
int64_t tablet_id, int64_t version, const std::string& val) { | ||
DeleteBitmapPB delete_bitmap_pb; | ||
delete_bitmap_pb.ParseFromString(val); | ||
delete_bitmap_pbs.emplace_back(std::move(delete_bitmap_pb)); | ||
tablets_delete_bitmap_size[tablet_id] += val.size(); | ||
pending_delete_bitmap_size_sum += val.size(); | ||
|
||
std::cout << fmt::format( | ||
"collect pending delete bitmap: tablet_id={}, version={} val.size={}\n", | ||
tablet_id, version, val.size()); | ||
|
||
return true; | ||
}; | ||
|
||
res = TabletMetaManager::traverse_delete_bitmap(&meta, collect_delete_bitmap_func); | ||
if (!res.ok()) { | ||
std::cout << fmt::format("failed to traverse delete bitmap.\n"); | ||
} | ||
|
||
std::cout << fmt::format( | ||
" ======================== Summary: ======================== " | ||
"tablet_meta.size={}\nrowset_meta.size={} B\ntablet_meta_size={} " | ||
"B\ndelete_bitmap_size={} B\npending_delete_bitmap_size={} B\n", | ||
tablets_delete_bitmap_size.size(), rowset_meta_size_sum, tablet_meta_size_sum, | ||
delete_bitmap_size_sum, pending_delete_bitmap_size_sum); | ||
} | ||
|
||
int main(int argc, char** argv) { | ||
using namespace doris; | ||
|
||
std::string usage = get_usage(argv[0]); | ||
gflags::SetUsageMessage(usage); | ||
google::ParseCommandLineFlags(&argc, &argv, true); | ||
|
||
if (FLAGS_operation == "show") { | ||
std::string root_path {FLAGS_root_path}; | ||
std::cout << fmt::format("get root_path={}\n", root_path); | ||
OlapMeta meta {root_path}; | ||
std::cout << fmt::format("begin to init OlapMeta, root_path={}\n", root_path); | ||
Status res = meta.init(); | ||
if (!res.ok()) { | ||
std::cout << fmt::format("init OlapMeta failed, open rocksdb failed, path={}", | ||
root_path); | ||
} | ||
std::cout << fmt::format("successfully open RocksDB, path={}\n", meta.get_root_path()); | ||
|
||
print_meta_detail(meta); | ||
} | ||
gflags::ShutDownCommandLineFlags(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters