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
25{
26 std::lock_guard<std::mutex> lockGuard(fLock);
27 fPages.emplace_back(std::move(page));
28 fReferences.emplace_back(1);
29 return RPageRef(page, this);
30}
31
33{
34 std::lock_guard<std::mutex> lockGuard(fLock);
35 fPages.emplace_back(std::move(page));
36 fReferences.emplace_back(0);
37}
38
40{
41 if (page.IsNull()) return;
42 std::lock_guard<std::mutex> lockGuard(fLock);
43
44 unsigned int N = fPages.size();
45 for (unsigned i = 0; i < N; ++i) {
46 if (fPages[i] != page) continue;
47
48 if (--fReferences[i] == 0) {
49 fPages[i] = std::move(fPages[N - 1]);
50 fReferences[i] = fReferences[N - 1];
51 fPages.resize(N-1);
52 fReferences.resize(N - 1);
53 }
54 return;
55 }
56 R__ASSERT(false);
57}
58
61{
62 std::lock_guard<std::mutex> lockGuard(fLock);
63 unsigned int N = fPages.size();
64 for (unsigned int i = 0; i < N; ++i) {
65 if (fReferences[i] < 0) continue;
66 if (fPages[i].GetColumnId() != columnId) continue;
67 if (!fPages[i].Contains(globalIndex)) continue;
68 fReferences[i]++;
69 return RPageRef(fPages[i], this);
70 }
71 return RPageRef();
72}
73
76{
77 std::lock_guard<std::mutex> lockGuard(fLock);
78 unsigned int N = fPages.size();
79 for (unsigned int i = 0; i < N; ++i) {
80 if (fReferences[i] < 0) continue;
81 if (fPages[i].GetColumnId() != columnId) continue;
82 if (!fPages[i].Contains(clusterIndex)) continue;
83 fReferences[i]++;
84 return RPageRef(fPages[i], this);
85 }
86 return RPageRef();
87}
#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:50
RPageRef RegisterPage(RPage page)
Adds a new page to the pool.
Definition RPagePool.cxx:24
RPageRef GetPage(ColumnId_t columnId, NTupleSize_t globalIndex)
Tries to find the page corresponding to column and index in the cache.
Definition RPagePool.cxx:60
std::vector< std::int32_t > fReferences
Definition RPagePool.hxx:51
void ReleasePage(const RPage &page)
Give back a page to the pool and decrease the reference counter.
Definition RPagePool.cxx:39
void PreloadPage(RPage page)
Like RegisterPage() but the reference counter is initialized to 0.
Definition RPagePool.cxx:32
Reference to a page stored in the page pool.
Definition RPagePool.hxx:85
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.