Logo ROOT   6.18/05
Reference Guide
RPagePool.hxx
Go to the documentation of this file.
1/// \file ROOT/RPagePool.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-09
5/// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback
6/// is welcome!
7
8/*************************************************************************
9 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16#ifndef ROOT7_RPagePool
17#define ROOT7_RPagePool
18
19#include <ROOT/RPage.hxx>
20#include <ROOT/RNTupleUtil.hxx>
21
22#include <cstddef>
23#include <vector>
24
25namespace ROOT {
26namespace Experimental {
27
28namespace Detail {
29
30class RColumn;
31
32// clang-format off
33/**
34\class ROOT::Experimental::Detail::RPagePool
35\ingroup NTuple
36\brief A thread-safe cache of column pages.
37
38The page pool encapsulated memory management for data written into a tree or read from a tree. Adding and removing
39pages is thread-safe. All pages have the same size, which means different pages do not necessarily contain the same
40number of elements. Multiple page caches can coexist.
41
42TODO(jblomer): it should be possible to register pages and to find them by column and index; this would
43facilitate pre-filling a cache, e.g. by read-ahead.
44*/
45// clang-format on
46class RPagePool {
47private:
48 void* fMemory;
49 std::size_t fPageSize;
50 std::size_t fNPages;
51 /// TODO(jblomer): should be an efficient index structure that allows
52 /// - random insert
53 /// - random delete
54 /// - searching by page
55 /// - searching by tree index
56 std::vector<RPage> fPages;
57 std::vector<std::uint32_t> fReferences;
58
59public:
60 RPagePool(std::size_t pageSize, std::size_t nPages);
61 RPagePool(const RPagePool&) = delete;
62 RPagePool& operator =(const RPagePool&) = delete;
63 ~RPagePool();
64
65 /// Get a new, empty page from the cache. Return a "null Page" if there is no more free space.
66 RPage ReservePage(RColumn* column);
67 /// Registers a page that has previously been acquired by ReservePage() and was meanwhile filled with content.
68 void CommitPage(const RPage& page);
69 /// Tries to find the page corresponding to column and index in the cache. On cache miss, load the page
70 /// from the PageSource attached to the column and put it in the cache.
71 RPage GetPage(RColumn* column, NTupleSize_t index);
72 /// Give back a page to the pool. There must not be any pointers anymore into this page.
73 void ReleasePage(const RPage &page);
74};
75
76} // namespace Detail
77
78} // namespace Experimental
79} // namespace ROOT
80
81#endif
A thread-safe cache of column pages.
Definition: RPagePool.hxx:46
RPage GetPage(RColumn *column, NTupleSize_t index)
Tries to find the page corresponding to column and index in the cache.
Definition: RPagePool.cxx:82
std::vector< std::uint32_t > fReferences
Definition: RPagePool.hxx:57
void ReleasePage(const RPage &page)
Give back a page to the pool. There must not be any pointers anymore into this page.
Definition: RPagePool.cxx:68
RPagePool & operator=(const RPagePool &)=delete
RPagePool(const RPagePool &)=delete
std::vector< RPage > fPages
TODO(jblomer): should be an efficient index structure that allows.
Definition: RPagePool.hxx:56
RPagePool(std::size_t pageSize, std::size_t nPages)
Definition: RPagePool.cxx:23
RPage ReservePage(RColumn *column)
Get a new, empty page from the cache. Return a "null Page" if there is no more free space.
Definition: RPagePool.cxx:41
void CommitPage(const RPage &page)
Registers a page that has previously been acquired by ReservePage() and was meanwhile filled with con...
Definition: RPagePool.cxx:57
A page is a fixed size slice of a column that is mapped into memory.
Definition: RPage.hxx:40
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:44
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21