MCPcopy Create free account
hub / github.com/comaps/comaps / ReadPage

Method ReadPage

libs/coding/reader_cache.hpp:84–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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;

Callers

nothing calls this directly

Calls 5

FindMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
ReadMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected