diff --git a/Framework/AnalysisSupport/src/Plugin.cxx b/Framework/AnalysisSupport/src/Plugin.cxx index 00a4cc6565494..e39e76f01dbdd 100644 --- a/Framework/AnalysisSupport/src/Plugin.cxx +++ b/Framework/AnalysisSupport/src/Plugin.cxx @@ -121,10 +121,11 @@ std::vector getListOfTables(std::unique_ptr& f) break; } +#if __has_include() void* v = f->GetObjectChecked(key->GetName(), TClass::GetClass("ROOT::RNTuple")); - if (!v) { - v = f->GetObjectChecked(key->GetName(), TClass::GetClass("ROOT::Experimental::RNTuple")); - } +#else + void* v = f->GetObjectChecked(key->GetName(), TClass::GetClass("ROOT::Experimental::RNTuple")); +#endif if (v) { std::string s = key->GetName(); size_t pos = s.find('-'); diff --git a/Framework/AnalysisSupport/src/RNTuplePlugin.cxx b/Framework/AnalysisSupport/src/RNTuplePlugin.cxx index 71719d712b6d3..cd34f464dee51 100644 --- a/Framework/AnalysisSupport/src/RNTuplePlugin.cxx +++ b/Framework/AnalysisSupport/src/RNTuplePlugin.cxx @@ -45,7 +45,6 @@ using DPLFieldToken = rns::REntry::RFieldToken; using DPLLocalIndex = rns::RClusterIndex; #endif - template class std::unique_ptr; @@ -188,15 +187,17 @@ class RNTupleFileFormat : public arrow::dataset::FileFormat }; template -requires requires (T&& f) { f.GetSubFields(); } -auto getSubfields(T const&field) { - return field.GetSubFields(); + requires requires(T&& f) { f.GetSubFields(); } +auto getSubfields(T const& field) +{ + return field.GetSubFields(); } template -requires requires (T&& f) { f.GetConstSubfields(); } -auto getSubfields(T const&field) { - return field.GetConstSubfields(); + requires requires(T&& f) { f.GetConstSubfields(); } +auto getSubfields(T const& field) +{ + return field.GetConstSubfields(); } struct RootNTupleVisitor : public rns::Detail::RFieldVisitor { @@ -284,7 +285,6 @@ struct RootNTupleVisitor : public rns::Detail::RFieldVisitor { } #endif - void VisitBoolField(const rns::RField& field) override { this->datatype = arrow::boolean(); @@ -562,18 +562,19 @@ class RNTupleFileWriter : public arrow::dataset::FileWriter }; template -requires requires (T const&m) { m.GetFieldZero(); } -auto &getFieldZero(T const &m) { + requires requires(T const& m) { m.GetFieldZero(); } +auto& getFieldZero(T const& m) +{ return m.GetFieldZero(); } template -requires requires (T const&m) { m.GetConstFieldZero(); } -auto &getFieldZero(T const &m) { + requires requires(T const& m) { m.GetConstFieldZero(); } +auto& getFieldZero(T const& m) +{ return m.GetConstFieldZero(); } - arrow::Result> RNTupleFileFormat::Inspect(const arrow::dataset::FileSource& source) const { diff --git a/Framework/Core/src/Plugin.cxx b/Framework/Core/src/Plugin.cxx index 13b67e2a781ba..8ed683d501906 100644 --- a/Framework/Core/src/Plugin.cxx +++ b/Framework/Core/src/Plugin.cxx @@ -222,21 +222,36 @@ struct RNTupleObjectReadingCapability : o2::framework::RootObjectReadingCapabili { auto context = new ImplementationContext; - return new RootObjectReadingCapability{ + return new RootObjectReadingCapability + { .name = "rntuple", - .lfn2objectPath = [](std::string s) { + .lfn2objectPath = [](std::string s) -> std::string { std::replace(s.begin()+1, s.end(), '/', '-'); +#if __has_include() + if (s.starts_with("/")) { + return std::string(s.begin() + 1, s.end()); + } else { + return s; + } }, +#else if (s.starts_with("/")) { return s; } else { return "/" + s; } }, +#endif +#if __has_include() + .getHandle = getHandleByClass("ROOT::RNTuple"), + .checkSupport = matchClassByName("ROOT::RNTuple"), +#else .getHandle = getHandleByClass("ROOT::Experimental::RNTuple"), .checkSupport = matchClassByName("ROOT::Experimental::RNTuple"), +#endif .factory = [context]() -> RootArrowFactory& { lazyLoadFactory(context->implementations, "O2FrameworkAnalysisRNTupleSupport:RNTupleObjectReadingImplementation"); return context->implementations.back(); - }}; + } + }; } }; diff --git a/Framework/Core/test/test_Root2ArrowTable.cxx b/Framework/Core/test/test_Root2ArrowTable.cxx index 395048ae916d6..dacb54eb5ecdf 100644 --- a/Framework/Core/test/test_Root2ArrowTable.cxx +++ b/Framework/Core/test/test_Root2ArrowTable.cxx @@ -73,7 +73,7 @@ TEST_CASE("RootTree2Fragment") /// A directory holding a tree /// Create a simple TTree - TBufferFile* file = new TBufferFile(TBuffer::kWrite); + auto* file = new TBufferFile(TBuffer::kWrite); TTree t1("t1", "a simple Tree with simple variables"); Float_t xyz[3]; @@ -519,7 +519,11 @@ TEST_CASE("RootTree2Dataset") validateContents(batch); } +#if __has_include() + arrow::fs::FileLocator rnTupleLocator{outFs, "rntuple"}; +#else arrow::fs::FileLocator rnTupleLocator{outFs, "/rntuple"}; +#endif // We write an RNTuple in the same TMemFile, using /rntuple as a location auto rntupleDestination = std::dynamic_pointer_cast(*destination); @@ -530,7 +534,11 @@ TEST_CASE("RootTree2Dataset") } // And now we can read back the RNTuple into a RecordBatch +#if __has_include() + arrow::dataset::FileSource writtenRntupleSource("rntuple", outFs); +#else arrow::dataset::FileSource writtenRntupleSource("/rntuple", outFs); +#endif REQUIRE(rNtupleFormat->IsSupported(writtenRntupleSource) == true);