diff --git a/tree/dataframe/inc/ROOT/RDF/InterfaceUtils.hxx b/tree/dataframe/inc/ROOT/RDF/InterfaceUtils.hxx index 65071442fcd5b023cc479627cff5597ac5a1056d..947dd4988f10f58b1f91b83d5504abc05d04f65c 100644 --- a/tree/dataframe/inc/ROOT/RDF/InterfaceUtils.hxx +++ b/tree/dataframe/inc/ROOT/RDF/InterfaceUtils.hxx @@ -89,7 +89,9 @@ HeadNode_t CreateSnaphotRDF(const ColumnNames_t &validCols, std::string DemangleTypeIdName(const std::type_info &typeInfo); -ColumnNames_t ConvertRegexToColumns(const ::ROOT::RDF::RNode &node, +ColumnNames_t ConvertRegexToColumns(RDFInternal::RBookedCustomColumns & customColumns, + TTree *tree, + ROOT::RDF::RDataSource *dataSource, std::string_view columnNameRegexp, std::string_view callerName); diff --git a/tree/dataframe/inc/ROOT/RDF/RInterface.hxx b/tree/dataframe/inc/ROOT/RDF/RInterface.hxx index 5f600c83749b4f5fa86c2c06afdc00aa11ecdb6f..e7cfddf587d974da1b4d03c35ebea7d5450e47ec 100644 --- a/tree/dataframe/inc/ROOT/RDF/RInterface.hxx +++ b/tree/dataframe/inc/ROOT/RDF/RInterface.hxx @@ -90,9 +90,7 @@ class RInterface { using RLoopManager = RDFDetail::RLoopManager; friend std::string cling::printValue(::ROOT::RDataFrame *tdf); // For a nice printing at the prompt friend class RDFInternal::GraphDrawing::GraphCreatorHelper; - friend ColumnNames_t RDFInternal::ConvertRegexToColumns(const RNode &node, - std::string_view columnNameRegexp, - std::string_view callerName); + using HeadNode_t = ::ROOT::RDF::RResultPtr<RInterface<RLoopManager, void>>; friend HeadNode_t RDFInternal::CreateSnaphotRDF(const ColumnNames_t &validCols, const std::string &fullTreeName, @@ -550,7 +548,11 @@ public: std::string_view columnNameRegexp = "", const RSnapshotOptions &options = RSnapshotOptions()) { - auto selectedColumns = RDFInternal::ConvertRegexToColumns(*this, columnNameRegexp, "Snapshot"); + auto selectedColumns = RDFInternal::ConvertRegexToColumns(fCustomColumns, + fLoopManager->GetTree(), + fDataSource, + columnNameRegexp, + "Snapshot"); return Snapshot(treename, filename, selectedColumns, options); } // clang-format on @@ -656,7 +658,12 @@ public: /// is empty, all columns are selected. See the previous overloads for more information. RInterface<RLoopManager> Cache(std::string_view columnNameRegexp = "") { - auto selectedColumns = RDFInternal::ConvertRegexToColumns(*this, columnNameRegexp, "Cache"); + + auto selectedColumns = RDFInternal::ConvertRegexToColumns(fCustomColumns, + fLoopManager->GetTree(), + fDataSource, + columnNameRegexp, + "Cache"); return Cache(selectedColumns); } @@ -1799,7 +1806,11 @@ public: /// See the previous overloads for further details. RResultPtr<RDisplay> Display(std::string_view columnNameRegexp = "", const int &nRows = 5) { - auto selectedColumns = RDFInternal::ConvertRegexToColumns(*this, columnNameRegexp, "Display"); + auto selectedColumns = RDFInternal::ConvertRegexToColumns(fCustomColumns, + fLoopManager->GetTree(), + fDataSource, + columnNameRegexp, + "Display"); return Display(selectedColumns, nRows); } diff --git a/tree/dataframe/src/RDFInterfaceUtils.cxx b/tree/dataframe/src/RDFInterfaceUtils.cxx index 092751d72b0b0899f99571d13f9009ce290f710b..274b04cddf72ed9d7b632153095b6885165ca87d 100644 --- a/tree/dataframe/src/RDFInterfaceUtils.cxx +++ b/tree/dataframe/src/RDFInterfaceUtils.cxx @@ -107,7 +107,10 @@ std::string DemangleTypeIdName(const std::type_info &typeInfo) return TClassEdit::DemangleTypeIdName(typeInfo, dummy); } -ColumnNames_t ConvertRegexToColumns(const ROOT::RDF::RNode &node, std::string_view columnNameRegexp, +ColumnNames_t ConvertRegexToColumns(RDFInternal::RBookedCustomColumns & customColumns, + TTree *tree, + ROOT::RDF::RDataSource *dataSource, + std::string_view columnNameRegexp, std::string_view callerName) { const auto theRegexSize = columnNameRegexp.size(); @@ -126,14 +129,13 @@ ColumnNames_t ConvertRegexToColumns(const ROOT::RDF::RNode &node, std::string_vi // Since we support gcc48 and it does not provide in its stl std::regex, // we need to use TRegexp TPRegexp regexp(theRegex); - for (auto &&branchName : node.fCustomColumns.GetNames()) { + for (auto &&branchName : customColumns.GetNames()) { if ((isEmptyRegex || 0 != regexp.Match(branchName.c_str())) && !RDFInternal::IsInternalColumn(branchName)) { selectedColumns.emplace_back(branchName); } } - auto tree = node.fLoopManager->GetTree(); if (tree) { auto branchNames = RDFInternal::GetTopLevelBranchNames(*tree); for (auto &branchName : branchNames) { @@ -143,8 +145,8 @@ ColumnNames_t ConvertRegexToColumns(const ROOT::RDF::RNode &node, std::string_vi } } - if (node.fDataSource) { - auto &dsColNames = node.fDataSource->GetColumnNames(); + if (dataSource) { + auto &dsColNames = dataSource->GetColumnNames(); for (auto &dsColName : dsColNames) { if ((isEmptyRegex || 0 != regexp.Match(dsColName.c_str())) && !RDFInternal::IsInternalColumn(dsColName)) {