Skip to content

Commit 272083c

Browse files
committed
DPL: more fixes to handle the ROOT v6-36-00
- More tweaks to get ROOT::Experimental out of the way - RNTuples cannot have / as first character in name
1 parent 807a6b1 commit 272083c

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
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
@@ -43,7 +43,6 @@ using DPLFieldToken = rns::REntry::RFieldToken;
4343
using DPLLocalIndex = rns::RClusterIndex;
4444
#endif
4545

46-
4746
template class
4847
std::unique_ptr<rns::RNTupleReader>;
4948

@@ -186,15 +185,17 @@ class RNTupleFileFormat : public arrow::dataset::FileFormat
186185
};
187186

188187
template <typename T>
189-
requires requires (T&& f) { f.GetSubFields(); }
190-
auto getSubfields(T const&field) {
191-
return field.GetSubFields();
188+
requires requires(T&& f) { f.GetSubFields(); }
189+
auto getSubfields(T const& field)
190+
{
191+
return field.GetSubFields();
192192
}
193193

194194
template <typename T>
195-
requires requires (T&& f) { f.GetConstSubfields(); }
196-
auto getSubfields(T const&field) {
197-
return field.GetConstSubfields();
195+
requires requires(T&& f) { f.GetConstSubfields(); }
196+
auto getSubfields(T const& field)
197+
{
198+
return field.GetConstSubfields();
198199
}
199200

200201
struct RootNTupleVisitor : public rns::Detail::RFieldVisitor {
@@ -282,7 +283,6 @@ struct RootNTupleVisitor : public rns::Detail::RFieldVisitor {
282283
}
283284
#endif
284285

285-
286286
void VisitBoolField(const rns::RField<bool>& field) override
287287
{
288288
this->datatype = arrow::boolean();
@@ -560,18 +560,19 @@ class RNTupleFileWriter : public arrow::dataset::FileWriter
560560
};
561561

562562
template <typename T>
563-
requires requires (T const&m) { m.GetFieldZero(); }
564-
auto &getFieldZero(T const &m) {
563+
requires requires(T const& m) { m.GetFieldZero(); }
564+
auto& getFieldZero(T const& m)
565+
{
565566
return m.GetFieldZero();
566567
}
567568

568569
template <typename T>
569-
requires requires (T const&m) { m.GetConstFieldZero(); }
570-
auto &getFieldZero(T const &m) {
570+
requires requires(T const& m) { m.GetConstFieldZero(); }
571+
auto& getFieldZero(T const& m)
572+
{
571573
return m.GetConstFieldZero();
572574
}
573575

574-
575576
arrow::Result<std::shared_ptr<arrow::Schema>> RNTupleFileFormat::Inspect(const arrow::dataset::FileSource& source) const
576577
{
577578

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: 3 additions & 3 deletions
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,7 @@ TEST_CASE("RootTree2Dataset")
519519
validateContents(batch);
520520
}
521521

522-
arrow::fs::FileLocator rnTupleLocator{outFs, "/rntuple"};
522+
arrow::fs::FileLocator rnTupleLocator{outFs, "rntuple"};
523523
// We write an RNTuple in the same TMemFile, using /rntuple as a location
524524
auto rntupleDestination = std::dynamic_pointer_cast<TDirectoryFileOutputStream>(*destination);
525525

@@ -530,7 +530,7 @@ TEST_CASE("RootTree2Dataset")
530530
}
531531

532532
// And now we can read back the RNTuple into a RecordBatch
533-
arrow::dataset::FileSource writtenRntupleSource("/rntuple", outFs);
533+
arrow::dataset::FileSource writtenRntupleSource("rntuple", outFs);
534534

535535
REQUIRE(rNtupleFormat->IsSupported(writtenRntupleSource) == true);
536536

0 commit comments

Comments
 (0)