Logo ROOT  
Reference Guide
RPagePool.cxx
Go to the documentation of this file.
1/// \file RPagePool.cxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-04
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#include <ROOT/RPagePool.hxx>
17#include <ROOT/RColumn.hxx>
18
19#include <TError.h>
20
21#include <cstdlib>
22
24{
25 fPages.emplace_back(page);
26 fReferences.emplace_back(1);
27 fDeleters.emplace_back(deleter);
28}
29
31{
32 if (page.IsNull()) return;
33
34 unsigned int N = fPages.size();
35 for (unsigned i = 0; i < N; ++i) {
36 if (fPages[i] != page) continue;
37
38 if (--fReferences[i] == 0) {
39 fDeleters[i](fPages[i]);
40 fPages[i] = fPages[N-1];
41 fReferences[i] = fReferences[N-1];
42 fDeleters[i] = fDeleters[N-1];
43 fPages.resize(N-1);
44 fReferences.resize(N-1);
45 fDeleters.resize(N-1);
46 }
47 return;
48 }
49 R__ASSERT(false);
50}
51
53 ColumnId_t columnId, NTupleSize_t globalIndex)
54{
55 unsigned int N = fPages.size();
56 for (unsigned int i = 0; i < N; ++i) {
57 if (fReferences[i] == 0) continue;
58 if (fPages[i].GetColumnId() != columnId) continue;
59 if (!fPages[i].Contains(globalIndex)) continue;
60 fReferences[i]++;
61 return fPages[i];
62 }
63 return RPage();
64}
65
67 ColumnId_t columnId, const RClusterIndex &clusterIndex)
68{
69 unsigned int N = fPages.size();
70 for (unsigned int i = 0; i < N; ++i) {
71 if (fReferences[i] == 0) continue;
72 if (fPages[i].GetColumnId() != columnId) continue;
73 if (!fPages[i].Contains(clusterIndex)) continue;
74 fReferences[i]++;
75 return fPages[i];
76 }
77 return RPage();
78}
#define R__ASSERT(e)
Definition: TError.h:96
#define N
A closure that can free the memory associated with a mapped page.
std::vector< RPageDeleter > fDeleters
Definition: RPagePool.hxx:55
std::vector< std::uint32_t > fReferences
Definition: RPagePool.hxx:54
void ReturnPage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
Definition: RPagePool.cxx:30
RPage GetPage(ColumnId_t columnId, NTupleSize_t globalIndex)
Tries to find the page corresponding to column and index in the cache.
Definition: RPagePool.cxx:52
std::vector< RPage > fPages
TODO(jblomer): should be an efficient index structure that allows.
Definition: RPagePool.hxx:53
void RegisterPage(const RPage &page, const RPageDeleter &deleter)
Adds a new page to the pool together with the function to free its space.
Definition: RPagePool.cxx:23
A page is a slice of a column that is mapped into memory.
Definition: RPage.hxx:41
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Definition: RNTupleUtil.hxx:83
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
Definition: RNTupleUtil.hxx:43
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.
Definition: RNTupleUtil.hxx:75