Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/ROOT/RSnapshotOptions.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // Author: Guilherme Amadio, Enrico Guiraud, Danilo Piparo CERN  2/2018
0002 
0003 /*************************************************************************
0004  * Copyright (C) 1995-2018, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOT_RSNAPSHOTOPTIONS
0012 #define ROOT_RSNAPSHOTOPTIONS
0013 
0014 #include <Compression.h>
0015 #include <string_view>
0016 #include <string>
0017 
0018 namespace ROOT {
0019 
0020 namespace RDF {
0021 enum class ESnapshotOutputFormat {
0022    kDefault,
0023    kTTree,
0024    kRNTuple
0025 };
0026 
0027 // clang-format off
0028 /**
0029 \struct ROOT::RDF::RSnapshotOptions
0030 \brief A collection of options to steer the creation of the dataset on disk through Snapshot().
0031 
0032 Some settings are output format-dependent. Please refer to the table below for an overview of all options, and to which
0033 output format they apply.
0034 
0035 Note that for RNTuple, the defaults correspond to those set in RNTupleWriteOptions.
0036 
0037 <table>
0038 <thead>
0039 <tr>
0040 <th>Format</th>
0041 <th>Option</th>
0042 <th>Type</th>
0043 <th>Default</th>
0044 <th>Description</th>
0045 </tr>
0046 </thead>
0047 <tbody>
0048 <tr>
0049 <td rowspan="8">All</td>
0050 <td><code>fMode</code></td>
0051 <td><code>std::string</code></td>
0052 <td>&quot;RECREATE&quot;</td>
0053 <td>Creation mode for the output TFile</td>
0054 </tr>
0055 <tr>
0056 <td><code>fCompressionAlgorithm</code></td>
0057 <td><code>ROOT::RCompressionSetting::EAlgorithm</code></td>
0058 <td>Zstd</td>
0059 <td>Compression algorithm for the output dataset</td>
0060 </tr>
0061 <tr>
0062 <td><code>fCompressionLevel</code></td>
0063 <td><code>int</code></td>
0064 <td>5</td>
0065 <td>Compression level for the output dataset</td>
0066 </tr>
0067 <tr>
0068 <td><code>fOutputFormat</code></td>
0069 <td><code>ROOT::RDF::ESnapshotOutputFormat</code></td>
0070 <td>TTree</td>
0071 <td>Which output data format to use</td>
0072 </tr>
0073 <tr>
0074 <td><code>fLazy</code></td>
0075 <td><code>bool</code></td>
0076 <td>False</td>
0077 <td>Whether to immediately start the event loop when Snapshot() is called</td>
0078 </tr>
0079 <tr>
0080 <td><code>fOverwriteIfExists</code></td>
0081 <td><code>bool</code></td>
0082 <td>False</td>
0083 <td>If <code>fMode</code> is &quot;UPDATE&quot;, overwrite the object with the same name in the output file already present</td>
0084 </tr>
0085 <tr>
0086 <td><code>fVector2RVec</code></td>
0087 <td><code>bool</code></td>
0088 <td>True</td>
0089 <td>Store <code>std::vector</code>-type columns as <code>ROOT::RVec</code> in the output</td>
0090 </tr>
0091 <tr>
0092 <td><code>fIncludeInVariations</code></td>
0093 <td><code>bool</code></td>
0094 <td>False</td>
0095 <td>Include columns that result from a Vary() action in the output</td>
0096 </tr>
0097 <tr>
0098 <td rowspan="3">TTree</td>
0099 <td><code>fAutoFlush</code></td>
0100 <td><code>int</code></td>
0101 <td>0</td>
0102 <td>AutoFlush setting for the output (see TTree::SetAutoFlush())</td>
0103 </tr>
0104 <tr>
0105 <td><code>fSplitLevel</code></td>
0106 <td><code>int</code></td>
0107 <td>99</td>
0108 <td>Split level of the output branches</td>
0109 </tr>
0110 <tr>
0111 <td><code>fBasketSize</code></td>
0112 <td><code>int</code></td>
0113 <td>-1</td>
0114 <td>Output basket size (a value of -1 means the TTree default of 32000 B used)</td>
0115 </tr>
0116 <tr>
0117 <td rowspan="6">RNTuple</td>
0118 <td><code>fApproxZippedClusterSize</code></td>
0119 <td><code>std::size_t</code></td>
0120 <td>128 MiB</td>
0121 <td>Approximate output compressed cluster size</td>
0122 </tr>
0123 <tr>
0124 <td><code>fMaxUnzippedClusterSize</code></td>
0125 <td><code>std::size_t</code></td>
0126 <td>1280 MiB</td>
0127 <td>Maximum uncompressed output cluster size</td>
0128 </tr>
0129 <tr>
0130 <td><code>fInitialUnzippedPageSize</code></td>
0131 <td><code>std::size_t</code></td>
0132 <td>256 B</td>
0133 <td>Initial output page size before compression</td>
0134 </tr>
0135 <tr>
0136 <td><code>fMaxUnzippedPageSize</code></td>
0137 <td><code>std::size_t</code></td>
0138 <td>1 MiB</td>
0139 <td>Maximum allowed output page size before compression</td>
0140 </tr>
0141 <tr>
0142 <td><code>fEnablePageChecksums</code></td>
0143 <td><code>bool</code></td>
0144 <td>True</td>
0145 <td>Enable checksumming for output pages</td>
0146 </tr>
0147 <tr>
0148 <td><code>fEnableSamePageMerging</code></td>
0149 <td><code>bool</code></td>
0150 <td>True</td>
0151 <td>Enable identical-page deduplication (requires page checksumming enabled)</td>
0152 </tr>
0153 </tbody>
0154 </table>
0155 */
0156 // clang-format on
0157 struct RSnapshotOptions {
0158    using ECAlgo = ROOT::RCompressionSetting::EAlgorithm::EValues;
0159    RSnapshotOptions() = default;
0160    RSnapshotOptions(std::string_view mode, ECAlgo comprAlgo, int comprLevel, int autoFlush, int splitLevel, bool lazy,
0161                     bool overwriteIfExists = false, bool vector2RVec = true, int basketSize = -1,
0162                     std::size_t approxZippedClusterSize = 128 * 1024 * 1024,
0163                     std::size_t maxUnzippedClusterSize = 10 * 128 * 1024 * 1024,
0164                     std::size_t maxUnzippedPageSize = 1024 * 1024, std::size_t initUnzippedPageSize = 256,
0165                     bool enablePageChecksums = true, bool enableSamePageMerging = true,
0166                     ESnapshotOutputFormat outputFormat = ESnapshotOutputFormat::kDefault)
0167       : fMode(mode),
0168         fOutputFormat(outputFormat),
0169         fCompressionAlgorithm(comprAlgo),
0170         fCompressionLevel{comprLevel},
0171         fLazy(lazy),
0172         fOverwriteIfExists(overwriteIfExists),
0173         fVector2RVec(vector2RVec),
0174         fAutoFlush(autoFlush),
0175         fSplitLevel(splitLevel),
0176         fBasketSize(basketSize),
0177         fApproxZippedClusterSize(approxZippedClusterSize),
0178         fMaxUnzippedClusterSize(maxUnzippedClusterSize),
0179         fInitialUnzippedPageSize(initUnzippedPageSize),
0180         fMaxUnzippedPageSize(maxUnzippedPageSize),
0181         fEnablePageChecksums(enablePageChecksums),
0182         fEnableSamePageMerging(enableSamePageMerging)
0183    {
0184    }
0185    std::string fMode = "RECREATE"; ///< Mode of creation of output file
0186    ESnapshotOutputFormat fOutputFormat = ESnapshotOutputFormat::kDefault; ///< Which data format to write to
0187    ECAlgo fCompressionAlgorithm =
0188       ROOT::RCompressionSetting::EAlgorithm::kZSTD; ///< Compression algorithm of output file
0189    int fCompressionLevel = 5;                       ///< Compression level of output file
0190    bool fLazy = false;                              ///< Do not start the event loop when Snapshot is called
0191    bool fOverwriteIfExists = false;  ///< If fMode is "UPDATE", overwrite object in output file if it already exists
0192    bool fVector2RVec = true;         ///< If set to true will convert std::vector columns to RVec when saving to disk
0193    bool fIncludeVariations = false;  ///< Include columns that result from a Vary() action
0194 
0195    /// *(TTree only)* AutoFlush value for output tree
0196    int fAutoFlush = 0;
0197    /// *(TTree only)* Split level of output tree
0198    int fSplitLevel = 99;
0199    /// *(TTree only)* Set a custom basket size option. For more details, see
0200    /// https://root.cern/manual/trees/#baskets-clusters-and-the-tree-header
0201    int fBasketSize = -1;
0202 
0203    /// *(RNTuple only)* Approximate target compressed cluster size
0204    std::size_t fApproxZippedClusterSize = 128 * 1024 * 1024;
0205    /// *(RNTuple only)* Maximum uncompressed cluster size
0206    std::size_t fMaxUnzippedClusterSize = 10 * fApproxZippedClusterSize;
0207    /// *(RNTuple only)* Initial page size before compression
0208    std::size_t fInitialUnzippedPageSize = 256;
0209    /// *(RNTuple only)* Maximum allowed page size before compression
0210    std::size_t fMaxUnzippedPageSize = 1024 * 1024;
0211    /// *(RNTuple only)* Enable checksumming for pages
0212    bool fEnablePageChecksums = true;
0213    /// *(RNTuple only)* Enable identical-page deduplication. Requires page checksumming
0214    bool fEnableSamePageMerging = true;
0215 };
0216 } // namespace RDF
0217 } // namespace ROOT
0218 
0219 #endif