Skip to content

Commit 7335adc

Browse files
authored
DPL: more fixes to handle the ROOT v6-36-00 (#14341)
- More tweaks to get ROOT::Experimental out of the way - RNTuples cannot have / as first character in name
1 parent 6bb3383 commit 7335adc

File tree

4 files changed

+45
-20
lines changed

4 files changed

+45
-20
lines changed

Framework/AnalysisSupport/src/Plugin.cxx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,11 @@ std::vector<std::string> getListOfTables(std::unique_ptr<TFile>& f)
121121
break;
122122
}
123123

124+
#if __has_include(<ROOT/RFieldBase.hxx>)
124125
void* v = f->GetObjectChecked(key->GetName(), TClass::GetClass("ROOT::RNTuple"));
125-
if (!v) {
126-
v = f->GetObjectChecked(key->GetName(), TClass::GetClass("ROOT::Experimental::RNTuple"));
127-
}
126+
#else
127+
void* v = f->GetObjectChecked(key->GetName(), TClass::GetClass("ROOT::Experimental::RNTuple"));
128+
#endif
128129
if (v) {
129130
std::string s = key->GetName();
130131
size_t pos = s.find('-');

Framework/AnalysisSupport/src/RNTuplePlugin.cxx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ using DPLFieldToken = rns::REntry::RFieldToken;
4545
using DPLLocalIndex = rns::RClusterIndex;
4646
#endif
4747

48-
4948
template class
5049
std::unique_ptr<rns::RNTupleReader>;
5150

@@ -188,15 +187,17 @@ class RNTupleFileFormat : public arrow::dataset::FileFormat
188187
};
189188

190189
template <typename T>
191-
requires requires (T&& f) { f.GetSubFields(); }
192-
auto getSubfields(T const&field) {
193-
return field.GetSubFields();
190+
requires requires(T&& f) { f.GetSubFields(); }
191+
auto getSubfields(T const& field)
192+
{
193+
return field.GetSubFields();
194194
}
195195

196196
template <typename T>
197-
requires requires (T&& f) { f.GetConstSubfields(); }
198-
auto getSubfields(T const&field) {
199-
return field.GetConstSubfields();
197+
requires requires(T&& f) { f.GetConstSubfields(); }
198+
auto getSubfields(T const& field)
199+
{
200+
return field.GetConstSubfields();
200201
}
201202

202203
struct RootNTupleVisitor : public rns::Detail::RFieldVisitor {
@@ -284,7 +285,6 @@ struct RootNTupleVisitor : public rns::Detail::RFieldVisitor {
284285
}
285286
#endif
286287

287-
288288
void VisitBoolField(const rns::RField<bool>& field) override
289289
{
290290
this->datatype = arrow::boolean();
@@ -562,18 +562,19 @@ class RNTupleFileWriter : public arrow::dataset::FileWriter
562562
};
563563

564564
template <typename T>
565-
requires requires (T const&m) { m.GetFieldZero(); }
566-
auto &getFieldZero(T const &m) {
565+
requires requires(T const& m) { m.GetFieldZero(); }
566+
auto& getFieldZero(T const& m)
567+
{
567568
return m.GetFieldZero();
568569
}
569570

570571
template <typename T>
571-
requires requires (T const&m) { m.GetConstFieldZero(); }
572-
auto &getFieldZero(T const &m) {
572+
requires requires(T const& m) { m.GetConstFieldZero(); }
573+
auto& getFieldZero(T const& m)
574+
{
573575
return m.GetConstFieldZero();
574576
}
575577

576-
577578
arrow::Result<std::shared_ptr<arrow::Schema>> RNTupleFileFormat::Inspect(const arrow::dataset::FileSource& source) const
578579
{
579580

Framework/Core/src/Plugin.cxx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,21 +222,36 @@ struct RNTupleObjectReadingCapability : o2::framework::RootObjectReadingCapabili
222222
{
223223
auto context = new ImplementationContext;
224224

225-
return new RootObjectReadingCapability{
225+
return new RootObjectReadingCapability
226+
{
226227
.name = "rntuple",
227-
.lfn2objectPath = [](std::string s) {
228+
.lfn2objectPath = [](std::string s) -> std::string {
228229
std::replace(s.begin()+1, s.end(), '/', '-');
230+
#if __has_include(<ROOT/RFieldBase.hxx>)
231+
if (s.starts_with("/")) {
232+
return std::string(s.begin() + 1, s.end());
233+
} else {
234+
return s;
235+
} },
236+
#else
229237
if (s.starts_with("/")) {
230238
return s;
231239
} else {
232240
return "/" + s;
233241
} },
242+
#endif
243+
#if __has_include(<ROOT/RFieldBase.hxx>)
244+
.getHandle = getHandleByClass("ROOT::RNTuple"),
245+
.checkSupport = matchClassByName("ROOT::RNTuple"),
246+
#else
234247
.getHandle = getHandleByClass("ROOT::Experimental::RNTuple"),
235248
.checkSupport = matchClassByName("ROOT::Experimental::RNTuple"),
249+
#endif
236250
.factory = [context]() -> RootArrowFactory& {
237251
lazyLoadFactory(context->implementations, "O2FrameworkAnalysisRNTupleSupport:RNTupleObjectReadingImplementation");
238252
return context->implementations.back();
239-
}};
253+
}
254+
};
240255
}
241256
};
242257

Framework/Core/test/test_Root2ArrowTable.cxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ TEST_CASE("RootTree2Fragment")
7373
/// A directory holding a tree
7474

7575
/// Create a simple TTree
76-
TBufferFile* file = new TBufferFile(TBuffer::kWrite);
76+
auto* file = new TBufferFile(TBuffer::kWrite);
7777

7878
TTree t1("t1", "a simple Tree with simple variables");
7979
Float_t xyz[3];
@@ -519,7 +519,11 @@ TEST_CASE("RootTree2Dataset")
519519
validateContents(batch);
520520
}
521521

522+
#if __has_include(<ROOT/RFieldBase.hxx>)
523+
arrow::fs::FileLocator rnTupleLocator{outFs, "rntuple"};
524+
#else
522525
arrow::fs::FileLocator rnTupleLocator{outFs, "/rntuple"};
526+
#endif
523527
// We write an RNTuple in the same TMemFile, using /rntuple as a location
524528
auto rntupleDestination = std::dynamic_pointer_cast<TDirectoryFileOutputStream>(*destination);
525529

@@ -530,7 +534,11 @@ TEST_CASE("RootTree2Dataset")
530534
}
531535

532536
// And now we can read back the RNTuple into a RecordBatch
537+
#if __has_include(<ROOT/RFieldBase.hxx>)
538+
arrow::dataset::FileSource writtenRntupleSource("rntuple", outFs);
539+
#else
533540
arrow::dataset::FileSource writtenRntupleSource("/rntuple", outFs);
541+
#endif
534542

535543
REQUIRE(rNtupleFormat->IsSupported(writtenRntupleSource) == true);
536544

0 commit comments

Comments
 (0)