File indexing completed on 2025-10-24 09:19:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef ROOT_RNTupleWriteOptions
0015 #define ROOT_RNTupleWriteOptions
0016
0017 #include <Compression.h>
0018
0019 #include <cstdint>
0020 #include <cstddef>
0021 #include <memory>
0022
0023 namespace ROOT {
0024
0025 class RNTupleWriteOptions;
0026
0027 namespace Internal {
0028
0029 class RNTupleWriteOptionsManip final {
0030 public:
0031 static void SetMaxKeySize(RNTupleWriteOptions &options, std::uint64_t maxKeySize);
0032 };
0033
0034 }
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 class RNTupleWriteOptions {
0178 public:
0179 enum class EImplicitMT {
0180 kOff,
0181 kDefault,
0182 };
0183
0184
0185 static constexpr std::uint64_t kDefaultMaxKeySize = 0x4000'0000; // 1 GiB
0186 // clang-format on
0187
0188 friend Internal::RNTupleWriteOptionsManip;
0189
0190 protected:
0191 std::uint32_t fCompression{RCompressionSetting::EDefaults::kUseGeneralPurpose};
0192 std::size_t fApproxZippedClusterSize = 128 * 1024 * 1024;
0193 std::size_t fMaxUnzippedClusterSize = 10 * fApproxZippedClusterSize;
0194 std::size_t fInitialUnzippedPageSize = 256;
0195 std::size_t fMaxUnzippedPageSize = 1024 * 1024;
0196 std::size_t fPageBufferBudget = 0;
0197 bool fUseBufferedWrite = true;
0198 bool fUseDirectIO = false;
0199 std::size_t fWriteBufferSize = 4 * 1024 * 1024;
0200 EImplicitMT fUseImplicitMT = EImplicitMT::kDefault;
0201 bool fEnablePageChecksums = true;
0202 bool fEnableSamePageMerging = true;
0203 /// Specifies the max size of a payload storeable into a single TKey. When writing an RNTuple to a ROOT file,
0204 /// any payload whose size exceeds this will be split into multiple keys.
0205 std::uint64_t fMaxKeySize = kDefaultMaxKeySize;
0206
0207 public:
0208
0209 virtual ~RNTupleWriteOptions() = default;
0210 virtual std::unique_ptr<RNTupleWriteOptions> Clone() const;
0211
0212 std::uint32_t GetCompression() const { return fCompression; }
0213 void SetCompression(std::uint32_t val) { fCompression = val; }
0214 void SetCompression(RCompressionSetting::EAlgorithm::EValues algorithm, int compressionLevel)
0215 {
0216 fCompression = CompressionSettings(algorithm, compressionLevel);
0217 }
0218
0219 std::size_t GetApproxZippedClusterSize() const { return fApproxZippedClusterSize; }
0220 void SetApproxZippedClusterSize(std::size_t val);
0221
0222 std::size_t GetMaxUnzippedClusterSize() const { return fMaxUnzippedClusterSize; }
0223 void SetMaxUnzippedClusterSize(std::size_t val);
0224
0225 std::size_t GetInitialUnzippedPageSize() const { return fInitialUnzippedPageSize; }
0226 void SetInitialUnzippedPageSize(std::size_t val);
0227
0228 std::size_t GetMaxUnzippedPageSize() const { return fMaxUnzippedPageSize; }
0229 void SetMaxUnzippedPageSize(std::size_t val);
0230
0231 std::size_t GetPageBufferBudget() const;
0232 void SetPageBufferBudget(std::size_t val) { fPageBufferBudget = val; }
0233
0234 bool GetUseBufferedWrite() const { return fUseBufferedWrite; }
0235 void SetUseBufferedWrite(bool val) { fUseBufferedWrite = val; }
0236
0237 bool GetUseDirectIO() const { return fUseDirectIO; }
0238 void SetUseDirectIO(bool val) { fUseDirectIO = val; }
0239
0240 std::size_t GetWriteBufferSize() const { return fWriteBufferSize; }
0241 void SetWriteBufferSize(std::size_t val) { fWriteBufferSize = val; }
0242
0243 EImplicitMT GetUseImplicitMT() const { return fUseImplicitMT; }
0244 void SetUseImplicitMT(EImplicitMT val) { fUseImplicitMT = val; }
0245
0246 bool GetEnablePageChecksums() const { return fEnablePageChecksums; }
0247 /// Note that turning off page checksums will also turn off the same page merging optimization (see tuning.md)
0248 void SetEnablePageChecksums(bool val)
0249 {
0250 fEnablePageChecksums = val;
0251 if (!fEnablePageChecksums) {
0252 fEnableSamePageMerging = false;
0253 }
0254 }
0255
0256 bool GetEnableSamePageMerging() const { return fEnableSamePageMerging; }
0257 void SetEnableSamePageMerging(bool val);
0258
0259 std::uint64_t GetMaxKeySize() const { return fMaxKeySize; }
0260 };
0261
0262 namespace Internal {
0263 inline void RNTupleWriteOptionsManip::SetMaxKeySize(RNTupleWriteOptions &options, std::uint64_t maxKeySize)
0264 {
0265 options.fMaxKeySize = maxKeySize;
0266 }
0267
0268 } // namespace Internal
0269 } // namespace ROOT
0270
0271 #endif // ROOT_RNTupleWriteOptions