34 assert(fLookupByBuffer.count(
page.GetBuffer()) == 0);
54 fCounters->fNPage.Inc();
60 std::lock_guard<std::mutex>
lockGuard(fLock);
61 return RPageRef(AddPage(std::move(
page), key, 1).fPage,
this);
66 std::lock_guard<std::mutex>
lockGuard(fLock);
67 const auto &
entry = AddPage(std::move(
page), key, 0);
68 if (
entry.fRefCounter == 0)
69 AddToUnusedPages(
entry.fPage);
82 const auto N = fEntries.size();
85 fLookupByBuffer[fEntries[
N - 1].fPage.GetBuffer()] =
entryIdx;
86 itrPageSet = fLookupByKey.find(fEntries[
N - 1].fKey);
91 fEntries[
entryIdx] = std::move(fEntries[
N - 1]);
94 fCounters->fNPage.Dec();
95 fEntries.resize(
N - 1);
100 if (
page.IsNull())
return;
101 std::lock_guard<std::mutex>
lockGuard(fLock);
107 assert(fEntries[idx].fRefCounter >= 1);
108 if (--fEntries[idx].fRefCounter == 0) {
109 if (fPageSource.GetPinnedClusters().count(
page.GetClusterInfo().GetId()) > 0) {
110 AddToUnusedPages(
page);
119 fUnusedPages[
page.GetClusterInfo().GetId()].emplace(
page.GetBuffer());
124 auto itr = fUnusedPages.find(
page.GetClusterInfo().GetId());
126 itr->second.erase(
page.GetBuffer());
127 if (
itr->second.empty())
128 fUnusedPages.erase(
itr);
133 std::lock_guard<std::mutex>
lockGuard(fLock);
145 if (fEntries[
itrEntryIdx->second].fRefCounter == 0)
146 RemoveFromUnusedPages(fEntries[
itrEntryIdx->second].fPage);
155 std::lock_guard<std::mutex>
lockGuard(fLock);
167 if (fEntries[
itrEntryIdx->second].fRefCounter == 0)
168 RemoveFromUnusedPages(fEntries[
itrEntryIdx->second].fPage);
177 std::lock_guard<std::mutex>
lockGuard(fLock);
179 if (
itr == fUnusedPages.
end())
190 fUnusedPages.erase(
itr);
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
A thread-safe integral performance counter.
CounterPtrT MakeCounter(const std::string &name, Args &&... args)
std::unique_ptr< RCounters > fCounters
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.
ROOT::Experimental::Detail::RNTupleMetrics fMetrics
The page pool counters are observed by the page source.
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.
RPagePool(RPageSource &pageSource)
void AddToUnusedPages(const RPage &page)
Called by PreloadPage() if the page at hand is new and thus added with ref counter 0.
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.
void ReleasePage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
Abstract interface to read data from an ntuple.
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.
Performance counters that get registered in fMetrics.
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...