Skip to content

Commit 2a65c39

Browse files
committed
[df] Remove unnecessary methods from loop manager
1 parent ccb4914 commit 2a65c39

File tree

2 files changed

+0
-168
lines changed

2 files changed

+0
-168
lines changed

tree/dataframe/inc/ROOT/RDF/RLoopManager.hxx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ class RLoopManager : public RNodeBase {
120120
using ColumnNames_t = std::vector<std::string>;
121121
enum class ELoopType {
122122
kInvalid,
123-
kROOTFiles,
124-
kROOTFilesMT,
125123
kNoFiles,
126124
kNoFilesMT,
127125
kDataSource,
@@ -139,9 +137,6 @@ class RLoopManager : public RNodeBase {
139137
std::vector<RDefineBase *> fBookedDefines;
140138
std::vector<RDFInternal::RVariationBase *> fBookedVariations;
141139

142-
/// Shared pointer to the input TTree. It does not delete the pointee if the TTree/TChain was passed directly as an
143-
/// argument to RDataFrame's ctor (in which case we let users retain ownership).
144-
std::shared_ptr<TTree> fTree{nullptr};
145140
Long64_t fBeginEntry{0};
146141
Long64_t fEndEntry{std::numeric_limits<Long64_t>::max()};
147142

@@ -150,8 +145,6 @@ class RLoopManager : public RNodeBase {
150145
/// Samples need to survive throughout the whole event loop, hence stored as an attribute
151146
std::vector<ROOT::RDF::Experimental::RSample> fSamples;
152147

153-
/// Friends of the fTree. Only used if we constructed fTree ourselves.
154-
std::vector<std::unique_ptr<TChain>> fFriends;
155148
ColumnNames_t fDefaultColumns;
156149
/// Range of entries created when no data source is specified.
157150
std::pair<ULong64_t, ULong64_t> fEmptyEntryRange{};
@@ -185,8 +178,6 @@ class RLoopManager : public RNodeBase {
185178

186179
void RunEmptySourceMT();
187180
void RunEmptySource();
188-
void RunTreeProcessorMT();
189-
void RunTreeReader();
190181
void RunDataSourceMT();
191182
void RunDataSource();
192183
void RunAndCheckFilters(unsigned int slot, Long64_t entry);
@@ -251,7 +242,6 @@ public:
251242
void Report(ROOT::RDF::RCutFlowReport &rep) const final;
252243
/// End of recursive chain of calls, does nothing
253244
void PartialReport(ROOT::RDF::RCutFlowReport &) const final {}
254-
void SetTree(std::shared_ptr<TTree> tree);
255245
void IncrChildrenCount() final { ++fNChildren; }
256246
void StopProcessing() final { ++fNStopsReceived; }
257247
void ToJitExec(const std::string &) const;

tree/dataframe/src/RLoopManager.cxx

Lines changed: 0 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -287,42 +287,6 @@ std::string LogRangeProcessing(const DatasetLogInfo &info)
287287
return msg.str();
288288
}
289289

290-
DatasetLogInfo TreeDatasetLogInfo(const TTreeReader &r, unsigned int slot)
291-
{
292-
const auto tree = r.GetTree();
293-
const auto chain = dynamic_cast<TChain *>(tree);
294-
std::string what;
295-
if (chain) {
296-
auto files = chain->GetListOfFiles();
297-
std::vector<std::string> treeNames;
298-
std::vector<std::string> fileNames;
299-
for (TObject *f : *files) {
300-
treeNames.emplace_back(f->GetName());
301-
fileNames.emplace_back(f->GetTitle());
302-
}
303-
what = "trees {";
304-
for (const auto &t : treeNames) {
305-
what += t + ",";
306-
}
307-
what.back() = '}';
308-
what += " in files {";
309-
for (const auto &f : fileNames) {
310-
what += f + ",";
311-
}
312-
what.back() = '}';
313-
} else {
314-
assert(tree != nullptr); // to make clang-tidy happy
315-
const auto treeName = tree->GetName();
316-
what = std::string("tree \"") + treeName + "\"";
317-
const auto file = tree->GetCurrentFile();
318-
if (file)
319-
what += std::string(" in file \"") + file->GetName() + "\"";
320-
}
321-
const auto entryRange = r.GetEntriesRange();
322-
const ULong64_t end = entryRange.second == -1ll ? tree->GetEntries() : entryRange.second;
323-
return {std::move(what), static_cast<ULong64_t>(entryRange.first), end, slot};
324-
}
325-
326290
auto MakeDatasetColReadersKey(std::string_view colName, const std::type_info &ti)
327291
{
328292
// We use a combination of column name and column type name as the key because in some cases we might end up
@@ -595,110 +559,6 @@ bool validTTreeReaderRead(TTreeReader &treeReader)
595559
}
596560
} // namespace
597561

598-
/// Run event loop over one or multiple ROOT files, in parallel.
599-
void RLoopManager::RunTreeProcessorMT()
600-
{
601-
#ifdef R__USE_IMT
602-
if (fEndEntry == fBeginEntry) // empty range => no work needed
603-
return;
604-
std::shared_ptr<ROOT::Internal::RSlotStack> slotStack = SlotStack();
605-
const auto &entryList = fTree->GetEntryList() ? *fTree->GetEntryList() : TEntryList();
606-
auto tp =
607-
(fBeginEntry != 0 || fEndEntry != std::numeric_limits<Long64_t>::max())
608-
? std::make_unique<ROOT::TTreeProcessorMT>(*fTree, fNSlots, std::make_pair(fBeginEntry, fEndEntry),
609-
fSuppressErrorsForMissingBranches)
610-
: std::make_unique<ROOT::TTreeProcessorMT>(*fTree, entryList, fNSlots, fSuppressErrorsForMissingBranches);
611-
612-
std::atomic<ULong64_t> entryCount(0ull);
613-
614-
tp->Process([this, &slotStack, &entryCount](TTreeReader &r) -> void {
615-
ROOT::Internal::RSlotStackRAII slotRAII(*slotStack);
616-
auto slot = slotRAII.fSlot;
617-
RCallCleanUpTask cleanup(*this, slot, &r);
618-
InitNodeSlots(&r, slot);
619-
R__LOG_DEBUG(0, RDFLogChannel()) << LogRangeProcessing(TreeDatasetLogInfo(r, slot));
620-
const auto entryRange = r.GetEntriesRange(); // we trust TTreeProcessorMT to call SetEntriesRange
621-
const auto nEntries = entryRange.second - entryRange.first;
622-
auto count = entryCount.fetch_add(nEntries);
623-
try {
624-
// recursive call to check filters and conditionally execute actions
625-
while (validTTreeReaderRead(r)) {
626-
if (fNewSampleNotifier.CheckFlag(slot)) {
627-
UpdateSampleInfo(slot, r);
628-
}
629-
RunAndCheckFilters(slot, count++);
630-
}
631-
} catch (...) {
632-
std::cerr << "RDataFrame::Run: event loop was interrupted\n";
633-
throw;
634-
}
635-
// fNStopsReceived < fNChildren is always true at the moment as we don't support event loop early quitting in
636-
// multi-thread runs, but it costs nothing to be safe and future-proof in case we add support for that later.
637-
if (r.GetEntryStatus() != TTreeReader::kEntryBeyondEnd && fNStopsReceived < fNChildren) {
638-
// something went wrong in the TTreeReader event loop
639-
throw std::runtime_error("An error was encountered while processing the data. TTreeReader status code is: " +
640-
std::to_string(r.GetEntryStatus()));
641-
}
642-
});
643-
644-
auto &&processedEntries = entryCount.load();
645-
if (fEndEntry != std::numeric_limits<Long64_t>::max() &&
646-
static_cast<ULong64_t>(fEndEntry - fBeginEntry) > processedEntries) {
647-
Warning("RDataFrame::Run",
648-
"RDataFrame stopped processing after %lld entries, whereas an entry range (begin=%lld,end=%lld) was "
649-
"requested. Consider adjusting the end value of the entry range to a maximum of %lld.",
650-
processedEntries, fBeginEntry, fEndEntry, fBeginEntry + processedEntries);
651-
}
652-
#endif // no-op otherwise (will not be called)
653-
}
654-
655-
/// Run event loop over one or multiple ROOT files, in sequence.
656-
void RLoopManager::RunTreeReader()
657-
{
658-
TTreeReader r(fTree.get(), fTree->GetEntryList(), /*warnAboutLongerFriends*/ true,
659-
fSuppressErrorsForMissingBranches);
660-
if (0 == fTree->GetEntriesFast() || fBeginEntry == fEndEntry)
661-
return;
662-
// Apply the range if there is any
663-
// In case of a chain with a total of N entries, calling SetEntriesRange(N + 1, ...) does not error out
664-
// This is a bug, reported here: https://github.com/root-project/root/issues/10774
665-
if (fBeginEntry != 0 || fEndEntry != std::numeric_limits<Long64_t>::max())
666-
if (r.SetEntriesRange(fBeginEntry, fEndEntry) != TTreeReader::kEntryValid)
667-
throw std::logic_error("Something went wrong in initializing the TTreeReader.");
668-
669-
RCallCleanUpTask cleanup(*this, 0u, &r);
670-
InitNodeSlots(&r, 0);
671-
R__LOG_DEBUG(0, RDFLogChannel()) << LogRangeProcessing(TreeDatasetLogInfo(r, 0u));
672-
673-
// recursive call to check filters and conditionally execute actions
674-
// in the non-MT case processing can be stopped early by ranges, hence the check on fNStopsReceived
675-
Long64_t processedEntries{};
676-
try {
677-
while (validTTreeReaderRead(r) && fNStopsReceived < fNChildren) {
678-
if (fNewSampleNotifier.CheckFlag(0)) {
679-
UpdateSampleInfo(/*slot*/0, r);
680-
}
681-
RunAndCheckFilters(0, r.GetCurrentEntry());
682-
processedEntries++;
683-
}
684-
} catch (...) {
685-
std::cerr << "RDataFrame::Run: event loop was interrupted\n";
686-
throw;
687-
}
688-
if (r.GetEntryStatus() != TTreeReader::kEntryBeyondEnd && fNStopsReceived < fNChildren) {
689-
// something went wrong in the TTreeReader event loop
690-
throw std::runtime_error("An error was encountered while processing the data. TTreeReader status code is: " +
691-
std::to_string(r.GetEntryStatus()));
692-
}
693-
694-
if (fEndEntry != std::numeric_limits<Long64_t>::max() && (fEndEntry - fBeginEntry) > processedEntries) {
695-
Warning("RDataFrame::Run",
696-
"RDataFrame stopped processing after %lld entries, whereas an entry range (begin=%lld,end=%lld) was "
697-
"requested. Consider adjusting the end value of the entry range to a maximum of %lld.",
698-
processedEntries, fBeginEntry, fEndEntry, fBeginEntry + processedEntries);
699-
}
700-
}
701-
702562
namespace {
703563
struct DSRunRAII {
704564
ROOT::RDF::RDataSource &fDS;
@@ -1045,10 +905,8 @@ void RLoopManager::Run(bool jit)
1045905
throw std::runtime_error("RDataFrame: executing the computation graph without a data source, aborting.");
1046906
break;
1047907
case ELoopType::kNoFilesMT: RunEmptySourceMT(); break;
1048-
case ELoopType::kROOTFilesMT: RunTreeProcessorMT(); break;
1049908
case ELoopType::kDataSourceMT: RunDataSourceMT(); break;
1050909
case ELoopType::kNoFiles: RunEmptySource(); break;
1051-
case ELoopType::kROOTFiles: RunTreeReader(); break;
1052910
case ELoopType::kDataSource: RunDataSource(); break;
1053911
}
1054912
s.Stop();
@@ -1148,15 +1006,6 @@ void RLoopManager::Report(ROOT::RDF::RCutFlowReport &rep) const
11481006
fPtr->FillReport(rep);
11491007
}
11501008

1151-
void RLoopManager::SetTree(std::shared_ptr<TTree> tree)
1152-
{
1153-
fTree = std::move(tree);
1154-
1155-
TChain *ch = nullptr;
1156-
if ((ch = dynamic_cast<TChain *>(fTree.get())))
1157-
fNoCleanupNotifier.RegisterChain(*ch);
1158-
}
1159-
11601009
void RLoopManager::ToJitExec(const std::string &code) const
11611010
{
11621011
R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
@@ -1208,10 +1057,6 @@ std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode> RLoopManager::GetG
12081057
std::string name;
12091058
if (fDataSource) {
12101059
name = fDataSource->GetLabel();
1211-
} else if (fTree) {
1212-
name = fTree->GetName();
1213-
if (name.empty())
1214-
name = fTree->ClassName();
12151060
} else {
12161061
name = "Empty source\\nEntries: " + std::to_string(GetNEmptyEntries());
12171062
}
@@ -1226,9 +1071,6 @@ std::shared_ptr<ROOT::Internal::RDF::GraphDrawing::GraphNode> RLoopManager::GetG
12261071
/// Never use fBranchNames directy, always request it through this method.
12271072
const ColumnNames_t &RLoopManager::GetBranchNames()
12281073
{
1229-
if (fValidBranchNames.empty() && fTree) {
1230-
fValidBranchNames = RDFInternal::GetBranchNames(*fTree, /*allowRepetitions=*/true);
1231-
}
12321074
if (fValidBranchNames.empty() && fDataSource) {
12331075
fValidBranchNames = fDataSource->GetColumnNames();
12341076
}

0 commit comments

Comments
 (0)