Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](meta-tool) Fix compile error in meta tool #31457

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions be/src/tools/meta_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "olap/options.h"
#include "olap/rowset/segment_v2/binary_plain_page.h"
#include "olap/rowset/segment_v2/column_reader.h"
#include "olap/storage_engine.h"
#include "olap/tablet_meta.h"
#include "olap/tablet_meta_manager.h"
#include "olap/utils.h"
Expand All @@ -46,6 +47,7 @@

using std::filesystem::path;
using doris::DataDir;
using doris::StorageEngine;
using doris::OlapMeta;
using doris::Status;
using doris::TabletMeta;
Expand Down Expand Up @@ -140,7 +142,7 @@ void delete_meta(DataDir* data_dir) {
std::cout << "delete meta successfully" << std::endl;
}

Status init_data_dir(const std::string& dir, std::unique_ptr<DataDir>* ret) {
Status init_data_dir(StorageEngine& engine, const std::string& dir, std::unique_ptr<DataDir>* ret) {
std::string root_path;
RETURN_IF_ERROR(doris::io::global_local_filesystem()->canonicalize(dir, &root_path));
doris::StorePath path;
Expand All @@ -150,8 +152,7 @@ Status init_data_dir(const std::string& dir, std::unique_ptr<DataDir>* ret) {
return Status::InternalError("parse root path failed");
}

std::unique_ptr<DataDir> p(
new (std::nothrow) DataDir(path.path, path.capacity_bytes, path.storage_medium));
auto p = std::make_unique<DataDir>(engine, path.path, path.capacity_bytes, path.storage_medium);
if (p == nullptr) {
std::cout << "new data dir failed" << std::endl;
return Status::InternalError("new data dir failed");
Expand All @@ -177,6 +178,7 @@ void batch_delete_meta(const std::string& tablet_file) {
int err_num = 0;
int delete_num = 0;
int total_num = 0;
StorageEngine engine(doris::EngineOptions {});
std::unordered_map<std::string, std::unique_ptr<DataDir>> dir_map;
while (std::getline(infile, line)) {
total_num++;
Expand All @@ -198,7 +200,7 @@ void batch_delete_meta(const std::string& tablet_file) {
if (dir_map.find(dir) == dir_map.end()) {
// new data dir, init it
std::unique_ptr<DataDir> data_dir_p;
Status st = init_data_dir(dir, &data_dir_p);
Status st = init_data_dir(engine, dir, &data_dir_p);
if (!st.ok()) {
std::cout << "invalid root path:" << FLAGS_root_path
<< ", error: " << st.to_string() << std::endl;
Expand Down Expand Up @@ -350,8 +352,9 @@ int main(int argc, char** argv) {
return -1;
}

StorageEngine engine(doris::EngineOptions {});
std::unique_ptr<DataDir> data_dir;
Status st = init_data_dir(FLAGS_root_path, &data_dir);
Status st = init_data_dir(engine, FLAGS_root_path, &data_dir);
if (!st.ok()) {
std::cout << "invalid root path:" << FLAGS_root_path << ", error: " << st.to_string()
<< std::endl;
Expand Down
Loading