MCPcopy Create free account
hub / github.com/baidu/tera / ReadMetaTabletFromFile

Function ReadMetaTabletFromFile

src/admincli.cc:740–785  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

738}
739
740int ReadMetaTabletFromFile(const std::string& filename) {
741 std::ifstream ifs(filename.c_str(), std::ofstream::binary);
742 if (!ifs.is_open()) {
743 LOG(INFO) << "fail to open file " << filename << " for read";
744 return -1;
745 }
746
747 std::string key, value;
748 TabletMeta meta;
749 std::pair<std::string, std::string> keyrange_bak;
750 std::string path_bak;
751 std::string startkey_bak;
752 std::string endkey_bak;
753
754 while (ReadMetaFromStream(ifs, &key, &value)) {
755 if (key.empty()) {
756 return 0;
757 }
758 char first_key_char = key[0];
759 if (first_key_char == '~' || first_key_char == '@' || first_key_char == '|') {
760 continue;
761 } else if (first_key_char > '@') {
762 ParseMetaTableKeyValue(key, value, &meta);
763
764 if (meta.table_name() == FLAGS_tera_master_meta_table_name) {
765 LOG(INFO) << "ignore meta tablet record in meta table";
766 } else {
767 path_bak = meta.path();
768 startkey_bak = meta.key_range().key_start();
769 endkey_bak = meta.key_range().key_end();
770
771 auto it = g_map_bak.find(path_bak);
772 if (it == g_map_bak.end()) {
773 keyrange_bak = make_pair(startkey_bak, endkey_bak);
774 g_map_bak.insert(make_pair(path_bak, keyrange_bak));
775 LOG(INFO) << "read from meta bak file: path" << path_bak << "start" << startkey_bak
776 << "end" << endkey_bak;
777 }
778 }
779 }
780 }
781
782 ifs.close();
783 LOG(INFO) << "restore meta tablet from meta bak file succ";
784 return 0;
785}
786
787int DfsListDir(const std::string& dir_name, std::vector<std::string>* paths) {
788 struct stat fstat;

Callers 1

MetaDiffOpFunction · 0.85

Calls 5

ReadMetaFromStreamFunction · 0.85
ParseMetaTableKeyValueFunction · 0.85
insertMethod · 0.80
closeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected