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

Method Open

src/leveldb/persistent_cache/persistent_cache_impl.cc:167–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167Status PersistentCacheImpl::Open() {
168 Status status;
169
170 assert(!size_.Get());
171
172 // Check the validity of the options
173 status = opt_.ValidateSettings();
174 assert(status.ok());
175 if (!status.ok()) {
176 LEVELDB_LOG("Invalid persistent cache options.\n");
177 return status;
178 }
179
180 // Create base directory
181 status = opt_.env->CreateDir(opt_.path);
182 if (!status.ok()) {
183 LEVELDB_LOG("Error creating directory %s. %s.\n", opt_.path.c_str(), status.ToString().c_str());
184 return status;
185 }
186
187 // Create meta directory
188 status = opt_.env->CreateDir(GetMetaPath());
189 assert(status.ok());
190 if (!status.ok()) {
191 LEVELDB_LOG("Error creating directory %s. %s.\n", GetMetaPath().c_str(),
192 status.ToString().c_str());
193 return status;
194 }
195
196 status = metadata_.Init(&writer_cache_id_, this);
197 if (!status.ok()) {
198 LEVELDB_LOG("Init metadata failed, reason: %s.\n", status.ToString().c_str());
199 return status;
200 }
201 metadata_size_.Set(metadata_.GetDBSize());
202 if (opt_.transfer_flash_env_files) {
203 PullEnvFlashFiles();
204 }
205 // Clean up non-cache file
206 CleanupCacheFolder(GetCachePath());
207
208 LEVELDB_LOG("Persistent Cache Init Done, writer_cache_id: %lu\n", writer_cache_id_);
209
210 return Status::OK();
211}
212
213Status PersistentCacheImpl::Read(const Slice& key, size_t offset, size_t length, Slice* content,
214 SstDataScratch* scratch) {

Callers 1

NewPersistentCacheFunction · 0.45

Calls 8

ValidateSettingsMethod · 0.80
GetDBSizeMethod · 0.80
GetMethod · 0.45
okMethod · 0.45
CreateDirMethod · 0.45
ToStringMethod · 0.45
InitMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected