Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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>
17 #include <ROOT/RColumnModel.hxx>
18 #include <ROOT/RPageStorage.hxx>
19 
20 #include <TError.h>
21 
22 #include <iostream>
23 
24 ROOT::Experimental::Detail::RColumn::RColumn(const RColumnModel& model, std::uint32_t index)
25  : fModel(model), fIndex(index), fPageSink(nullptr), fPageSource(nullptr), fHeadPage(), fNElements(0),
26  fCurrentPage(),
27  fColumnIdSource(kInvalidColumnId)
28 {
29 }
30 
31 ROOT::Experimental::Detail::RColumn::~RColumn()
32 {
33  if (!fHeadPage.IsNull())
34  fPageSink->ReleasePage(fHeadPage);
35  if (!fCurrentPage.IsNull())
36  fPageSource->ReleasePage(fCurrentPage);
37 }
38 
39 void ROOT::Experimental::Detail::RColumn::Connect(DescriptorId_t fieldId, RPageStorage *pageStorage)
40 {
41  switch (pageStorage->GetType()) {
42  case EPageStorageType::kSink:
43  fPageSink = static_cast<RPageSink*>(pageStorage); // the page sink initializes fHeadPage on AddColumn
44  fHandleSink = fPageSink->AddColumn(fieldId, *this);
45  fHeadPage = fPageSink->ReservePage(fHandleSink);
46  break;
47  case EPageStorageType::kSource:
48  fPageSource = static_cast<RPageSource*>(pageStorage);
49  fHandleSource = fPageSource->AddColumn(fieldId, *this);
50  fNElements = fPageSource->GetNElements(fHandleSource);
51  fColumnIdSource = fPageSource->GetColumnId(fHandleSource);
52  break;
53  default:
54  R__ASSERT(false);
55  }
56 }
57 
58 void ROOT::Experimental::Detail::RColumn::Flush()
59 {
60  if (fHeadPage.GetSize() == 0) return;
61 
62  fPageSink->CommitPage(fHandleSink, fHeadPage);
63  fHeadPage.Reset(fNElements);
64 }
65 
66 void ROOT::Experimental::Detail::RColumn::MapPage(const NTupleSize_t index)
67 {
68  fPageSource->ReleasePage(fCurrentPage);
69  fCurrentPage = fPageSource->PopulatePage(fHandleSource, index);
70 }
71 
72 void ROOT::Experimental::Detail::RColumn::MapPage(const RClusterIndex &clusterIndex)
73 {
74  fPageSource->ReleasePage(fCurrentPage);
75  fCurrentPage = fPageSource->PopulatePage(fHandleSource, clusterIndex);
76 }