@@ -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-
326290auto 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-
702562namespace {
703563struct 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-
11601009void 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.
12271072const 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