@@ -101,25 +101,93 @@ TEST(RDFSnapshotRNTuple, LazyNotTriggered)
101
101
EXPECT_TRUE (gSystem ->AccessPathName (fileGuard.GetPath ().c_str ()));
102
102
}
103
103
104
- TEST (RDFSnapshotRNTuple, Compression )
104
+ TEST (RDFSnapshotRNTuple, WriteOpts )
105
105
{
106
- FileRAII fileGuard{" RDFSnapshotRNTuple_compression .root" };
106
+ FileRAII fileGuard{" RDFSnapshotRNTuple_write_opts .root" };
107
107
const std::vector<std::string> columns = {" x" };
108
108
109
109
auto df = ROOT::RDataFrame (25ull ).Define (" x" , [] { return 10 ; });
110
110
111
+ ROOT::RNTupleWriteOptions writeOpts;
112
+ writeOpts.SetEnablePageChecksums (false );
113
+
111
114
RSnapshotOptions opts;
112
115
opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
113
- opts.fCompressionAlgorithm = ROOT::RCompressionSetting::EAlgorithm::kLZ4 ;
114
- opts.fCompressionLevel = 4 ;
116
+ opts.fNTupleWriteOpts = writeOpts;
115
117
116
118
auto sdf = df.Snapshot (" ntuple" , fileGuard.GetPath (), " x" , opts);
117
119
118
120
EXPECT_EQ (columns, sdf->GetColumnNames ());
119
121
120
122
auto reader = RNTupleReader::Open (" ntuple" , fileGuard.GetPath ());
121
- auto compSettings = *reader->GetDescriptor ().GetClusterDescriptor (0 ).GetColumnRange (0 ).GetCompressionSettings ();
122
- EXPECT_EQ (404 , compSettings);
123
+ EXPECT_FALSE (reader->GetDescriptor ().GetClusterDescriptor (0 ).GetPageRange (0 ).GetPageInfos ()[0 ].HasChecksum ());
124
+ }
125
+
126
+ TEST (RDFSnapshotRNTuple, Compression)
127
+ {
128
+ FileRAII fileGuard{" RDFSnapshotRNTuple_compression.root" };
129
+ const std::vector<std::string> columns = {" x" };
130
+
131
+ auto df = ROOT::RDataFrame (25ull ).Define (" x" , [] { return 10 ; });
132
+
133
+ // Default should be taken from RNTupleWriteOptions provided by RSnapshotOptions (zstd)
134
+ {
135
+ RSnapshotOptions opts;
136
+ opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
137
+
138
+ auto sdf = df.Snapshot (" ntuple" , fileGuard.GetPath (), " x" , opts);
139
+
140
+ EXPECT_EQ (columns, sdf->GetColumnNames ());
141
+
142
+ auto reader = RNTupleReader::Open (" ntuple" , fileGuard.GetPath ());
143
+ auto compSettings = *reader->GetDescriptor ().GetClusterDescriptor (0 ).GetColumnRange (0 ).GetCompressionSettings ();
144
+ EXPECT_EQ (505 , compSettings);
145
+ }
146
+ // Directly through RSnapshotOptions
147
+ {
148
+ RSnapshotOptions opts;
149
+ opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
150
+ opts.fCompressionAlgorithm = ROOT::RCompressionSetting::EAlgorithm::kLZ4 ;
151
+ opts.fCompressionLevel = 4 ;
152
+
153
+ auto sdf = df.Snapshot (" ntuple" , fileGuard.GetPath (), " x" , opts);
154
+
155
+ EXPECT_EQ (columns, sdf->GetColumnNames ());
156
+
157
+ auto reader = RNTupleReader::Open (" ntuple" , fileGuard.GetPath ());
158
+ auto compSettings = *reader->GetDescriptor ().GetClusterDescriptor (0 ).GetColumnRange (0 ).GetCompressionSettings ();
159
+ EXPECT_EQ (404 , compSettings);
160
+ }
161
+ // Through RNTupleWriteOptions provided by RSnapshotOptions
162
+ {
163
+ RSnapshotOptions opts;
164
+ opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
165
+ opts.fNTupleWriteOpts .SetCompression (404 );
166
+
167
+ auto sdf = df.Snapshot (" ntuple" , fileGuard.GetPath (), " x" , opts);
168
+
169
+ EXPECT_EQ (columns, sdf->GetColumnNames ());
170
+
171
+ auto reader = RNTupleReader::Open (" ntuple" , fileGuard.GetPath ());
172
+ auto compSettings = *reader->GetDescriptor ().GetClusterDescriptor (0 ).GetColumnRange (0 ).GetCompressionSettings ();
173
+ EXPECT_EQ (404 , compSettings);
174
+ }
175
+ // When both are set, preference is given to RNTupleWriteOptions
176
+ {
177
+ RSnapshotOptions opts;
178
+ opts.fOutputFormat = ROOT::RDF::ESnapshotOutputFormat::kRNTuple ;
179
+ opts.fCompressionAlgorithm = ROOT::RCompressionSetting::EAlgorithm::kLZ4 ;
180
+ opts.fCompressionLevel = 4 ;
181
+ opts.fNTupleWriteOpts .SetCompression (207 );
182
+
183
+ auto sdf = df.Snapshot (" ntuple" , fileGuard.GetPath (), " x" , opts);
184
+
185
+ EXPECT_EQ (columns, sdf->GetColumnNames ());
186
+
187
+ auto reader = RNTupleReader::Open (" ntuple" , fileGuard.GetPath ());
188
+ auto compSettings = *reader->GetDescriptor ().GetClusterDescriptor (0 ).GetColumnRange (0 ).GetCompressionSettings ();
189
+ EXPECT_EQ (207 , compSettings);
190
+ }
123
191
}
124
192
125
193
class RDFSnapshotRNTupleTest : public ::testing::Test {
0 commit comments