CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes

edm::FileIndex Class Reference

#include <FileIndex.h>

List of all members.

Classes

class  Element
struct  Transients

Public Types

typedef std::vector< Element >
::const_iterator 
const_iterator
typedef long long EntryNumber_t
enum  EntryType { kRun, kLumi, kEvent, kEnd }
typedef std::vector< Element >
::iterator 
iterator
enum  SortState { kNotSorted, kSorted_Run_Lumi_Event, kSorted_Run_Lumi_EventEntry }

Public Member Functions

void addEntry (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry)
bool allEventsInEntryOrder () const
const_iterator begin () const
iterator begin ()
bool containsEvent (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool containsItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
bool containsLumi (RunNumber_t run, LuminosityBlockNumber_t lumi) const
bool containsRun (RunNumber_t run) const
bool empty () const
const_iterator end () const
iterator end ()
iterator erase (iterator begin, iterator end)
iterator erase (iterator pos)
 FileIndex ()
const_iterator findEventEntryPosition (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, EntryNumber_t entry) const
const_iterator findEventPosition (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
const_iterator findLumiOrRunPosition (RunNumber_t run, LuminosityBlockNumber_t lumi) const
const_iterator findLumiPosition (RunNumber_t run, LuminosityBlockNumber_t lumi) const
const_iterator findPosition (RunNumber_t run, LuminosityBlockNumber_t lumi=0U, EventNumber_t event=0U) const
const_iterator findRunPosition (RunNumber_t run) const
void initializeTransients () const
std::vector< Element >::size_type size () const
void sortBy_Run_Lumi_Event ()
void sortBy_Run_Lumi_EventEntry ()
 ~FileIndex ()

Private Member Functions

bool & allInEntryOrder () const
bool & resultCached () const
SortStatesortState () const

Private Attributes

std::vector< Elemententries_
Transients transient_

Detailed Description

Definition at line 20 of file FileIndex.h.


Member Typedef Documentation

Definition at line 53 of file FileIndex.h.

typedef long long edm::FileIndex::EntryNumber_t

Definition at line 23 of file FileIndex.h.

typedef std::vector<Element>::iterator edm::FileIndex::iterator

Definition at line 55 of file FileIndex.h.


Member Enumeration Documentation

Enumerator:
kRun 
kLumi 
kEvent 
kEnd 

Definition at line 30 of file FileIndex.h.

Enumerator:
kNotSorted 
kSorted_Run_Lumi_Event 
kSorted_Run_Lumi_EventEntry 

Definition at line 116 of file FileIndex.h.


Constructor & Destructor Documentation

edm::FileIndex::FileIndex ( )

Definition at line 10 of file FileIndex.cc.

: entries_(), transient_() {}
edm::FileIndex::~FileIndex ( ) [inline]

Definition at line 26 of file FileIndex.h.

{}

Member Function Documentation

void edm::FileIndex::addEntry ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
EntryNumber_t  entry 
)

Definition at line 29 of file FileIndex.cc.

References entries_, kNotSorted, resultCached(), and sortState().

                                                                                                             {
    entries_.emplace_back(run, lumi, event, entry);
    resultCached() = false;
    sortState() = kNotSorted;
  }
bool edm::FileIndex::allEventsInEntryOrder ( ) const

Definition at line 47 of file FileIndex.cc.

References allInEntryOrder(), entries_, edm::FileIndex::Element::invalidEntry, kEvent, and resultCached().

                                              {
    if(!resultCached()) {
      resultCached() = true;
      EntryNumber_t maxEntry = Element::invalidEntry;
      for(std::vector<FileIndex::Element>::const_iterator it = entries_.begin(), itEnd = entries_.end(); it != itEnd; ++it) {
        if(it->getEntryType() == kEvent) {
          if(it->entry_ < maxEntry) {
            allInEntryOrder() = false;
            return false;
          }
          maxEntry = it->entry_;
        }
      }
      allInEntryOrder() = true;
      return true;
    }
    return allInEntryOrder();
  }
bool& edm::FileIndex::allInEntryOrder ( ) const [inline, private]

Definition at line 130 of file FileIndex.h.

References edm::FileIndex::Transients::allInEntryOrder_, and transient_.

Referenced by allEventsInEntryOrder().

iterator edm::FileIndex::begin ( void  ) [inline]

Definition at line 102 of file FileIndex.h.

References entries_.

{return entries_.begin();}
const_iterator edm::FileIndex::begin ( void  ) const [inline]

Definition at line 98 of file FileIndex.h.

References entries_.

Referenced by edm::operator<<(), and edm::preIndexIntoFilePrintEventsInLumis().

{return entries_.begin();}
bool edm::FileIndex::containsEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const [inline]

Definition at line 84 of file FileIndex.h.

References entries_, and findEventPosition().

Referenced by containsItem().

                                                                                              {
        return findEventPosition(run, lumi, event) != entries_.end();
      }
bool edm::FileIndex::containsItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const [inline]

Definition at line 79 of file FileIndex.h.

References containsEvent(), containsLumi(), and containsRun().

                                                                                             {
        return event ? containsEvent(run, lumi, event) : (lumi ? containsLumi(run, lumi) : containsRun(run));
      }
bool edm::FileIndex::containsLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const [inline]

Definition at line 89 of file FileIndex.h.

References entries_, and findLumiPosition().

Referenced by containsItem().

                                                                        {
        return findLumiPosition(run, lumi) != entries_.end();
      }
bool edm::FileIndex::containsRun ( RunNumber_t  run) const [inline]

Definition at line 94 of file FileIndex.h.

References entries_, and findRunPosition().

Referenced by containsItem().

                                         {
        return findRunPosition(run) != entries_.end();
      }
bool edm::FileIndex::empty ( ) const [inline]

Definition at line 112 of file FileIndex.h.

References entries_.

Referenced by fwlite::EntryFinder::empty().

{return entries_.empty();}
iterator edm::FileIndex::end ( void  ) [inline]

Definition at line 104 of file FileIndex.h.

References entries_.

{return entries_.end();}
const_iterator edm::FileIndex::end ( void  ) const [inline]
iterator edm::FileIndex::erase ( iterator  pos) [inline]

Definition at line 106 of file FileIndex.h.

References entries_.

{return entries_.erase(pos);}
iterator edm::FileIndex::erase ( iterator  begin,
iterator  end 
) [inline]

Definition at line 108 of file FileIndex.h.

References entries_.

{return entries_.erase(begin, end);}
FileIndex::const_iterator edm::FileIndex::findEventEntryPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
EntryNumber_t  entry 
) const

Definition at line 162 of file FileIndex.cc.

References entries_, findEventPosition(), kNotSorted, kSorted_Run_Lumi_EventEntry, edm::lower_bound_all(), and sortState().

                                                                                                                                 {
    assert(sortState() != kNotSorted);
    const_iterator it;
    const_iterator itEnd = entries_.end();
    if(sortState() == kSorted_Run_Lumi_EventEntry) {
      assert(lumi != 0U);
      Element el(run, lumi, event, entry);
      it = lower_bound_all(entries_, el, Compare_Run_Lumi_EventEntry());
    } else {
      it = findEventPosition(run, lumi, event);
      while(it != itEnd && it->entry_ != entry && it->event_ == event) {
        ++it;
      }
    }
    if(it == itEnd) return itEnd;
    if(lumi == 0) lumi = it->lumi_;
    if(it->run_ != run || it->lumi_ != lumi || it->event_ != event || it->entry_ != entry) return itEnd;
    return it;
  }
FileIndex::const_iterator edm::FileIndex::findEventPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 91 of file FileIndex.cc.

References entries_, findPosition(), kEvent, kSorted_Run_Lumi_Event, and sortState().

Referenced by containsEvent(), fwlite::EntryFinder::findEvent(), and findEventEntryPosition().

                                                                                                       {

    const_iterator it = findPosition(run, lumi, event);
    const_iterator itEnd = entries_.end();
    while(it != itEnd && it->getEntryType() != FileIndex::kEvent) {
      ++it;
    }
    if(it == itEnd) {
      return itEnd;
    }
    if(lumi == 0) {
      lumi = it->lumi_;
    }
    if(it->run_ != run || it->lumi_ != lumi || it->event_ != event) {
      if (sortState() == kSorted_Run_Lumi_Event) {
        return itEnd;
      }
      // not sorted by event, so we need to do a linear search
      while (it != itEnd && it->run_ == run && it->lumi_ == lumi && it->event_ != event) {
         ++it;
      }
      if(it->run_ != run || it->lumi_ != lumi || it->event_ != event) {
        return itEnd;
      }
    }
    return it;
  }
FileIndex::const_iterator edm::FileIndex::findLumiOrRunPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 152 of file FileIndex.cc.

References entries_, findPosition(), kLumi, and kRun.

                                                                                      {
    const_iterator it = findPosition(run, lumi, 0U);
    const_iterator itEnd = entries_.end();
    while(it != itEnd && it->getEntryType() != FileIndex::kLumi && it->getEntryType() != FileIndex::kRun) {
      ++it;
    }
    return it;
  }
FileIndex::const_iterator edm::FileIndex::findLumiPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
) const

Definition at line 120 of file FileIndex.cc.

References entries_, findPosition(), and kLumi.

Referenced by containsLumi(), and fwlite::EntryFinder::findLumi().

                                                                                 {
    const_iterator it = findPosition(run, lumi, 0U);
    const_iterator itEnd = entries_.end();
    while(it != itEnd && it->getEntryType() != FileIndex::kLumi) {
      ++it;
    }
    if(it == itEnd) {
      return itEnd;
    }
    if(it->run_ != run || it->lumi_ != lumi) {
      return itEnd;
    }
    return it;
  }
FileIndex::const_iterator edm::FileIndex::findPosition ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi = 0U,
EventNumber_t  event = 0U 
) const

Definition at line 67 of file FileIndex.cc.

References entries_, kNotSorted, kSorted_Run_Lumi_Event, edm::lower_bound_all(), and sortState().

Referenced by findEventPosition(), findLumiOrRunPosition(), findLumiPosition(), and findRunPosition().

                                                                                                  {
    assert(sortState() != kNotSorted);

    const_iterator itEnd = entries_.end();
    const_iterator it;
    Element el(run, lumi, event);
    if (sortState() == kSorted_Run_Lumi_Event) {
      it =  lower_bound_all(entries_, el);
      bool lumiMissing = (lumi == 0 && event != 0);
      if(lumiMissing) {
        while(it != itEnd && it->run_ < run) {
          ++it;
        }
        while(it != itEnd && (it->run_ == run && it->event_ < event)) {
          ++it;
        }
      }
    } else {
      it = lower_bound_all(entries_, el, Compare_Run_Lumi_EventEntry());
    }
    return it;
  }
FileIndex::const_iterator edm::FileIndex::findRunPosition ( RunNumber_t  run) const

Definition at line 136 of file FileIndex.cc.

References entries_, findPosition(), and kRun.

Referenced by containsRun(), and fwlite::EntryFinder::findRun().

                                                  {
    const_iterator it = findPosition(run, 0U, 0U);
    const_iterator itEnd = entries_.end();
    while(it != itEnd && it->getEntryType() != FileIndex::kRun) {
      ++it;
    }
    if(it == itEnd) {
      return itEnd;
    }
    if(it->run_ != run) {
      return itEnd;
    }
    return it;
  }
void edm::FileIndex::initializeTransients ( ) const [inline]

Definition at line 118 of file FileIndex.h.

References edm::FileIndex::Transients::reset(), and transient_.

bool& edm::FileIndex::resultCached ( ) const [inline, private]
std::vector<Element>::size_type edm::FileIndex::size ( void  ) const [inline]

Definition at line 110 of file FileIndex.h.

References entries_.

{return entries_.size();}
void edm::FileIndex::sortBy_Run_Lumi_Event ( )
void edm::FileIndex::sortBy_Run_Lumi_EventEntry ( )

Definition at line 41 of file FileIndex.cc.

References entries_, kSorted_Run_Lumi_EventEntry, resultCached(), sortState(), and edm::stable_sort_all().

                                             {
    stable_sort_all(entries_, Compare_Run_Lumi_EventEntry());
    resultCached() = false;
    sortState() = kSorted_Run_Lumi_EventEntry;
  }
SortState& edm::FileIndex::sortState ( ) const [inline, private]

Member Data Documentation

std::vector<Element> edm::FileIndex::entries_ [private]

Definition at line 135 of file FileIndex.h.

Referenced by allInEntryOrder(), initializeTransients(), resultCached(), and sortState().