Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
28
30 : fType(type), fIndex(columnIndex), fRepresentationIndex(representationIndex), fTeam({this})
31{
32}
33
41
44{
45 fInitialNElements = pageSink.GetWriteOptions().GetInitialUnzippedPageSize() / fElement->GetSize();
46 if (fInitialNElements < 1) {
47 throw RException(R__FAIL("initial page size is too small for at least one element"));
48 }
49
50 fPageSink = &pageSink;
51 fFirstElementIndex = firstElementIndex;
52 fHandleSink = fPageSink->AddColumn(fieldId, *this);
53 fOnDiskId = fPageSink->GetColumnId(fHandleSink);
54 fWritePage = fPageSink->ReservePage(fHandleSink, fInitialNElements);
55 if (fWritePage.IsNull())
56 throw RException(R__FAIL("page buffer memory budget too small"));
57}
58
60{
61 fPageSource = &pageSource;
62 fHandleSource = fPageSource->AddColumn(fieldId, *this);
63 fNElements = fPageSource->GetNElements(fHandleSource);
64 fOnDiskId = fPageSource->GetColumnId(fHandleSource);
65 {
66 auto descriptorGuard = fPageSource->GetSharedDescriptorGuard();
67 fFirstElementIndex = descriptorGuard->GetColumnDescriptor(fOnDiskId).GetFirstElementIndex();
68 }
69}
70
72{
73 if (fWritePage.GetNElements() == 0)
74 return;
75
76 fPageSink->CommitPage(fHandleSink, fWritePage);
77 fWritePage = fPageSink->ReservePage(fHandleSink, fInitialNElements);
78 R__ASSERT(!fWritePage.IsNull());
79 fWritePage.Reset(fNElements);
80}
81
83{
84 fPageSink->CommitSuppressedColumn(fHandleSink);
85}
86
88{
89 const auto nTeam = fTeam.size();
90 std::size_t iTeam = 1;
91 do {
92 fReadPageRef = fPageSource->LoadPage(fTeam.at(fLastGoodTeamIdx)->GetHandleSource(), globalIndex);
93 if (!fReadPageRef.Get().IsNull())
94 break;
95 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
96 iTeam++;
97 } while (iTeam <= nTeam);
98
99 return fReadPageRef.Get().Contains(globalIndex);
100}
101
103{
104 const auto nTeam = fTeam.size();
105 std::size_t iTeam = 1;
106 do {
107 fReadPageRef = fPageSource->LoadPage(fTeam.at(fLastGoodTeamIdx)->GetHandleSource(), localIndex);
108 if (!fReadPageRef.Get().IsNull())
109 break;
110 fLastGoodTeamIdx = (fLastGoodTeamIdx + 1) % nTeam;
111 iTeam++;
112 } while (iTeam <= nTeam);
113
114 return fReadPageRef.Get().Contains(localIndex);
115}
116
118{
119 // We are working on very small vectors here, so quadratic complexity works
120 for (auto *c : other.fTeam) {
121 if (std::find(fTeam.begin(), fTeam.end(), c) == fTeam.end())
122 fTeam.emplace_back(c);
123 }
124
125 for (auto c : fTeam) {
126 if (c == this)
127 continue;
128 c->fTeam = fTeam;
129 }
130}
#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.
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.
A column is a storage-backed array of a simple, fixed-size type, from which pages can be mapped into ...
Definition RColumn.hxx:40
RColumn(ROOT::ENTupleColumnType type, std::uint32_t columnIndex, std::uint16_t representationIndex)
void MergeTeams(RColumn &other)
Definition RColumn.cxx:117
ROOT::Experimental::Internal::RPageStorage::ColumnHandle_t fHandleSink
Definition RColumn.hxx:50
void ConnectPageSource(ROOT::DescriptorId_t fieldId, ROOT::Experimental::Internal::RPageSource &pageSource)
Connect the column to a page source.
Definition RColumn.cxx:59
ROOT::Experimental::Internal::RPageSink * fPageSink
Definition RColumn.hxx:48
ROOT::Experimental::Internal::RPageStorage::ColumnHandle_t fHandleSource
Definition RColumn.hxx:51
ROOT::Experimental::Internal::RPageSource * fPageSource
Definition RColumn.hxx:49
bool TryMapPage(ROOT::NTupleSize_t globalIndex)
Definition RColumn.cxx:87
void ConnectPageSink(ROOT::DescriptorId_t fieldId, ROOT::Experimental::Internal::RPageSink &pageSink, ROOT::NTupleSize_t firstElementIndex=0U)
Connect the column to a page sink.
Definition RColumn.cxx:42
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.