MCPcopy Create free account
hub / github.com/4paradigm/OpenMLDB / UpdateTableMeta

Method UpdateTableMeta

src/tablet/tablet_impl.cc:3656–3682  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3654}
3655
3656int TabletImpl::UpdateTableMeta(const std::string& path,
3657 ::fedb::api::TableMeta* table_meta,
3658 bool for_add_column) {
3659 std::string full_path = path + "/table_meta.txt";
3660 int fd = open(full_path.c_str(), O_RDONLY);
3661 ::fedb::api::TableMeta old_meta;
3662 if (fd < 0) {
3663 PDLOG(WARNING, "[%s] is not exist", "table_meta.txt");
3664 return 1;
3665 } else {
3666 google::protobuf::io::FileInputStream fileInput(fd);
3667 fileInput.SetCloseOnDelete(true);
3668 if (!google::protobuf::TextFormat::Parse(&fileInput, &old_meta)) {
3669 PDLOG(WARNING, "parse table_meta failed");
3670 return -1;
3671 }
3672 }
3673 // use replicas in LoadRequest
3674 if (!for_add_column) {
3675 old_meta.clear_replicas();
3676 old_meta.MergeFrom(*table_meta);
3677 table_meta->CopyFrom(old_meta);
3678 }
3679 std::string new_name = full_path + "." + ::fedb::base::GetNowTime();
3680 rename(full_path.c_str(), new_name.c_str());
3681 return 0;
3682}
3683
3684int TabletImpl::UpdateTableMeta(const std::string& path,
3685 ::fedb::api::TableMeta* table_meta) {

Callers

nothing calls this directly

Calls 1

GetNowTimeFunction · 0.85

Tested by

no test coverage detected