![]() |
|
|||
Warning, file /include/root/ROOT/RNTupleMerger.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /// \file ROOT/RNTupleMerger.hxx 0002 /// \ingroup NTuple 0003 /// \author Jakob Blomer <jblomer@cern.ch>, Max Orok <maxwellorok@gmail.com>, Alaettin Serhan Mete <amete@anl.gov> 0004 /// \date 2020-07-08 0005 /// \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback 0006 /// is welcome! 0007 0008 /************************************************************************* 0009 * Copyright (C) 1995-2020, Rene Brun and Fons Rademakers. * 0010 * All rights reserved. * 0011 * * 0012 * For the licensing terms see $ROOTSYS/LICENSE. * 0013 * For the list of contributors see $ROOTSYS/README/CREDITS. * 0014 *************************************************************************/ 0015 0016 #ifndef ROOT_RNTupleMerger 0017 #define ROOT_RNTupleMerger 0018 0019 #include <ROOT/RError.hxx> 0020 #include <ROOT/RNTupleDescriptor.hxx> 0021 #include <ROOT/RNTupleUtil.hxx> 0022 #include <ROOT/RPageStorage.hxx> 0023 #include <ROOT/TTaskGroup.hxx> 0024 #include <Compression.h> 0025 0026 #include <memory> 0027 #include <optional> 0028 0029 namespace ROOT { 0030 0031 class RNTuple; 0032 0033 namespace Internal { 0034 class RPageAllocator; 0035 class RClusterPool; 0036 } 0037 0038 namespace Experimental::Internal { 0039 0040 enum class ENTupleMergingMode { 0041 /// The merger will discard all columns that aren't present in the prototype model (i.e. the model of the first 0042 /// source); also all subsequent RNTuples must contain at least all the columns that are present in the prototype 0043 /// model 0044 kFilter, 0045 /// The merger will refuse to merge any 2 RNTuples whose schema doesn't match exactly 0046 kStrict, 0047 /// The merger will update the output model to include all columns from all sources. Entries corresponding to columns 0048 /// that are not present in a source will be set to the default value of the type. 0049 kUnion 0050 }; 0051 0052 enum class ENTupleMergeErrBehavior { 0053 /// The merger will abort merging as soon as an error is encountered 0054 kAbort, 0055 /// Upon errors, the merger will skip the current source and continue 0056 kSkip 0057 }; 0058 0059 struct RColumnMergeInfo; 0060 struct RNTupleMergeData; 0061 struct RSealedPageMergeData; 0062 0063 /// Set of merging options to pass to RNTupleMerger. 0064 /// If you're using the merger through TFileMerger you need to give it string-based options instead. 0065 /// Here is the mapping for the TFileMerger options: 0066 /// - "rntuple.MergingMode=(Filter|Union|...)" -> sets fMergingMode 0067 /// - "rntuple.ErrBehavior=(Abort|Skip|...)" -> sets fErrBehavior 0068 /// - "rntuple.ExtraVerbose" -> sets fExtraVerbose to true 0069 /// Rules about the string-based options: 0070 /// 1. there must be no space between the separators (i.e. `.` and `=`) 0071 /// 2. all string matching is case insensitive 0072 struct RNTupleMergeOptions { 0073 /// If fCompressionSettings is empty (the default), the merger will not change the 0074 /// compression of any of its sources (fast merging). Otherwise, all sources will be converted to the specified 0075 /// compression algorithm and level. 0076 std::optional<std::uint32_t> fCompressionSettings; 0077 /// Determines how the merging treats sources with different models (\see ENTupleMergingMode). 0078 ENTupleMergingMode fMergingMode = ENTupleMergingMode::kFilter; 0079 /// Determines how the Merge function behaves upon merging errors 0080 ENTupleMergeErrBehavior fErrBehavior = ENTupleMergeErrBehavior::kAbort; 0081 /// If true, the merger will emit further diagnostics and information. 0082 bool fExtraVerbose = false; 0083 }; 0084 0085 // clang-format off 0086 /** 0087 * \class ROOT::Experimental::Internal::RNTupleMerger 0088 * \ingroup NTuple 0089 * \brief Given a set of RPageSources merge them into an RPagePersistentSink, optionally changing their compression. 0090 * This can also be used to change the compression of a single RNTuple by just passing a single source. 0091 */ 0092 // clang-format on 0093 class RNTupleMerger final { 0094 friend class ROOT::RNTuple; 0095 0096 std::unique_ptr<ROOT::Internal::RPagePersistentSink> fDestination; 0097 std::unique_ptr<ROOT::Internal::RPageAllocator> fPageAlloc; 0098 std::optional<TTaskGroup> fTaskGroup; 0099 std::unique_ptr<ROOT::RNTupleModel> fModel; 0100 0101 void MergeCommonColumns(ROOT::Internal::RClusterPool &clusterPool, const ROOT::RClusterDescriptor &clusterDesc, 0102 std::span<const RColumnMergeInfo> commonColumns, 0103 const ROOT::Internal::RCluster::ColumnSet_t &commonColumnSet, 0104 std::size_t nCommonColumnsInCluster, RSealedPageMergeData &sealedPageData, 0105 const RNTupleMergeData &mergeData, ROOT::Internal::RPageAllocator &pageAlloc); 0106 0107 void MergeSourceClusters(ROOT::Internal::RPageSource &source, std::span<const RColumnMergeInfo> commonColumns, 0108 std::span<const RColumnMergeInfo> extraDstColumns, RNTupleMergeData &mergeData); 0109 0110 /// Creates a RNTupleMerger with the given destination. 0111 /// The model must be given if and only if `destination` has been initialized with that model 0112 /// (i.e. in case of incremental merging). 0113 RNTupleMerger(std::unique_ptr<ROOT::Internal::RPagePersistentSink> destination, 0114 std::unique_ptr<ROOT::RNTupleModel> model); 0115 0116 public: 0117 /// Creates a RNTupleMerger with the given destination. 0118 explicit RNTupleMerger(std::unique_ptr<ROOT::Internal::RPagePersistentSink> destination); 0119 0120 /// Merge a given set of sources into the destination. 0121 /// Note that sources with an empty schema (i.e. created from a Model that had no fields added to it) are in 0122 /// general valid (depending on the merging mode) but add no entries to the destination. 0123 RResult<void> Merge(std::span<ROOT::Internal::RPageSource *> sources, 0124 const RNTupleMergeOptions &mergeOpts = RNTupleMergeOptions()); 0125 0126 }; // end of class RNTupleMerger 0127 0128 } // namespace Experimental::Internal 0129 } // namespace ROOT 0130 0131 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |