Review fix

This commit is contained in:
Alexey Milovidov 2021-03-28 22:15:13 +03:00
parent 7cc6eeff0d
commit 15b41fd110
2 changed files with 9 additions and 9 deletions

View File

@ -27,7 +27,7 @@ MMapReadBufferFromFileWithCache::MMapReadBufferFromFileWithCache(
mapped = cache.getOrSet(cache.hash(file_name, offset, length), [&]
{
return std::make_shared<MappedFile>(file_name, offset, length);
}).first;
});
init();
}
@ -38,7 +38,7 @@ MMapReadBufferFromFileWithCache::MMapReadBufferFromFileWithCache(
mapped = cache.getOrSet(cache.hash(file_name, offset, -1), [&]
{
return std::make_shared<MappedFile>(file_name, offset);
}).first;
});
init();
}

View File

@ -44,16 +44,16 @@ public:
return key;
}
MappedPtr get(const Key & key)
template <typename LoadFunc>
MappedPtr getOrSet(const Key & key, LoadFunc && load)
{
MappedPtr res = Base::get(key);
if (res)
ProfileEvents::increment(ProfileEvents::MappedFileCacheHits);
else
auto result = Base::getOrSet(key, load);
if (result.second)
ProfileEvents::increment(ProfileEvents::MappedFileCacheMisses);
else
ProfileEvents::increment(ProfileEvents::MappedFileCacheHits);
return res;
return result.first;
}
};