Logo ROOT  
Reference Guide
RPageAllocator.hxx
Go to the documentation of this file.
1 /// \file ROOT/RPageAllocator.hxx
2 /// \ingroup NTuple ROOT7
3 /// \author Jakob Blomer <jblomer@cern.ch>
4 /// \date 2019-06-25
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_RPageAllocator
17 #define ROOT7_RPageAllocator
18 
19 #include <ROOT/RNTupleUtil.hxx>
20 #include <ROOT/RPage.hxx>
21 
22 #include <cstddef>
23 #include <functional>
24 
25 namespace ROOT {
26 namespace Experimental {
27 namespace Detail {
28 
29 // clang-format off
30 /**
31 \class ROOT::Experimental::Detail::RPageDeleter
32 \ingroup NTuple
33 \brief A closure that can free the memory associated with a mapped page
34 
35 The page pool, once taken ownership of pages, must know how to free them. When registering a new page with
36 the page pool, the passed page deleter encapsulates that knowledge.
37 */
38 // clang-format on
39 class RPageDeleter {
40 private:
41  /// The callable that is suppped to free the given page; it is called with fUserData as the second argument.
42  std::function<void(const RPage &page, void *userData)> fFnDelete;
43  /// Optionally additional information necessary to free resources associated with a page. For instance,
44  /// when the page is read from a TKey, user data points to the ROOT object created for reading, which needs to be
45  /// freed as well.
46  void *fUserData;
47 
48 public:
49  RPageDeleter() : fFnDelete(), fUserData(nullptr) {}
50  explicit RPageDeleter(decltype(fFnDelete) fnDelete) : fFnDelete(fnDelete), fUserData(nullptr) {}
51  RPageDeleter(decltype(fFnDelete) fnDelete, void *userData) : fFnDelete(fnDelete), fUserData(userData) {}
52  RPageDeleter(const RPageDeleter &other) = default;
53  RPageDeleter &operator =(const RPageDeleter &other) = default;
54  ~RPageDeleter() = default;
55 
56  void operator()(const RPage &page) { fFnDelete(page, fUserData); }
57 };
58 
59 
60 // clang-format off
61 /**
62 \class ROOT::Experimental::Detail::RPageAllocatorHeap
63 \ingroup NTuple
64 \brief Uses standard C++ memory allocation for the column data pages
65 
66 The page allocator acquires and releases memory for pages. It does not populate the pages, the returned pages
67 are empty but guaranteed to have enough contiguous space for the given number of elements. While a common
68 concrete implementation uses the heap, other implementations are possible, e.g. using arenas or mmap().
69 */
70 // clang-format on
72 public:
73  /// Reserves memory large enough to hold nElements of the given size. The page is immediately tagged with
74  /// a column id.
75  static RPage NewPage(ColumnId_t columnId, std::size_t elementSize, std::size_t nElements);
76  /// Releases the memory pointed to by page and resets the page's information
77  static void DeletePage(const RPage &page);
78 };
79 
80 } // namespace Detail
81 } // namespace Experimental
82 } // namespace ROOT
83 
84 #endif
ROOT::Experimental::Detail::RPageDeleter::RPageDeleter
RPageDeleter(decltype(fFnDelete) fnDelete, void *userData)
Definition: RPageAllocator.hxx:51
ROOT::Experimental::Detail::RPage
A page is a slice of a column that is mapped into memory.
Definition: RPage.hxx:41
ROOT::Experimental::Detail::RPageAllocatorHeap::DeletePage
static void DeletePage(const RPage &page)
Releases the memory pointed to by page and resets the page's information.
Definition: RPageAllocator.cxx:30
ROOT::Experimental::Detail::RPageDeleter::~RPageDeleter
~RPageDeleter()=default
RPage.hxx
ROOT::Experimental::Detail::RPageDeleter::operator()
void operator()(const RPage &page)
Definition: RPageAllocator.hxx:56
ROOT::Experimental::Detail::RPageDeleter::RPageDeleter
RPageDeleter()
Definition: RPageAllocator.hxx:49
ROOT::Experimental::Detail::RPageDeleter::operator=
RPageDeleter & operator=(const RPageDeleter &other)=default
ROOT::Experimental::Detail::RPageDeleter::RPageDeleter
RPageDeleter(decltype(fFnDelete) fnDelete)
Definition: RPageAllocator.hxx:50
ROOT::Experimental::Detail::RPageAllocatorHeap::NewPage
static RPage NewPage(ColumnId_t columnId, std::size_t elementSize, std::size_t nElements)
Reserves memory large enough to hold nElements of the given size.
Definition: RPageAllocator.cxx:21
ROOT::Experimental::Detail::RPageDeleter::fFnDelete
std::function< void(const RPage &page, void *userData)> fFnDelete
The callable that is suppped to free the given page; it is called with fUserData as the second argume...
Definition: RPageAllocator.hxx:42
ROOT::Experimental::Detail::RPageDeleter
A closure that can free the memory associated with a mapped page.
Definition: RPageAllocator.hxx:39
ROOT::R::function
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
RNTupleUtil.hxx
void
typedef void((*Func_t)())
ROOT::Experimental::Detail::RPageAllocatorHeap
Uses standard C++ memory allocation for the column data pages.
Definition: RPageAllocator.hxx:71
ROOT::Experimental::Detail::RPageDeleter::RPageDeleter
RPageDeleter(const RPageDeleter &other)=default
ROOT::Experimental::Detail::RPageDeleter::fUserData
void * fUserData
Optionally additional information necessary to free resources associated with a page.
Definition: RPageAllocator.hxx:46
ROOT::Experimental::ColumnId_t
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
Definition: RNTupleUtil.hxx:87
ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Definition: EExecutionPolicy.hxx:4