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

Method OpenTableWithCache

src/sdk/http/http.cc:94–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 google::protobuf::Closure* done);
93
94 Table* OpenTableWithCache(const std::string& tablename, ErrorCode* err) {
95 MutexLock l(&mutex_);
96 std::map<std::string, tera::Table*>::iterator it = tables_.find(tablename);
97 if (it == tables_.end()) {
98 mutex_.Unlock();
99 Table* table = client_->OpenTable(tablename, err);
100 mutex_.Lock();
101 if (table == NULL) {
102 VLOG(20) << "[OpenTableWithCache] open table failed:" << tablename << " for "
103 << err->GetReason();
104 return NULL;
105 }
106 VLOG(25) << "[OpenTableWithCache] open table done:" << tablename;
107 tables_[tablename] = table;
108 return table;
109 } else {
110 VLOG(25) << "[OpenTableWithCache] open table(cached):" << tablename;
111 return it->second;
112 }
113 }
114
115 private:
116 mutable Mutex mutex_;

Callers

nothing calls this directly

Calls 4

UnlockMethod · 0.45
OpenTableMethod · 0.45
LockMethod · 0.45
GetReasonMethod · 0.45

Tested by

no test coverage detected