Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RColumn.cxx
Go to the documentation of this file.
1/// \file RColumn.cxx
2/// \ingroup NTuple
3/// \author Jakob Blomer <jblomer@cern.ch>
4/// \date 2018-10-04
5
6/*************************************************************************
7 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#include <ROOT/RColumn.hxx>
16#include <ROOT/RPageStorage.hxx>
17
18#include <TError.h>
19
20#include <algorithm>
21#include <cassert>
22#include <utility>
23
26
28 : fType(type), fIndex(columnIndex), fRepresentationIndex(representationIndex), fTeam({this})
29{
30}
31
39
42{
43 fInitialNElements = pageSink.GetWriteOptions().GetInitialUnzippedPageSize() / fElement->GetSize();
44 if (fInitialNElements < 1) {
45 throw RException(R__FAIL("initial page size is too small for at least one element"));
46 }
47
48 fPageSink = &pageSink;
49 fFirstElementIndex = firstElementIndex;
50 fHandleSink = fPageSink->AddColumn(fieldId, *this);
51 fOnDiskId = fPageSink->GetColumnId(fHandleSink);
52 fWritePage = fPageSink->ReservePage(fHandleSink, fInitialNElements);
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, fInitialNElements);
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().IsNull())
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(), localIndex);
106 if (!fReadPageRef.Get().IsNull())
107 break;
108 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
109 iTeam++;
110 } while (iTeam <= nTeam);
111
112 return fReadPageRef.Get().Contains(localIndex);
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:299
#define c(i)
Definition RSha256.hxx:101
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
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
The available trivial, native content types of a column.
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
Definition RColumn.hxx:38
RColumn(ROOT::ENTupleColumnType type, std::uint32_t columnIndex, std::uint16_t representationIndex)
void MergeTeams(RColumn &other)
Definition RColumn.cxx:115
void ConnectPageSource(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource &pageSource)
Connect the column to a page source.
Definition RColumn.cxx:57
ROOT::Internal::RPageSource * fPageSource
Definition RColumn.hxx:47
ROOT::Internal::RPageSink * fPageSink
Definition RColumn.hxx:46
bool TryMapPage(ROOT::NTupleSize_t globalIndex)
Definition RColumn.cxx:85
ROOT::Internal::RPageStorage::ColumnHandle_t fHandleSink
Definition RColumn.hxx:48
void ConnectPageSink(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSink &pageSink, ROOT::NTupleSize_t firstElementIndex=0U)
Connect the column to a page sink.
Definition RColumn.cxx:40
ROOT::Internal::RPageStorage::ColumnHandle_t fHandleSource
Definition RColumn.hxx:49
Abstract interface to write data into an ntuple.
void DropColumn(ColumnHandle_t) final
Unregisters a column.
Abstract interface to read data from an ntuple.
void DropColumn(ColumnHandle_t columnHandle) override
Unregisters a column.
Base class for all ROOT issued exceptions.
Definition RError.hxx:79
Addresses a column element or field item relative to a particular cluster, instead of a global NTuple...
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
std::uint64_t NTupleSize_t
Integer type long enough to hold the maximum number of entries in a column.