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
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_
Transient< Transientstransients_

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.

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 22 of file FileIndex.cc.

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

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

Definition at line 40 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 127 of file FileIndex.h.

References edm::Transient< T >::get(), and transients_.

Referenced by allEventsInEntryOrder().

{return transients_.get().allInEntryOrder_;}
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<<().

{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 156 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 85 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 146 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 114 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 60 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 130 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;
  }
bool& edm::FileIndex::resultCached ( ) const [inline, private]

Definition at line 128 of file FileIndex.h.

References edm::Transient< T >::get(), and transients_.

Referenced by addEntry(), allEventsInEntryOrder(), sortBy_Run_Lumi_Event(), and sortBy_Run_Lumi_EventEntry().

{return transients_.get().resultCached_;}
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 34 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 132 of file FileIndex.h.

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