File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,13 +347,21 @@ ROOT::Experimental::RNTupleChainProcessor::AddFieldToEntry(const std::string &fi
347347
348348ROOT ::NTupleSize_t ROOT::Experimental::RNTupleChainProcessor::LoadEntry (ROOT ::NTupleSize_t entryNumber)
349349{
350- ROOT ::NTupleSize_t localEntryNumber = entryNumber;
351- std::size_t currProcessorNumber = 0 ;
350+ // If the requested entry number is lower than the current entry number, we have to again localise the correnct local
351+ // entry number starting from the first processor in the chain. Otherwise, we can continue looking from the inner
352+ // processor that is currently connected, which is much faster when the chain consists of many inner processors.
352353 if (entryNumber < fCurrentEntryNumber ) {
353354 fCurrentProcessorNumber = 0 ;
354355 ConnectInnerProcessor (fCurrentProcessorNumber );
355356 }
356357
358+ std::size_t currProcessorNumber = fCurrentProcessorNumber ;
359+ ROOT ::NTupleSize_t entriesSeen = 0 ;
360+ for (unsigned i = 0 ; i < currProcessorNumber; ++i) {
361+ entriesSeen += fInnerProcessors [i]->GetNEntries ();
362+ }
363+ ROOT ::NTupleSize_t localEntryNumber = entryNumber - entriesSeen;
364+
357365 // As long as the entry fails to load from the current processor, we decrement the local entry number with the number
358366 // of entries in this processor and try with the next processor until we find the correct local entry number.
359367 while (fInnerProcessors [currProcessorNumber]->LoadEntry (localEntryNumber) == kInvalidNTupleIndex ) {
You can’t perform that action at this time.
0 commit comments