Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RColumn.cxx
Go to the documentation of this file.
1/// \file RColumn.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/RColumn.hxx>
18#include <ROOT/RPageStorage.hxx>
19
20#include <TError.h>
21
22#include <algorithm>
23#include <cassert>
24#include <utility>
25
27 std::uint16_t representationIndex)
28 : fType(type), fIndex(columnIndex), fRepresentationIndex(representationIndex), fTeam({this})
29{
30}
31
33{
34 if (fHandleSink)
35 fPageSink->DropColumn(fHandleSink);
36 if (fHandleSource)
37 fPageSource->DropColumn(fHandleSource);
38}
39
41 NTupleSize_t firstElementIndex)
42{
43 if (pageSink.GetWriteOptions().GetInitialNElementsPerPage() * fElement->GetSize() >
45 throw RException(R__FAIL("maximum page size to small for the initial number of elements per page"));
46 }
47
48 fPageSink = &pageSink;
49 fFirstElementIndex = firstElementIndex;
50 fHandleSink = fPageSink->AddColumn(fieldId, *this);
51 fOnDiskId = fPageSink->GetColumnId(fHandleSink);
52 fWritePage = fPageSink->ReservePage(fHandleSink, fPageSink->GetWriteOptions().GetInitialNElementsPerPage());
53 if (fWritePage.IsNull())
54 throw RException(R__FAIL("page buffer memory budget too small"));
55}
56
58{
59 fPageSource = &pageSource;
60 fHandleSource = fPageSource->AddColumn(fieldId, *this);
61 fNElements = fPageSource->GetNElements(fHandleSource);
62 fOnDiskId = fPageSource->GetColumnId(fHandleSource);
63 {
64 auto descriptorGuard = fPageSource->GetSharedDescriptorGuard();
65 fFirstElementIndex = descriptorGuard->GetColumnDescriptor(fOnDiskId).GetFirstElementIndex();
66 }
67}
68
70{
71 if (fWritePage.GetNElements() == 0)
72 return;
73
74 fPageSink->CommitPage(fHandleSink, fWritePage);
75 fWritePage = fPageSink->ReservePage(fHandleSink, fPageSink->GetWriteOptions().GetInitialNElementsPerPage());
76 R__ASSERT(!fWritePage.IsNull());
77 fWritePage.Reset(fNElements);
78}
79
81{
82 fPageSink->CommitSuppressedColumn(fHandleSink);
83}
84
86{
87 const auto nTeam = fTeam.size();
88 std::size_t iTeam = 1;
89 do {
90 fReadPageRef = fPageSource->LoadPage(fTeam.at(fLastGoodTeamIdx)->GetHandleSource(), globalIndex);
91 if (fReadPageRef.Get().IsValid())
92 break;
93 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
94 iTeam++;
95 } while (iTeam <= nTeam);
96
97 return fReadPageRef.Get().Contains(globalIndex);
98}
99
101{
102 const auto nTeam = fTeam.size();
103 std::size_t iTeam = 1;
104 do {
105 fReadPageRef = fPageSource->LoadPage(fTeam.at(fLastGoodTeamIdx)->GetHandleSource(), clusterIndex);
106 if (fReadPageRef.Get().IsValid())
107 break;
108 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
109 iTeam++;
110 } while (iTeam <= nTeam);
111
112 return fReadPageRef.Get().Contains(clusterIndex);
113}
114
116{
117 // We are working on very small vectors here, so quadratic complexity works
118 for (auto *c : other.fTeam) {
119 if (std::find(fTeam.begin(), fTeam.end(), c) == fTeam.end())
120 fTeam.emplace_back(c);
121 }
122
123 for (auto c : fTeam) {
124 if (c == this)
125 continue;
126 c->fTeam = fTeam;
127 }
128}
#define R__FAIL(msg)
Short-hand to return an RResult<T> in an error state; the RError is implicitly converted into RResult...
Definition RError.hxx:290
#define c(i)
Definition RSha256.hxx:101
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
Definition RColumn.hxx:40
void ConnectPageSink(DescriptorId_t fieldId, RPageSink &pageSink, NTupleSize_t firstElementIndex=0U)
Connect the column to a page sink.
Definition RColumn.cxx:40
bool TryMapPage(NTupleSize_t globalIndex)
Definition RColumn.cxx:85
RColumn(EColumnType type, std::uint32_t columnIndex, std::uint16_t representationIndex)
Definition RColumn.cxx:26
std::vector< RColumn * > fTeam
The column team is a set of columns that serve the same column index for different representation IDs...
Definition RColumn.hxx:71
void ConnectPageSource(DescriptorId_t fieldId, RPageSource &pageSource)
Connect the column to a page source.
Definition RColumn.cxx:57
Abstract interface to write data into an ntuple.
const RNTupleWriteOptions & GetWriteOptions() const
Returns the sink's write options.
Abstract interface to read data from an ntuple.
ColumnHandle_t AddColumn(DescriptorId_t fieldId, RColumn &column) override
Register a new column.
virtual ColumnHandle_t AddColumn(DescriptorId_t fieldId, RColumn &column)=0
Register a new column.
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
Base class for all ROOT issued exceptions.
Definition RError.hxx:78
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.