Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include <utility>
23
26{
27 std::lock_guard<std::mutex> lockGuard(fLock);
28 fPages.emplace_back(std::move(page));
29 fPageInfos.emplace_back(RPageInfo{inMemoryType});
30 fReferences.emplace_back(1);
31 return RPageRef(page, this);
32}
33
35{
36 std::lock_guard<std::mutex> lockGuard(fLock);
37 fPages.emplace_back(std::move(page));
38 fPageInfos.emplace_back(RPageInfo{inMemoryType});
39 fReferences.emplace_back(0);
40}
41
43{
44 if (page.IsNull()) return;
45 std::lock_guard<std::mutex> lockGuard(fLock);
46
47 unsigned int N = fPages.size();
48 for (unsigned i = 0; i < N; ++i) {
49 if (fPages[i] != page) continue;
50
51 if (--fReferences[i] == 0) {
52 fPages[i] = std::move(fPages[N - 1]);
53 fPageInfos[i] = fPageInfos[N - 1];
54 fReferences[i] = fReferences[N - 1];
55 fPages.resize(N - 1);
56 fPageInfos.resize(N - 1);
57 fReferences.resize(N - 1);
58 }
59 return;
60 }
61 R__ASSERT(false);
62}
63
65 std::type_index inMemoryType,
67{
68 std::lock_guard<std::mutex> lockGuard(fLock);
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 (fPageInfos[i].fInMemoryType != inMemoryType)
74 continue;
75 if (!fPages[i].Contains(globalIndex)) continue;
76 fReferences[i]++;
77 return RPageRef(fPages[i], this);
78 }
79 return RPageRef();
80}
81
83 std::type_index inMemoryType,
85{
86 std::lock_guard<std::mutex> lockGuard(fLock);
87 unsigned int N = fPages.size();
88 for (unsigned int i = 0; i < N; ++i) {
89 if (fReferences[i] < 0) continue;
90 if (fPages[i].GetColumnId() != columnId) continue;
91 if (fPageInfos[i].fInMemoryType != inMemoryType)
92 continue;
93 if (!fPages[i].Contains(clusterIndex)) continue;
94 fReferences[i]++;
95 return RPageRef(fPages[i], this);
96 }
97 return RPageRef();
98}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
#define N
std::vector< RPage > fPages
TODO(jblomer): should be an efficient index structure that allows.
Definition RPagePool.hxx:57
RPageRef GetPage(ColumnId_t columnId, std::type_index inMemoryType, NTupleSize_t globalIndex)
Tries to find the page corresponding to column and index in the cache.
Definition RPagePool.cxx:64
std::vector< std::int32_t > fReferences
Definition RPagePool.hxx:59
void ReleasePage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
Definition RPagePool.cxx:42
RPageRef RegisterPage(RPage page, std::type_index inMemoryType)
Adds a new page to the pool.
Definition RPagePool.cxx:25
void PreloadPage(RPage page, std::type_index inMemoryType)
Like RegisterPage() but the reference counter is initialized to 0.
Definition RPagePool.cxx:34
std::vector< RPageInfo > fPageInfos
Definition RPagePool.hxx:58
Reference to a page stored in the page pool.
Definition RPagePool.hxx:93
A page is a slice of a column that is mapped into memory.
Definition RPage.hxx:46
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::int64_t ColumnId_t
Uniquely identifies a physical column within the scope of the current process, used to tag pages.