| 82 | inline size_t PageSize() const { return 1 << m_LogPageSize; } |
| 83 | |
| 84 | inline char const * ReadPage(ReaderT & reader, uint64_t pageNum) |
| 85 | { |
| 86 | bool cached; |
| 87 | std::vector<char> & v = m_Cache.Find(pageNum, cached); |
| 88 | m_Stats.m_CacheHit(cached ? 1 : 0); |
| 89 | if (!cached) |
| 90 | { |
| 91 | if (v.empty()) |
| 92 | v.resize(PageSize()); |
| 93 | uint64_t const pos = pageNum << m_LogPageSize; |
| 94 | reader.Read(pos, &v[0], std::min(PageSize(), static_cast<size_t>(reader.Size() - pos))); |
| 95 | } |
| 96 | return &v[0]; |
| 97 | } |
| 98 | |
| 99 | base::Cache<uint64_t, std::vector<char>> m_Cache; |
| 100 | uint32_t const m_LogPageSize; |