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#include <ROOT/TTaskGroup.hxx>
24#include <Compression.h>
25
26#include <memory>
27#include <optional>
28#include <string>
29#include <vector>
30#include <unordered_map>
31
33
35 /// The merger will discard all columns that aren't present in the prototype model (i.e. the model of the first
36 /// source)
37 kFilter,
38 /// The merger will refuse to merge any 2 RNTuples whose schema doesn't match exactly
39 kStrict,
40 /// The merger will update the output model to include all columns from all sources. Entries corresponding to columns
41 /// that are not present in a source will be set to the default value of the type.
42 kUnion
43};
44
46 /// The merger will abort merging as soon as an error is encountered
47 kAbort,
48 /// Upon errors, the merger will skip the current source and continue
49 kSkip
50};
51
52struct RColumnInfo;
53struct RNTupleMergeData;
54struct RSealedPageMergeData;
55
56class RClusterPool;
57
59 /// If `fCompressionSettings == kUnknownCompressionSettings` (the default), the merger will not change the
60 /// compression of any of its sources (fast merging). Otherwise, all sources will be converted to the specified
61 /// compression algorithm and level.
63 /// Determines how the merging treats sources with different models (\see ENTupleMergingMode).
65 /// Determines how the Merge function behaves upon merging errors
67 /// If true, the merger will emit further diagnostics and information.
68 bool fExtraVerbose = false;
69};
70
71// clang-format off
72/**
73 * \class ROOT::Experimental::Internal::RNTupleMerger
74 * \ingroup NTuple
75 * \brief Given a set of RPageSources merge them into an RPageSink, optionally changing their compression.
76 * This can also be used to change the compression of a single RNTuple by just passing a single source.
77 */
78// clang-format on
79class RNTupleMerger final {
80 std::unique_ptr<RPageAllocator> fPageAlloc;
81 std::optional<TTaskGroup> fTaskGroup;
82
83 void MergeCommonColumns(RClusterPool &clusterPool, DescriptorId_t clusterId, std::span<RColumnInfo> commonColumns,
84 RCluster::ColumnSet_t commonColumnSet, RSealedPageMergeData &sealedPageData,
85 const RNTupleMergeData &mergeData);
86
87 void MergeSourceClusters(RPageSource &source, std::span<RColumnInfo> commonColumns,
88 std::span<RColumnInfo> extraDstColumns, RNTupleMergeData &mergeData);
89
90public:
92
93 /// Merge a given set of sources into the destination.
94 RResult<void> Merge(std::span<RPageSource *> sources, RPageSink &destination,
95 const RNTupleMergeOptions &mergeOpts = RNTupleMergeOptions());
96
97}; // end of class RNTupleMerger
98
99} // namespace ROOT::Experimental::Internal
100
101#endif
Managed a set of clusters containing compressed and packed pages.
std::unordered_set< DescriptorId_t > ColumnSet_t
Definition RCluster.hxx:154
Given a set of RPageSources merge them into an RPageSink, optionally changing their compression.
RResult< void > Merge(std::span< RPageSource * > sources, RPageSink &destination, const RNTupleMergeOptions &mergeOpts=RNTupleMergeOptions())
Merge a given set of sources into the destination.
void MergeCommonColumns(RClusterPool &clusterPool, DescriptorId_t clusterId, std::span< RColumnInfo > commonColumns, RCluster::ColumnSet_t commonColumnSet, RSealedPageMergeData &sealedPageData, const RNTupleMergeData &mergeData)
std::unique_ptr< RPageAllocator > fPageAlloc
void MergeSourceClusters(RPageSource &source, std::span< RColumnInfo > commonColumns, std::span< RColumnInfo > extraDstColumns, RNTupleMergeData &mergeData)
Abstract interface to write data into an ntuple.
Abstract interface to read data from an ntuple.
The class is used as a return type for operations that can fail; wraps a value of type T or an RError...
Definition RError.hxx:194
@ kStrict
The merger will refuse to merge any 2 RNTuples whose schema doesn't match exactly.
@ kUnion
The merger will update the output model to include all columns from all sources.
@ kFilter
The merger will discard all columns that aren't present in the prototype model (i....
@ kAbort
The merger will abort merging as soon as an error is encountered.
@ kSkip
Upon errors, the merger will skip the current source and continue.
constexpr int kUnknownCompressionSettings
std::uint64_t DescriptorId_t
Distriniguishes elements of the same type within a descriptor, e.g. different fields.
int fCompressionSettings
If fCompressionSettings == kUnknownCompressionSettings (the default), the merger will not change the ...
ENTupleMergingMode fMergingMode
Determines how the merging treats sources with different models (.
ENTupleMergeErrBehavior fErrBehavior
Determines how the Merge function behaves upon merging errors.
bool fExtraVerbose
If true, the merger will emit further diagnostics and information.