Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Framework/AnalysisSupport/src/Plugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,11 @@ std::vector<std::string> getListOfTables(std::unique_ptr<TFile>& f)
break;
}

#if __has_include(<ROOT/RFieldBase.hxx>)
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('-');
Expand Down
27 changes: 14 additions & 13 deletions Framework/AnalysisSupport/src/RNTuplePlugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ using DPLFieldToken = rns::REntry::RFieldToken;
using DPLLocalIndex = rns::RClusterIndex;
#endif


template class
std::unique_ptr<rns::RNTupleReader>;

Expand Down Expand Up @@ -188,15 +187,17 @@ class RNTupleFileFormat : public arrow::dataset::FileFormat
};

template <typename T>
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 <typename T>
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 {
Expand Down Expand Up @@ -284,7 +285,6 @@ struct RootNTupleVisitor : public rns::Detail::RFieldVisitor {
}
#endif


void VisitBoolField(const rns::RField<bool>& field) override
{
this->datatype = arrow::boolean();
Expand Down Expand Up @@ -562,18 +562,19 @@ class RNTupleFileWriter : public arrow::dataset::FileWriter
};

template <typename T>
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 <typename T>
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<std::shared_ptr<arrow::Schema>> RNTupleFileFormat::Inspect(const arrow::dataset::FileSource& source) const
{

Expand Down
21 changes: 18 additions & 3 deletions Framework/Core/src/Plugin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<ROOT/RFieldBase.hxx>)
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(<ROOT/RFieldBase.hxx>)
.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();
}};
}
};
}
};

Expand Down
10 changes: 9 additions & 1 deletion Framework/Core/test/test_Root2ArrowTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -519,7 +519,11 @@ TEST_CASE("RootTree2Dataset")
validateContents(batch);
}

#if __has_include(<ROOT/RFieldBase.hxx>)
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<TDirectoryFileOutputStream>(*destination);

Expand All @@ -530,7 +534,11 @@ TEST_CASE("RootTree2Dataset")
}

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

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

Expand Down