Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RColumn.cxx
Go to the documentation of this file.
1/// \file RColumn.cxx
2/// \author Jakob Blomer <jblomer@cern.ch>
3/// \date 2018-10-04
4
5/*************************************************************************
6 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
7 * All rights reserved. *
8 * *
9 * For the licensing terms see $ROOTSYS/LICENSE. *
10 * For the list of contributors see $ROOTSYS/README/CREDITS. *
11 *************************************************************************/
12
13#include <ROOT/RColumn.hxx>
15#include <ROOT/RPageStorage.hxx>
16
17#include <TError.h>
18
19#include <algorithm>
20#include <cassert>
21#include <utility>
22
25
27 : fType(type), fIndex(columnIndex), fRepresentationIndex(representationIndex), fTeam({this})
28{
29}
30
38
41{
42 fInitialNElements = pageSink.GetWriteOptions().GetInitialUnzippedPageSize() / fElement->GetSize();
43 if (fInitialNElements < 1) {
44 throw RException(R__FAIL("initial page size is too small for at least one element"));
45 }
46
47 fPageSink = &pageSink;
48 fFirstElementIndex = firstElementIndex;
49 fHandleSink = fPageSink->AddColumn(fieldId, *this);
50 fOnDiskId = fPageSink->GetColumnId(fHandleSink);
51 fWritePage = fPageSink->ReservePage(fHandleSink, fInitialNElements);
52 if (fWritePage.IsNull())
53 throw RException(R__FAIL("page buffer memory budget too small"));
54}
55
57{
58 fPageSource = &pageSource;
59 fHandleSource = fPageSource->AddColumn(fieldId, *this);
60 fOnDiskId = fPageSource->GetColumnId(fHandleSource);
61 {
62 auto descriptorGuard = fPageSource->GetSharedDescriptorGuard();
63 fFirstElementIndex = descriptorGuard->GetColumnDescriptor(fOnDiskId).GetFirstElementIndex();
64 }
65}
66
68{
69 if (fWritePage.GetNElements() == 0)
70 return;
71
72 fPageSink->CommitPage(fHandleSink, fWritePage);
73 fWritePage = fPageSink->ReservePage(fHandleSink, fInitialNElements);
74 R__ASSERT(!fWritePage.IsNull());
75 fWritePage.Reset(fNElements);
76}
77
79{
80 fPageSink->CommitSuppressedColumn(fHandleSink);
81}
82
84{
85 const auto nTeam = fTeam.size();
86 std::size_t iTeam = 1;
87 do {
88 fReadPageRef = fPageSource->LoadPage(fTeam.at(fLastGoodTeamIdx)->GetHandleSource(), globalIndex);
89 if (!fReadPageRef.Get().IsNull())
90 break;
91 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
92 iTeam++;
93 } while (iTeam <= nTeam);
94
95 return fReadPageRef.Get().Contains(globalIndex);
96}
97
99{
100 const auto nTeam = fTeam.size();
101 std::size_t iTeam = 1;
102 do {
103 fReadPageRef = fPageSource->LoadPage(fTeam.at(fLastGoodTeamIdx)->GetHandleSource(), localIndex);
104 if (!fReadPageRef.Get().IsNull())
105 break;
106 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
107 iTeam++;
108 } while (iTeam <= nTeam);
109
110 return fReadPageRef.Get().Contains(localIndex);
111}
112
114{
115 // We are working on very small vectors here, so quadratic complexity works
116 for (auto *c : other.fTeam) {
117 if (std::find(fTeam.begin(), fTeam.end(), c) == fTeam.end())
118 fTeam.emplace_back(c);
119 }
120
121 for (auto c : fTeam) {
122 if (c == this)
123 continue;
124 c->fTeam = fTeam;
125 }
126}
#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:322
#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:130
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:37
RColumn(ROOT::ENTupleColumnType type, std::uint32_t columnIndex, std::uint16_t representationIndex)
void MergeTeams(RColumn &other)
Definition RColumn.cxx:113
void ConnectPageSource(ROOT::DescriptorId_t fieldId, ROOT::Internal::RPageSource &pageSource)
Connect the column to a page source.
Definition RColumn.cxx:56
ROOT::Internal::RPageSource * fPageSource
Definition RColumn.hxx:46
ROOT::Internal::RPageSink * fPageSink
Definition RColumn.hxx:45
bool TryMapPage(ROOT::NTupleSize_t globalIndex)
Definition RColumn.cxx:83
ROOT::Internal::RPageStorage::ColumnHandle_t fHandleSink
Definition RColumn.hxx:47
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:39
ROOT::Internal::RPageStorage::ColumnHandle_t fHandleSource
Definition RColumn.hxx:48
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:78
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.