Skip to content

Commit

Permalink
feat: add RNTuple with multiple cluster groups (#168)
Browse files Browse the repository at this point in the history
* Added RNTuple with multiple cluster groups

* Small tweaks
  • Loading branch information
ariostas authored Jan 9, 2025
1 parent 797693e commit ec6501d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions dev/make-root/rntuple_multiple_cluster_groups.C
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 not shown.

0 comments on commit ec6501d

Please sign in to comment.