forked from root-project/rntuple-validation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrite_algorithm.hxx
More file actions
31 lines (26 loc) · 944 Bytes
/
Copy pathwrite_algorithm.hxx
File metadata and controls
31 lines (26 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <ROOT/RNTupleModel.hxx>
#if __has_include(<ROOT/RNTupleTypes.hxx>)
#include <ROOT/RNTupleTypes.hxx>
#else
#include <ROOT/RNTupleUtil.hxx>
#endif
#include <ROOT/RNTupleWriteOptions.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <cstdint>
#include <memory>
#include <string_view>
void write_algorithm(std::string_view filename, std::uint32_t compression) {
auto model = ROOT::RNTupleModel::Create();
auto Int64 = model->MakeField<std::int64_t>("Int64");
model->GetMutableField("Int64").SetColumnRepresentatives(
{{ROOT::ENTupleColumnType::kSplitInt64}});
ROOT::RNTupleWriteOptions options;
options.SetCompression(compression);
auto writer = ROOT::RNTupleWriter::Recreate(std::move(model), "ntpl",
filename, options);
// Write 32 entries to make sure the compression block is not too small.
for (int i = 0; i < 32; i++) {
*Int64 = i;
writer->Fill();
}
}