Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RNTupleMerger.hxx
Go to the documentation of this file.
1/// \file ROOT/RNTupleMerger.hxx
2/// \ingroup NTuple ROOT7
3/// \author Jakob Blomer <jblomer@cern.ch>, Max Orok <maxwellorok@gmail.com>, Alaettin Serhan Mete <amete@anl.gov>
4/// \date 2020-07-08
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-2020, 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#ifndef ROOT7_RNTupleMerger
17#define ROOT7_RNTupleMerger
18
19#include <ROOT/RError.hxx>
21#include <ROOT/RNTupleUtil.hxx>
22#include <ROOT/RPageStorage.hxx>
23
24#include <memory>
25#include <string>
26#include <vector>
27#include <unordered_map>
28
29namespace ROOT {
30namespace Experimental {
31namespace Internal {
32
33// clang-format off
34/**
35 * \class ROOT::Experimental::Internal::RNTupleMerger
36 * \ingroup NTuple
37 * \brief Given a set of RPageSources merge them into an RPageSink
38 */
39// clang-format on
41
42private:
43 // Struct to hold column information
44 struct RColumnInfo {
45 std::string fColumnName; ///< The qualified field name to which the column belongs, followed by the column index
46 std::string fColumnTypeAndVersion; ///< "<type>.<version>" of the field to which the column belongs
49
50 RColumnInfo(const std::string &name, const std::string &typeAndVersion, const DescriptorId_t &inputId,
51 const DescriptorId_t &outputId)
52 : fColumnName(name), fColumnTypeAndVersion(typeAndVersion), fColumnInputId(inputId), fColumnOutputId(outputId)
53 {
54 }
55 };
56
57 /// Build the internal column id map from the first source
58 /// This is where we assign the output ids for the first source
59 void BuildColumnIdMap(std::vector<RColumnInfo> &columns);
60
61 /// Validate the columns against the internal map that is built from the first source
62 /// This is where we assign the output ids for the remaining sources
63 void ValidateColumns(std::vector<RColumnInfo> &columns);
64
65 /// Recursively add columns from a given field
66 void AddColumnsFromField(std::vector<RColumnInfo> &columns, const RNTupleDescriptor &desc,
67 const RFieldDescriptor &fieldDesc, const std::string &prefix = "");
68
69 /// Recursively collect all the columns for all the fields rooted at field zero
70 std::vector<RColumnInfo> CollectColumns(const RPageSource &source, bool firstSource);
71
72 // Internal map that holds column name, type, and type id : output ID information
73 std::unordered_map<std::string, DescriptorId_t> fOutputIdMap;
74
75public:
76 /// Merge a given set of sources into the destination
77 void Merge(std::span<RPageSource *> sources, RPageSink &destination);
78
79}; // end of class RNTupleMerger
80
81} // namespace Internal
82} // namespace Experimental
83} // namespace ROOT
84
85#endif
char name[80]
Definition TGX11.cxx:110
Given a set of RPageSources merge them into an RPageSink.
std::unordered_map< std::string, DescriptorId_t > fOutputIdMap
void AddColumnsFromField(std::vector< RColumnInfo > &columns, const RNTupleDescriptor &desc, const RFieldDescriptor &fieldDesc, const std::string &prefix="")
Recursively add columns from a given field.
void Merge(std::span< RPageSource * > sources, RPageSink &destination)
Merge a given set of sources into the destination.
std::vector< RColumnInfo > CollectColumns(const RPageSource &source, bool firstSource)
Recursively collect all the columns for all the fields rooted at field zero.
void BuildColumnIdMap(std::vector< RColumnInfo > &columns)
Build the internal column id map from the first source This is where we assign the output ids for the...
void ValidateColumns(std::vector< RColumnInfo > &columns)
Validate the columns against the internal map that is built from the first source This is where we as...
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
Meta-data stored for every field of an ntuple.
The on-storage meta-data of an ntuple.
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
std::string fColumnName
The qualified field name to which the column belongs, followed by the column index.
RColumnInfo(const std::string &name, const std::string &typeAndVersion, const DescriptorId_t &inputId, const DescriptorId_t &outputId)
std::string fColumnTypeAndVersion
"<type>.<version>" of the field to which the column belongs