16#ifndef ROOT7_RPagePool
17#define ROOT7_RPagePool
28#include <unordered_map>
29#include <unordered_set>
58 return this->fColumnId ==
other.fColumnId && this->fInMemoryType ==
other.fInMemoryType;
70 auto seed = std::hash<ROOT::DescriptorId_t>()(k.
fColumnId);
71 return seed ^ (std::hash<std::type_index>()(k.
fInMemoryType) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
129 std::unordered_map<ROOT::DescriptorId_t, std::unordered_set<void *>>
fUnusedPages;
203 if (
this != &
other) {
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
A thread-safe cache of pages loaded from the page source.
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.
std::unordered_map< ROOT::DescriptorId_t, std::unordered_set< void * > > fUnusedPages
Remembers pages with reference counter 0, organized by the page's cluster id.
RPagePool(const RPagePool &)=delete
std::mutex fLock
The page pool is accessed concurrently due to parallel decompression.
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.
RPagePool & operator=(const RPagePool &)=delete
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.
RClusterInfo fClusterInfo
std::uint32_t fMaxElements
The capacity of the page in number of elements.
ROOT::NTupleSize_t fRangeFirst
std::uint32_t fElementSize
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
ROOT::NTupleSize_t GetIndexInCluster() const
ROOT::DescriptorId_t GetClusterId() const
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
constexpr DescriptorId_t kInvalidDescriptorId
Every page in the page pool is annotated with a search key and a reference counter.
Hash function to be used in the unordered map fLookupByKey.
std::size_t operator()(const RKey &k) const
Like boost::hash_combine.
ROOT::DescriptorId_t fColumnId
bool operator!=(const RKey &other) const
std::type_index fInMemoryType
bool operator==(const RKey &other) const
Used in fLookupByKey to store both the absolute and the cluster-local page index of the referenced pa...
RPagePosition(const RPage &page)
bool operator<(const RPagePosition &other) const
RPagePosition(ROOT::NTupleSize_t globalIndex)
ROOT::NTupleSize_t fGlobalFirstElement
RPagePosition(RNTupleLocalIndex localIndex)
RNTupleLocalIndex fClusterFirstElement