MCPcopy Create free account
hub / github.com/ByConity/ByConity / initCacheFromFileSystem

Method initCacheFromFileSystem

src/Storages/DiskCache/KeyIndexFileCache.cpp:147–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145KeyIndexFileCache::~KeyIndexFileCache() = default;
146
147void KeyIndexFileCache::initCacheFromFileSystem()
148{
149 LOG_INFO(log, "Initializing KeyIndexFileCache...");
150 Poco::File(rep->base_path).createDirectories();
151
152 Stopwatch timer;
153 int num_loaded = 0;
154 Poco::DirectoryIterator end;
155 for (auto it = Poco::DirectoryIterator(rep->base_path); it != end; ++it)
156 {
157 auto & filename = it.name();
158 if (startsWith(filename, "TMP_"))
159 {
160 LOG_TRACE(log, "Removing temporary file {}", it->path());
161 Poco::File(it->path()).remove();
162 }
163 else
164 {
165 String key;
166 UInt64 size;
167 if (tryParseCacheFileName(filename, key, size))
168 {
169 rep->cache.set(key, CacheValue::Cached(size));
170 num_loaded++;
171 }
172 else
173 {
174 LOG_WARNING(log, "Unrecognized name for unique key index cache file: {}", filename);
175 }
176 }
177 }
178 LOG_INFO(log, "Initialized KeyIndexFileCache with {} entries in {} ms", num_loaded, timer.elapsedMilliseconds());
179}
180
181int KeyIndexFileCache::get(const IndexFile::RemoteFileInfo & file)
182{

Callers

nothing calls this directly

Calls 10

DirectoryIteratorClass · 0.85
tryParseCacheFileNameFunction · 0.85
FileClass · 0.50
startsWithFunction · 0.50
createDirectoriesMethod · 0.45
nameMethod · 0.45
pathMethod · 0.45
removeMethod · 0.45
setMethod · 0.45
elapsedMillisecondsMethod · 0.45

Tested by

no test coverage detected