313     fBrNames(new 
TList), fTree(
tree), fPrefillType(GetConfiguredPrefillType())
 
  316   Int_t nleaves = 
tree->GetListOfLeaves()->GetEntries();
 
  380      const char *bname = 
b->GetName();
 
  388         const char *mothername = 
b->GetMother()->GetName();
 
  389         if (
b != 
b->GetMother() && mothername[strlen(mothername)-1] != 
'.') {
 
  392            if (bem->GetType() < 3) {
 
  396               if (strncmp(bname,build.
Data(),build.
Length()) != 0) {
 
  398                  bname = build.
Data();
 
  405      if (
gDebug > 0) printf(
"Entry: %lld, registering branch: %s\n",
b->GetTree()->GetReadEntry(),
b->GetName());
 
  413      for (
Int_t j = 0; j < nb; j++) {
 
  415         if (!branch) 
continue;
 
  440   TLeaf *leaf, *leafcount;
 
  451   if (!strcmp(bname,
"*")) all = 
kTRUE;
 
  452   for (i=0;i<nleaves;i++)  {
 
  459         if (strcmp(bname,branch->
GetName())
 
  461             && 
s.Index(re) == 
kNPOS) 
continue;
 
  468      if (leafcount && !all) {
 
  475   if (nb==0 && strchr(bname,
'*')==0) {
 
  496         char *subbranch = (
char*)strstr(bname,fe->
GetName());
 
  497         if (subbranch!=bname) subbranch = 0;
 
  499            subbranch += strlen(fe->
GetName());
 
  500            if ( *subbranch != 
'.' ) subbranch = 0;
 
  512   if (!nb && !foundInFriend) {
 
  513      if (
gDebug > 0) printf(
"AddBranch: unknown branch -> %s \n", bname);
 
  514      Error(
"AddBranch", 
"unknown branch -> %s", bname);
 
  544      if (
gDebug > 0) printf(
"Entry: %lld, un-registering branch: %s\n",
b->GetTree()->GetReadEntry(),
b->GetName());
 
  553      for (
Int_t j = 0; j < nb; j++) {
 
  555         if (!branch) 
continue;
 
  580   TLeaf *leaf, *leafcount;
 
  591   if (!strcmp(bname,
"*")) all = 
kTRUE;
 
  592   for (i=0;i<nleaves;i++)  {
 
  599         if (strcmp(bname,branch->
GetName())
 
  601             && 
s.Index(re) == 
kNPOS) 
continue;
 
  608      if (leafcount && !all) {
 
  615   if (nb==0 && strchr(bname,
'*')==0) {
 
  636         char *subbranch = (
char*)strstr(bname,fe->
GetName());
 
  637         if (subbranch!=bname) subbranch = 0;
 
  639            subbranch += strlen(fe->
GetName());
 
  640            if ( *subbranch != 
'.' ) subbranch = 0;
 
  652   if (!nb && !foundInFriend) {
 
  653      if (
gDebug > 0) printf(
"DropBranch: unknown branch -> %s \n", bname);
 
  654      Error(
"DropBranch", 
"unknown branch -> %s", bname);
 
  721   Int_t *lbaskets = 
b.GetBasketBytes();
 
  728   Int_t blistsize = 
b.GetWriteBasket();
 
  737   if (basketOffset < 0) { 
 
  743   if ((basketOffset < blistsize) && 
b.GetListOfBaskets()->UncheckedAt(basketOffset)) {
 
  749   Long64_t pos = 
b.GetBasketSeek(basketOffset);
 
  750   Int_t len = lbaskets[basketOffset];
 
  791   TBranch *resultBranch = 
nullptr;
 
  794   std::vector<std::pair<size_t, Int_t>> basketsInfo;
 
  798   for (
int i = 0; i < count; i++) {
 
  803      if (iopos.fLen == 0) { 
 
  806      if (iopos.fPos == pos && iopos.fLen == len) {
 
  807         found_request = 
kTRUE;
 
  812      fMissCache->fEntries.emplace_back(std::move(iopos));
 
  815         Int_t blistsize = 
b->GetWriteBasket();
 
  816         Int_t basketNumber = -1;
 
  817         for (
Int_t bn = 0; bn < blistsize; ++bn) {
 
  818            if (iopos.fPos == 
b->GetBasketSeek(bn)) {
 
  823         if (basketNumber >= 0)
 
  824            basketsInfo.emplace_back((
size_t)i, basketNumber);
 
  833      for (
auto &info : basketsInfo) {
 
  834         perfStats->SetLoadedMiss(info.first, info.second);
 
  885   std::vector<Long64_t> positions;
 
  886   positions.reserve(
fMissCache->fEntries.size());
 
  887   std::vector<Int_t> lengths;
 
  891      positions.push_back(mcentry.fIO.fPos);
 
  892      lengths.push_back(mcentry.fIO.fLen);
 
  893      mcentry.fIndex = cumulative;
 
  894      cumulative += mcentry.fIO.fLen;
 
  926   auto iter = std::lower_bound(
fMissCache->fEntries.begin(), 
fMissCache->fEntries.end(), mcentry);
 
  929      if (len > iter->fIO.fLen) {
 
  933      auto offset = iter->fIndex;
 
  934      memcpy(buf, &(
fMissCache->fData[offset]), len);
 
  954      auto offset = iter->fIndex;
 
  956      memcpy(buf, &(
fMissCache->fData[offset]), len);
 
  977      Range() : fMin(-1), fMax(-1) {}
 
  981         if (fMin == -1 || min < fMin)
 
  987         if (fMax == -1 || fMax < max)
 
  991      Bool_t Contains(
Long64_t entry) { 
return (fMin <= entry && entry <= fMax); }
 
  994   std::vector<Range> fRanges;
 
  995   std::map<Long64_t,size_t> fMinimums;
 
  996   std::map<Long64_t,size_t> fMaximums;
 
  998   BasketRanges(
size_t nBranches) { fRanges.resize(nBranches); }
 
 1002      Range &range = fRanges.at(branchNumber);
 
 1005      range.UpdateMin(min);
 
 1006      range.UpdateMax(max);
 
 1008      if (old.fMax != range.fMax) {
 
 1009         if (old.fMax != -1) {
 
 1010            auto maxIter = fMaximums.find(old.fMax);
 
 1011            if (maxIter != fMaximums.end()) {
 
 1012               if (maxIter->second == 1) {
 
 1013                  fMaximums.erase(maxIter);
 
 1015                  --(maxIter->second);
 
 1023   void Update(
size_t branchNumber, 
size_t basketNumber, 
Long64_t *entries, 
size_t nb, 
size_t max)
 
 1025      Update(branchNumber, entries[basketNumber],
 
 1026             (basketNumber < (nb - 1)) ? (entries[basketNumber + 1] - 1) : max - 1);
 
 1030   bool CheckAllIncludeRange()
 
 1033      for (
const auto &
r : fRanges) {
 
 1034         if (result.fMin == -1 || result.fMin < 
r.fMin) {
 
 1036               result.fMin = 
r.fMin;
 
 1038         if (result.fMax == -1 || 
r.fMax < result.fMax) {
 
 1040               result.fMax = 
r.fMax;
 
 1047      Range allIncludedRange(AllIncludedRange());
 
 1049      return (result.fMin == allIncludedRange.fMin && result.fMax == allIncludedRange.fMax);
 
 1059   Range AllIncludedRange()
 
 1062      if (!fMinimums.empty())
 
 1063         result.fMin = fMinimums.rbegin()->first;
 
 1064      if (!fMaximums.empty())
 
 1065         result.fMax = fMaximums.begin()->first;
 
 1070   UInt_t BranchesRegistered()
 
 1073      for (
const auto &
r : fRanges) {
 
 1074         if (
r.fMin != -1 && 
r.fMax != -1)
 
 1084      for (
const auto &
r : fRanges) {
 
 1085         if (
r.fMin != -1 && 
r.fMax != -1)
 
 1086            if (
r.fMin <= entry && entry <= 
r.fMax)
 
 1094      for (
size_t i = 0; i < fRanges.size(); ++i) {
 
 1095         if (fRanges[i].fMin != -1 || fRanges[i].fMax != -1)
 
 1096            Printf(
"Range #%zu : %lld to %lld", i, fRanges[i].fMin, fRanges[i].fMax);
 
 1154               if (entry < 0) entry = 0;
 
 1160            if (entry < 0) 
return kFALSE;
 
 1166               if (entry < 0 && fEntryNext > 0) {
 
 1186   static constexpr bool showMore = 
kFALSE;
 
 1191         b->PrintCacheInfo();
 
 1195   if (showMore || 
gDebug > 6)
 
 1196      Info(
"FillBuffer", 
"***** Called for entry %lld", entry);
 
 1204         if (!
b->fCacheInfo.AllUsed()) {
 
 1211         if (showMore || 
gDebug > 5)
 
 1212            Info(
"FillBuffer", 
"All baskets used already, so refresh the cache early at entry %lld", entry);
 
 1231      resetBranchInfo = 
kTRUE;
 
 1232      if (showMore || 
gDebug > 6)
 
 1233         Info(
"FillBuffer", 
"*** Will reset the branch information about baskets");
 
 1234   } 
else if (showMore || 
gDebug > 6) {
 
 1235      Info(
"FillBuffer", 
"*** Info we have on the set of baskets");
 
 1242   auto entryCurrent = clusterIter();
 
 1257   if (showMore || 
gDebug > 6)
 
 1271   if (resetBranchInfo) {
 
 1274         if (!(fEntryCurrent < fCurrentClusterStart || fEntryCurrent >= 
fNextClusterStart)) {
 
 1275            Error(
"FillBuffer", 
"Inconsistency: fCurrentClusterStart=%lld fEntryCurrent=%lld fNextClusterStart=%lld " 
 1276                                "but fEntryCurrent should not be in between the two",
 
 1300   Int_t ntotCurrentBuf = 0;
 
 1304         ntotCurrentBuf = 
fNtot;
 
 1313      ntotCurrentBuf = 
fNtot;
 
 1320   Int_t clusterIterations = 0;
 
 1324   Int_t nReadPrefRequest = 0;
 
 1327      prevNtot = ntotCurrentBuf;
 
 1330      struct collectionInfo {
 
 1331         Int_t fClusterStart{-1}; 
 
 1335         void Rewind() { fCurrent = (fClusterStart >= 0) ? fClusterStart : 0; }
 
 1337      std::vector<collectionInfo> cursor(
fNbranches);
 
 1341      Int_t nDistinctLoad = 0;
 
 1353      auto CollectBaskets = [
this, elist, chainOffset, entry, clusterIterations, resetBranchInfo, perfStats,
 
 1354       &cursor, &lowestMaxEntry, &maxReadEntry, &minEntry,
 
 1355       &reachedEnd, &skippedFirst, &oncePerBranch, &nDistinctLoad, &progress,
 
 1356       &ranges, &memRanges, &reqRanges,
 
 1357       &ntotCurrentBuf, &nReadPrefRequest](EPass pass, ENarrow narrow, 
Long64_t maxCollectEntry) {
 
 1361         Int_t nReachedEnd = 0;
 
 1363         auto oldnReadPrefRequest = nReadPrefRequest;
 
 1364         std::vector<Int_t> potentialVetoes;
 
 1366         if (showMore || 
gDebug > 7)
 
 1367            Info(
"CollectBaskets", 
"Called with pass=%d narrow=%d maxCollectEntry=%lld", pass, narrow, maxCollectEntry);
 
 1374            if (
b->GetDirectory()->GetFile() != 
fFile)
 
 1376            potentialVetoes.clear();
 
 1377            if (pass == kStart && !cursor[i].fLoadedOnce && resetBranchInfo) {
 
 1381               b->fCacheInfo.GetUnused(potentialVetoes);
 
 1382               if (showMore || 
gDebug > 7) {
 
 1384                  for(
auto v : potentialVetoes) {
 
 1388                  if (!potentialVetoes.empty())
 
 1389                     Info(
"FillBuffer", 
"*** Potential Vetos for branch #%d: %s", i, vetolist.
Data());
 
 1391               b->fCacheInfo.Reset();
 
 1393            Int_t nb = 
b->GetMaxBaskets();
 
 1394            Int_t *lbaskets   = 
b->GetBasketBytes();
 
 1395            Long64_t *entries = 
b->GetBasketEntry();
 
 1396            if (!lbaskets || !entries)
 
 1400            Int_t blistsize = 
b->GetListOfBaskets()->GetSize();
 
 1402            auto maxOfBasket = [
this, nb, entries](
int j) {
 
 1403               return ((j < (nb - 1)) ? (entries[j + 1] - 1) : 
fEntryMax - 1);
 
 1406            if (pass == kRewind)
 
 1408            for (
auto &j = cursor[i].fCurrent; j < nb; j++) {
 
 1411               if (j < blistsize && b->GetListOfBaskets()->UncheckedAt(j)) {
 
 1413                  if (showMore || 
gDebug > 6) {
 
 1414                     ranges.Update(i, entries[j], maxOfBasket(j));
 
 1415                     memRanges.Update(i, entries[j], maxOfBasket(j));
 
 1417                  if (entries[j] <= entry && entry <= maxOfBasket(j)) {
 
 1418                     b->fCacheInfo.SetIsInCache(j);
 
 1419                     b->fCacheInfo.SetUsed(j);
 
 1433               if (entries[j] >= maxCollectEntry) {
 
 1439               Int_t len = lbaskets[j];
 
 1440               if (pos <= 0 || len <= 0)
 
 1444                  if ((showMore || 
gDebug > 7) &&
 
 1445                      (!(entries[j] < minEntry && (j < nb - 1 && entries[j + 1] <= minEntry))))
 
 1446                     Info(
"FillBuffer", 
"Skipping branch %s basket %d is too large for the cache: %d > %d",
 
 1451               if (nReadPrefRequest && entries[j] > (reqRanges.AllIncludedRange().fMax + 1)) {
 
 1461                  if (showMore || 
gDebug > 8)
 
 1462                     Info(
"FillBuffer", 
"Skipping for now due to gap %d/%d with %lld > %lld", i, j, entries[j],
 
 1463                          (reqRanges.AllIncludedRange().fMax + 1));
 
 1467               if (entries[j] < minEntry && (j<nb-1 && entries[j+1] <= minEntry))
 
 1471               if (cursor[i].fClusterStart == -1)
 
 1472                  cursor[i].fClusterStart = j;
 
 1477                     emax = entries[j + 1] - 1;
 
 1478                  if (!elist->
ContainsRange(entries[j]+chainOffset,emax+chainOffset))
 
 1482               if (
b->fCacheInfo.HasBeenUsed(j) || 
b->fCacheInfo.IsInCache(j) || 
b->fCacheInfo.IsVetoed(j)) {
 
 1485                  if (showMore || 
gDebug > 7)
 
 1486                     Info(
"FillBuffer", 
"Skipping basket to avoid redo: %d/%d veto: %d", i, j, 
b->fCacheInfo.IsVetoed(j));
 
 1490               if (std::find(std::begin(potentialVetoes), std::end(potentialVetoes), j) != std::end(potentialVetoes)) {
 
 1497                  b->fCacheInfo.Veto(j);
 
 1498                  if (showMore || 
gDebug > 7)
 
 1499                     Info(
"FillBuffer", 
"Veto-ing cluster %d [%lld,%lld[ in branch %s #%d", j, entries[j],
 
 1500                          maxOfBasket(j) + 1, 
b->GetName(), i);
 
 1505                  if ((((entries[j] > entry)) || (j < nb - 1 && entries[j + 1] <= entry))) {
 
 1507                     if (j == cursor[i].fClusterStart && entry > entries[j])
 
 1509                     if (entries[j] > entry)
 
 1518                  if (clusterIterations > 0 && cursor[i].fLoadedOnce) {
 
 1522                     if (showMore || 
gDebug > 5) {
 
 1525                           "Breaking early because %d is greater than %d at cluster iteration %d will restart at %lld",
 
 1526                           (ntotCurrentBuf + len), 
fBufferSizeMin, clusterIterations, minEntry);
 
 1532                     if (pass == kStart || !cursor[i].fLoadedOnce) {
 
 1540                           if (showMore || 
gDebug > 5) {
 
 1541                              Info(
"FillBuffer", 
"Breaking early because %d is greater than 4*%d at cluster iteration " 
 1542                                                 "%d pass %d will restart at %lld",
 
 1554                           if (showMore || 
gDebug > 5) {
 
 1555                              Info(
"FillBuffer", 
"Breaking early because %d is greater than 2*%d at cluster iteration " 
 1556                                                 "%d pass %d will restart at %lld",
 
 1568               reqRanges.Update(i, j, entries, nb, 
fEntryMax);
 
 1569               if (showMore || 
gDebug > 6)
 
 1570                  ranges.Update(i, j, entries, nb, 
fEntryMax);
 
 1572               b->fCacheInfo.SetIsInCache(j);
 
 1574               if (showMore || 
gDebug > 6)
 
 1575                  Info(
"FillBuffer", 
"*** Registering branch %d basket %d %s", i, j, 
b->GetName());
 
 1577               if (!cursor[i].fLoadedOnce) {
 
 1578                  cursor[i].fLoadedOnce = 
kTRUE;
 
 1582                  perfStats->SetLoaded(i, j);
 
 1589                     ntotCurrentBuf = 
fNtot;
 
 1598                  ntotCurrentBuf = 
fNtot;
 
 1601               if ( ( j < (nb-1) ) && entries[j+1] > maxReadEntry ) {
 
 1603                  maxReadEntry = entries[j+1];
 
 1607                  Warning(
"FillBuffer", 
"There is more data in this cluster (starting at entry %lld to %lld, " 
 1608                                        "current=%lld) than usual ... with %d %.3f%% of the branches we already have " 
 1609                                        "%d bytes (instead of %d)",
 
 1613               if (pass == kStart) {
 
 1615                  auto high = maxOfBasket(j);
 
 1616                  if (high < lowestMaxEntry)
 
 1617                     lowestMaxEntry = high;
 
 1621               } 
else if ((j + 1) == nb || entries[j + 1] >= maxReadEntry || entries[j + 1] >= lowestMaxEntry) {
 
 1623                  auto high = maxOfBasket(j);
 
 1624                  if (high < lowestMaxEntry)
 
 1625                     lowestMaxEntry = high;
 
 1632            if (cursor[i].fCurrent == nb) {
 
 1637               Info(
"CollectBaskets",
 
 1638                    "Entry: %lld, registering baskets branch %s, fEntryNext=%lld, fNseek=%d, ntotCurrentBuf=%d",
 
 1642         skippedFirst = (nSkipped > 0);
 
 1643         oncePerBranch = (nDistinctLoad == 
fNbranches);
 
 1644         progress = nReadPrefRequest - oldnReadPrefRequest;
 
 1651      full = CollectBaskets(kStart, kNarrow, 
fEntryNext);
 
 1655      while (!full && !reachedEnd && progress) { 
 
 1656         full = CollectBaskets(kStart, kFull, std::min(maxReadEntry, 
fEntryNext));
 
 1659      resetBranchInfo = 
kFALSE; 
 
 1664            full = CollectBaskets(kRegular, kFull, 
fEntryNext);
 
 1665         } 
while (!full && !reachedEnd && progress);
 
 1669      if (!full && skippedFirst) {
 
 1670         full = CollectBaskets(kRewind, kFull, 
fEntryNext);
 
 1671         while (!full && !reachedEnd && progress) {
 
 1672            full = CollectBaskets(kRegular, kFull, 
fEntryNext);
 
 1676      clusterIterations++;
 
 1678      minEntry = clusterIter.
Next();
 
 1696            (prevNtot < ntotCurrentBuf) && (minEntry < 
fEntryMax))) {
 
 1697         if (showMore || 
gDebug > 6)
 
 1698            Info(
"FillBuffer", 
"Breaking because %d <= %lld || (%d >= %d) || %lld >= %lld", 
fBufferSizeMin,
 
 1699                 ((
Long64_t)ntotCurrentBuf * (clusterIterations + 1)) / clusterIterations, prevNtot, ntotCurrentBuf,
 
 1708         if (minEntry >= fEntryCurrentMax && fEntryCurrentMax > 0)
 
 1716   if (showMore || 
gDebug > 6) {
 
 1717      Info(
"FillBuffer", 
"Mem ranges");
 
 1719      Info(
"FillBuffer", 
"Combined ranges");
 
 1721      Info(
"FillBuffer", 
"Requested ranges");
 
 1726   if (nReadPrefRequest == 0) {
 
 1730      if (showMore || 
gDebug > 5) {
 
 1731         Info(
"FillBuffer", 
"For entry %lld, nothing was added to the cache.", entry);
 
 1733   } 
else if (
fEntryNext < firstClusterEnd && !reqRanges.Contains(entry)) {
 
 1745      if (showMore || 
gDebug > 5) {
 
 1746         Error(
"FillBuffer", 
"Reset the next entry because the currently loaded range does not contains the request " 
 1747                             "entry: %lld.  fEntryNext updated from %lld to %lld. %d",
 
 1748               entry, 
fEntryNext, firstClusterEnd, nReadPrefRequest);
 
 1754      if (showMore || 
gDebug > 5) {
 
 1755         Info(
"FillBuffer", 
"Complete adding %d baskets from %d branches taking in memory %d out of %d",
 
 1756              nReadPrefRequest, reqRanges.BranchesRegistered(), ntotCurrentBuf, 
fBufferSizeMin);
 
 1785   if (!(stcp = 
gSystem->
Getenv(
"ROOT_TTREECACHE_PREFILL")) || !*stcp) {
 
 1883   printf(
"Number of branches in the cache ...: %d\n",
fNbranches);
 
 1884   printf(
"Cache Efficiency ..................: %f\n",
GetEfficiency());
 
 1889   if ( opt.
Contains(
"cachedbranches") ) {
 
 1891      printf(
"Cached branches....................:\n");
 
 1894      for (
Int_t i = 0; i < nbranches; ++i) {
 
 1896         printf(
"Branch name........................: %s\n",branch->
GetName());
 
 1915         ::Info(
"TTreeCache::ReadBufferNormal", 
"Cache miss after an %s FillBuffer: pos=%lld",
 
 1916                bufferFilled ? 
"active" : 
"inactive", basketpos);
 
 1919         Int_t blistsize = 
b->GetListOfBaskets()->GetSize();
 
 1920         for (
Int_t j = 0; j < blistsize; ++j) {
 
 1921            if (basketpos == 
b->GetBasketSeek(j)) {
 
 1923                  ::Info(
"TTreeCache::ReadBufferNormal", 
"   Missing basket: %d for %s", j, 
b->GetName());
 
 1937      else if (res == 0) {
 
 1941            recordMiss(perfStats, 
fBranches, bufferFilled, pos);
 
 1954      recordMiss(perfStats, 
fBranches, bufferFilled, pos);
 
 2045   if (res == 0 && buffersize <= prevsize) {
 
 2080      Info(
"SetEntryRange", 
"fEntryMin=%lld, fEntryMax=%lld, fEntryNext=%lld",
 
 2083   if (needLearningStart) {
 
 2231   if (entry < fEntryMin || entry > 
fEntryMax) 
return;
 
#define R__unlikely(expr)
unsigned long long ULong64_t
R__EXTERN TSystem * gSystem
A Branch for the case of an object.
A TTree is a list of TBranches.
A chain is a collection of files containing TTree objects.
virtual Int_t GetTreeNumber() const
Long64_t * GetTreeOffset() const
virtual Int_t GetEntries() const
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
A TEventList object is a list of selected events (entries) in a TTree.
virtual Bool_t ContainsRange(Long64_t entrymin, Long64_t entrymax)
Return TRUE if list contains entries from entrymin to entrymax included.
A cache when reading files over the network.
virtual Int_t SetBufferSize(Int_t buffersize)
Sets the buffer size.
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos.
virtual void SecondPrefetch(Long64_t, Int_t)
virtual void Print(Option_t *option="") const
Print cache statistics.
Bool_t fEnablePrefetching
reading by prefetching asynchronously
Int_t fNtot
Total size of prefetched blocks.
virtual void Prefetch(Long64_t pos, Int_t len)
Add block of length len at position pos in the list of blocks to be prefetched.
Int_t fBufferSizeMin
Original size of fBuffer.
Bool_t fIsTransferred
True when fBuffer contains something valid.
TFile * fFile
Pointer to file.
Int_t fNseek
Number of blocks to be prefetched.
virtual Int_t GetBufferSize() const
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Set the file using this cache and reset the current blocks (if any).
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
virtual Bool_t ReadBuffers(char *buf, Long64_t *pos, Int_t *len, Int_t nbuf)
Read the nbuf blocks described in arrays pos and len.
ECacheAction
TTreeCache flushing semantics.
virtual void SetCacheRead(TFileCacheRead *cache, TObject *tree=0, ECacheAction action=kDisconnect)
Set a pointer to the read cache.
A TFriendElement TF describes a TTree object TF in a file.
virtual TTree * GetTree()
Return pointer to friend TTree.
A TLeaf describes individual elements of a TBranch See TBranch structure in TTree.
virtual TLeaf * GetLeafCount() const
If this leaf stores a variable-sized array or a multi-dimensional array whose last dimension has vari...
TBranch * GetBranch() const
virtual void Add(TObject *obj)
virtual TObject * Remove(TObject *obj)
Remove object from the list.
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
virtual const char * GetName() const
Returns name of object.
Int_t GetEntriesFast() const
virtual void AddAtAndExpand(TObject *obj, Int_t idx)
Add object at position idx.
TObject * UncheckedAt(Int_t i) const
virtual TObject * Remove(TObject *obj)
Remove object from array.
virtual void AddAt(TObject *obj, Int_t idx)
Add object at position ids.
Collectable string class.
const char * GetName() const
Returns name of object.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Regular expression class.
void ToLower()
Change string to lower-case.
Int_t Atoi() const
Return integer value of string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TString & Append(const char *cs)
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual const char * Getenv(const char *env)
Get environment variable.
virtual Int_t AddBranch(TBranch *b, Bool_t subgbranches=kFALSE)
Add a branch to the list of branches to be stored in the cache this function is called by the user vi...
virtual void SetLearnPrefill(EPrefillType type=kNoPrefill)
Set whether the learning period is started with a prefilling of the cache and which type of prefillin...
virtual void UpdateBranches(TTree *tree)
Update pointer to current Tree and recompute pointers to the branches in the cache.
void SetOptimizeMisses(Bool_t opt)
Start of methods for the miss cache.
Double_t GetEfficiencyRel() const
This will indicate a sort of relative efficiency... a ratio of the reads found in the cache to the nu...
Bool_t fReverseRead
! reading in reverse mode
Bool_t fLearnPrefilling
! true if we are in the process of executing LearnPrefill
Long64_t fLastMiss
! set to the event # of the last miss.
Int_t fNMissReadPref
Number of blocks read into the secondary ("miss") cache.
virtual Int_t SetBufferSize(Int_t buffersize)
Change the underlying buffer size of the cache.
Int_t fNMissReadOk
Number of blocks read, not found in the primary cache, and found in the secondary cache.
Bool_t fOneTime
! used in the learning phase
virtual void SetFile(TFile *file, TFile::ECacheAction action=TFile::kDisconnect)
Overload to make sure that the object specific.
Long64_t fEntryMin
! first entry in the cache
virtual Bool_t FillBuffer()
Fill the cache buffer with the branches in the cache.
Bool_t ProcessMiss(Long64_t pos, int len)
! Given a file read not in the miss cache, handle (possibly) loading the data.
static void SetLearnEntries(Int_t n=10)
Static function to set the number of entries to be used in learning mode The default value for n is 1...
Long64_t fEntryNext
! next entry number where cache must be filled
Int_t fNReadMiss
Number of blocks read and not found in the cache.
Double_t GetEfficiency() const
Give the total efficiency of the primary cache... defined as the ratio of blocks found in the cache v...
Bool_t fEnabled
! cache enabled for cached reading
Bool_t fIsLearning
! true if cache is in learning mode
Long64_t fNextClusterStart
! End+1 of the cluster(s) where the current content was picked out
const TObjArray * GetCachedBranches() const
virtual ~TTreeCache()
Destructor. (in general called by the TFile destructor)
Bool_t CheckMissCache(char *buf, Long64_t pos, int len)
Check the miss cache for a particular buffer, fetching if deemed necessary.
Int_t fNMissReadMiss
Number of blocks read and not found in either cache.
IOPos FindBranchBasketPos(TBranch &, Long64_t entry)
Given a branch and an entry, determine the file location (offset / size) of the corresponding basket.
virtual void SetEntryRange(Long64_t emin, Long64_t emax)
Set the minimum and maximum entry number to be processed this information helps to optimize the numbe...
TTreeCache()
Default Constructor.
std::unique_ptr< MissCache > fMissCache
! Cache contents for misses
Bool_t fFirstTime
! save the fact that we processes the first entry
void StartLearningPhase()
The name should be enough to explain the method.
virtual Int_t LearnBranch(TBranch *b, Bool_t subgbranches=kFALSE)
Add a branch discovered by actual usage to the list of branches to be stored in the cache this functi...
Bool_t fReadDirectionSet
! read direction established
TBranch * CalculateMissEntries(Long64_t, int, bool)
Given an file read, try to determine the corresponding branch.
Long64_t fCurrentClusterStart
! Start of the cluster(s) where the current content was picked out
Double_t GetMissEfficiency() const
The total efficiency of the 'miss cache' - defined as the ratio of blocks found in the cache versus t...
virtual Int_t ReadBufferNormal(char *buf, Long64_t pos, Int_t len)
Old method ReadBuffer before the addition of the prefetch mechanism.
virtual void ResetCache()
This will simply clear the cache.
Bool_t fIsManual
! true if cache is StopLearningPhase was used
EPrefillType fPrefillType
Whether a pre-filling is enabled (and if applicable which type)
virtual void LearnPrefill()
Perform an initial prefetch, attempting to read as much of the learning phase baskets for all branche...
virtual Int_t ReadBuffer(char *buf, Long64_t pos, Int_t len)
Read buffer at position pos if the request is in the list of prefetched blocks read from fBuffer.
Long64_t fEntryMax
! last entry in the cache
static Int_t fgLearnEntries
number of entries used for learning mode
virtual Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE)
Remove a branch to the list of branches to be stored in the cache this function is called by TBranch:...
virtual Int_t ReadBufferPrefetch(char *buf, Long64_t pos, Int_t len)
Used to read a chunk from a block previously fetched.
Long64_t fEntryCurrent
! current lowest entry number in the cache
void ResetMissCache()
Reset all the miss cache training.
Long64_t fFirstMiss
! set to the event # of the first miss.
Double_t GetMissEfficiencyRel() const
Relative efficiency of the 'miss cache' - ratio of the reads found in cache to the number of reads so...
Long64_t fFirstEntry
! save the value of the first entry
Int_t fFillTimes
! how many times we can fill the current buffer
Int_t fNReadPref
Number of blocks that were prefetched.
TTree * fTree
! pointer to the current Tree
EPrefillType GetConfiguredPrefillType() const
Return the desired prefill type from the environment or resource variable.
Bool_t fFirstBuffer
! true if first buffer is used for prefetching
static Int_t GetLearnEntries()
Static function returning the number of entries used to train the cache see SetLearnEntries.
virtual void StopLearningPhase()
This is the counterpart of StartLearningPhase() and can be used to stop the learning phase.
Bool_t fOptimizeMisses
! true if we should optimize cache misses.
Int_t fNbranches
! Number of branches in the cache
Int_t fNReadOk
Number of blocks read and found in the cache.
virtual void Print(Option_t *option="") const
Print cache statistics.
TObjArray * fBranches
! List of branches to be stored in the cache
TList * fBrNames
! list of branch names in the cache
Helper class to iterate over cluster of baskets.
Long64_t Next()
Move on to the next cluster and return the starting entry of this next cluster.
A TTree object has a header with a name and a title.
virtual TVirtualPerfStats * GetPerfStats() const
virtual TBranch * GetBranch(const char *name)
Return pointer to the branch with the given name in this tree or its friends.
virtual TObjArray * GetListOfLeaves()
virtual Long64_t GetEntries() const
virtual Long64_t GetReadEntry() const
virtual TTree * GetTree() const
TEventList * GetEventList() const
virtual TList * GetListOfFriends() const
Provides the interface for the PROOF internal performance measurement and event tracing.
virtual void SetMissed(TBranch *b, size_t basketNumber)=0
virtual void UpdateBranchIndices(TObjArray *branches)=0
void Print(std::ostream &os, const OptionType &opt)
static constexpr double s
Long64_t BinarySearch(Long64_t n, const T *array, T value)