chaoyli commented on a change in pull request #1337: Be refactor optimize meta
tool new
URL: https://github.com/apache/incubator-doris/pull/1337#discussion_r295265491
##########
File path: be/src/tools/meta_tool.cpp
##########
@@ -29,144 +28,143 @@
#include "olap/tablet_meta_manager.h"
#include "olap/olap_define.h"
#include "olap/tablet_meta.h"
-#include "olap/olap_meta.h"
#include "olap/utils.h"
#include "json2pb/pb_to_json.h"
+using boost::filesystem::canonical;
+using boost::filesystem::path;
using doris::DataDir;
+using doris::OLAP_SUCCESS;
using doris::OlapMeta;
-using doris::TabletMetaManager;
-using doris::TabletMeta;
using doris::OLAPStatus;
-using doris::OLAP_SUCCESS;
using doris::Status;
+using doris::TabletMeta;
+using doris::TabletMetaManager;
-const std::string HEADER_PREFIX = "hdr_";
+const std::string HEADER_PREFIX = "tabletmeta_";
-DEFINE_string(root_path, "./", "storage root path");
-DEFINE_string(operation, "get_header",
- "valid operation: get_header, flag, load_header, delete_header,
rollback, show_header");
-DEFINE_int64(tablet_id, 0, "tablet_id for header operation");
-DEFINE_int32(schema_hash, 0, "schema_hash for header operation");
-DEFINE_string(json_header_path, "", "json header file path");
-DEFINE_string(pb_header_path, "", "pb header file path");
+DEFINE_string(root_path, "", "storage root path");
+DEFINE_string(operation, "get_meta",
+ "valid operation: get_meta, flag, load_meta, delete_meta,
show_meta");
+DEFINE_int64(tablet_id, 0, "tablet_id for tablet meta");
+DEFINE_int32(schema_hash, 0, "schema_hash for tablet meta");
+DEFINE_string(json_meta_path, "", "absolute json meta file path");
+DEFINE_string(pb_meta_path, "", "pb meta file path");
-void print_usage(std::string progname) {
- std::cout << progname << " is the Doris File tool." << std::endl;
- std::cout << "Usage:" << std::endl;
- std::cout << "./meta_tool --operation=get_header --tablet_id=tabletid
--schema_hash=schemahash" << std::endl;
- std::cout << "./meta_tool --operation=flag" << std::endl;
- std::cout << "./meta_tool --operation=load_header --json_header_path=path"
<< std::endl;
- std::cout << "./meta_tool --operation=delete_header --tablet_id=tabletid
--schema_hash=schemahash" << std::endl;
- std::cout << "./meta_tool --root_path=rootpath --operation=rollback" <<
std::endl;
- std::cout << "./meta_tool --operation=show_header --pb_header_path=path"
<< std::endl;
+std::string get_usage(std::string progname) {
+ std::stringstream ss;
+ ss << progname << " is the Doris BE Meta tool.\n";
+ ss << "Stop BE first before use this tool.\n";
+ ss << "Usage:\n";
+ ss << "./meta_tool --operation=get_meta --root_path=/path/to/storage/path
--tablet_id=tabletid --schema_hash=schemahash\n";
+ ss << "./meta_tool --operation=load_meta --root_path=/path/to/storage/path
--json_meta_path=path\n";
+ ss << "./meta_tool --operation=delete_meta
--root_path=/path/to/storage/path --tablet_id=tabletid
--schema_hash=schemahash\n";
+ ss << "./meta_tool --operation=show_meta --pb_meta_path=path\n";
+ return ss.str();
}
-int main(int argc, char** argv) {
- google::ParseCommandLineFlags(&argc, &argv, true);
+void show_meta() {
+ TabletMeta tablet_meta;
+ OLAPStatus s = tablet_meta.create_from_file(FLAGS_pb_meta_path);
+ if (s != OLAP_SUCCESS){
+ std::cout << "load pb meta file:" << FLAGS_pb_meta_path << " failed"
+ << ", status:" << s << std::endl;
+ return;
+ }
+ std::string json_meta;
+ json2pb::Pb2JsonOptions json_options;
+ json_options.pretty_json = true;
+ doris::TabletMetaPB tablet_meta_pb;
+ tablet_meta.to_meta_pb(&tablet_meta_pb);
+ json2pb::ProtoMessageToJson(tablet_meta_pb, &json_meta, json_options);
+ std::cout << "tablet meta:" << std::endl;
Review comment:
this line is not necessary.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]