16#ifndef ROOT7_RPagePool
17#define ROOT7_RPagePool
28#include <unordered_map>
29#include <unordered_set>
33namespace Experimental {
72 auto seed = std::hash<DescriptorId_t>()(k.
fColumnId);
73 return seed ^ (std::hash<std::type_index>()(k.
fInMemoryType) + 0x9e3779b9 + (seed << 6) + (seed >> 2));
129 std::unordered_map<DescriptorId_t, std::unordered_set<void *>>
fUnusedPages;
203 if (
this != &other) {
204 std::swap(
fPage, other.fPage);
A thread-safe cache of pages loaded from the page source.
REntry & AddPage(RPage page, const RKey &key, std::int64_t initialRefCounter)
Add a new page to the fLookupByBuffer and fLookupByKey data structures.
void PreloadPage(RPage page, RKey key)
Like RegisterPage() but the reference counter is initialized to 0.
RPagePool & operator=(const RPagePool &)=delete
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.
RPagePool(const RPagePool &)=delete
void ReleasePage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
void Evict(DescriptorId_t clusterId)
Removes unused pages (pages with reference counter 0) from the page pool.
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.
std::unordered_map< RKey, std::map< RPagePosition, std::size_t >, RKeyHasher > fLookupByKey
Used in GetPage() to find the right page in fEntries.
std::unordered_map< DescriptorId_t, std::unordered_set< void * > > fUnusedPages
Remembers pages with reference counter 0, organized by the page's cluster id.
void RemoveFromUnusedPages(const RPage &page)
Called by GetPage(), when the reference counter increases from zero to one.
std::mutex fLock
The page pool is accessed concurrently due to parallel decompression.
RPageRef GetPage(RKey key, NTupleSize_t globalIndex)
Tries to find the page corresponding to column and index in the cache.
RPageRef RegisterPage(RPage page, RKey key)
Adds a new page to the pool.
Stores information about the cluster in which this page resides.
NTupleSize_t GetIndexOffset() const
NTupleSize_t GetId() const
A page is a slice of a column that is mapped into memory.
ClusterSize_t::ValueType GetClusterRangeFirst() const
const RClusterInfo & GetClusterInfo() const
RClusterInfo fClusterInfo
std::uint32_t fMaxElements
The capacity of the page in number of elements.
std::uint32_t fElementSize
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
DescriptorId_t GetClusterId() const
ClusterSize_t::ValueType GetIndex() const
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
constexpr NTupleSize_t kInvalidNTupleIndex
constexpr ClusterSize_t kInvalidClusterIndex(std::uint64_t(-1))
constexpr DescriptorId_t kInvalidDescriptorId
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
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.
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(NTupleSize_t globalIndex)
RClusterIndex fClusterFirstElement
NTupleSize_t fGlobalFirstElement
bool operator<(const RPagePosition &other) const
RPagePosition(RClusterIndex clusterIndex)
RPagePosition(const RPage &page)