-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add RNTuple with multiple cluster groups (#168)
* Added RNTuple with multiple cluster groups * Small tweaks
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* https://root.cern/doc/master/ntpl001__staff_8C.html */ | ||
/* this file tests when we have multiple pages, each page stores 65536 bytes, | ||
* thus we need to make it longer */ | ||
/* https://github.com/scikit-hep/uproot5/pull/630 */ | ||
|
||
R__LOAD_LIBRARY(ROOTNTuple) | ||
#include <ROOT/RField.hxx> | ||
#include <ROOT/RNTuple.hxx> | ||
#include <ROOT/RNTupleModel.hxx> | ||
#include <ROOT/RNTupleWriter.hxx> | ||
#include <ROOT/RRawFile.hxx> | ||
|
||
using RNTupleModel = ROOT::Experimental::RNTupleModel; | ||
using RNTupleWriter = ROOT::Experimental::RNTupleWriter; | ||
|
||
void rntuple_multiple_cluster_groups() { | ||
std::string rootFileName{"test_multiple_cluster_groups_rntuple_v1-0-0-0.root"}; | ||
auto model = RNTupleModel::Create(); | ||
auto int_field = model->MakeField<int>("one"); | ||
auto int_vector = model->MakeField<std::vector<int16_t>>("int_vector"); | ||
auto ntuple = | ||
RNTupleWriter::Recreate(std::move(model), "ntuple", rootFileName); | ||
for(auto i=0; i<1000; i++){ | ||
if (i && i%100==0) { | ||
ntuple->CommitCluster(); | ||
} | ||
if (i == 450 || i == 750) { // to add a bit of unevenness | ||
ntuple->CommitCluster(/*commitClusterGroup*/ true); | ||
} | ||
*int_field = i; | ||
*int_vector = {static_cast<int16_t>(i), static_cast<int16_t>(i+1)}; | ||
ntuple->Fill(); | ||
} | ||
} |
Binary file added
BIN
+6.99 KB
src/skhep_testdata/data/test_multiple_cluster_groups_rntuple_v1-0-0-0.root
Binary file not shown.