51 std::lock_guard<std::mutex>
lockGuard(fLock);
52 return RPageRef(AddPage(std::move(
page), key, 1).fPage,
this);
57 std::lock_guard<std::mutex>
lockGuard(fLock);
58 const auto &
entry = AddPage(std::move(
page), key, 0);
59 if (
entry.fRefCounter == 0)
60 fUnusedPages[
entry.fPage.GetClusterInfo().GetId()].emplace(
entry.fPage.GetBuffer());
73 const auto N = fEntries.size();
76 fLookupByBuffer[fEntries[
N - 1].fPage.GetBuffer()] =
entryIdx;
77 itrPageSet = fLookupByKey.find(fEntries[
N - 1].fKey);
82 fEntries[
entryIdx] = std::move(fEntries[
N - 1]);
85 fEntries.resize(
N - 1);
90 if (
page.IsNull())
return;
91 std::lock_guard<std::mutex>
lockGuard(fLock);
97 assert(fEntries[idx].fRefCounter >= 1);
98 if (--fEntries[idx].fRefCounter == 0) {
105 auto itr = fUnusedPages.find(
page.GetClusterInfo().GetId());
107 itr->second.erase(
page.GetBuffer());
108 if (
itr->second.empty())
109 fUnusedPages.erase(
itr);
114 std::lock_guard<std::mutex>
lockGuard(fLock);
126 if (fEntries[
itrEntryIdx->second].fRefCounter == 0)
127 RemoveFromUnusedPages(fEntries[
itrEntryIdx->second].fPage);
136 std::lock_guard<std::mutex>
lockGuard(fLock);
148 if (fEntries[
itrEntryIdx->second].fRefCounter == 0)
149 RemoveFromUnusedPages(fEntries[
itrEntryIdx->second].fPage);
158 std::lock_guard<std::mutex>
lockGuard(fLock);
160 if (
itr == fUnusedPages.
end())
171 fUnusedPages.erase(
itr);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void ErasePage(std::size_t entryIdx, decltype(fLookupByBuffer)::iterator lookupByBufferItr)
Called both by ReleasePage() and by Evict() to remove an unused page from the pool.
void Evict(ROOT::DescriptorId_t clusterId)
Removes unused pages (pages with reference counter 0) from the page pool.
REntry & AddPage(RPage page, const RKey &key, std::int64_t initialRefCounter)
Add a new page to the fLookupByBuffer and fLookupByKey data structures.
RPageRef GetPage(RKey key, ROOT::NTupleSize_t globalIndex)
Tries to find the page corresponding to column and index in the cache.
std::unordered_map< RKey, std::map< RPagePosition, std::size_t >, RKeyHasher > fLookupByKey
Used in GetPage() to find the right page in fEntries.
void PreloadPage(RPage page, RKey key)
Like RegisterPage() but the reference counter is initialized to 0.
RPageRef RegisterPage(RPage page, RKey key)
Adds a new page to the pool.
void RemoveFromUnusedPages(const RPage &page)
Called by GetPage(), when the reference counter increases from zero to one.
std::unordered_map< void *, std::size_t > fLookupByBuffer
Used in ReleasePage() to find the page index in fPages.
std::vector< REntry > fEntries
All cached pages in the page pool.
void ReleasePage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
A page is a slice of a column that is mapped into memory.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
const_iterator begin() const
const_iterator end() const
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Every page in the page pool is annotated with a search key and a reference counter.
Used in fLookupByKey to store both the absolute and the cluster-local page index of the referenced pa...