Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip all entries (per file) at once, not one at a time. #9163

Merged
merged 1 commit into from
May 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions IOPool/Input/src/RootFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ namespace edm {
indexIntoFileIter_ = indexIntoFileEnd_;
}

bool skipEntries(unsigned int& offset) {return eventTree_.skipEntries(offset);}
bool skipEvents(int& offset);
bool goToEvent(EventID const& eventID);
bool nextEventEntry() {return eventTree_.next();}
Expand Down
22 changes: 10 additions & 12 deletions IOPool/Input/src/RootInputFileSequence.cc
Original file line number Diff line number Diff line change
Expand Up @@ -703,19 +703,17 @@ namespace edm {

void
RootInputFileSequence::skipEntries(unsigned int offset) {
while(offset > 0) {
while(offset > 0 && rootFile_->nextEventEntry()) {
--offset;
}
if(offset > 0) {
++fileIter_;
if(fileIter_ == fileIterEnd_) {
fileIter_ = fileIterBegin_;
}
initFile(false);
assert(rootFile_);
rootFile_->setAtEventEntry(IndexIntoFile::invalidEntry);
// offset is decremented by the number of events actually skipped.
bool completed = rootFile_->skipEntries(offset);
while(!completed) {
++fileIter_;
if(fileIter_ == fileIterEnd_) {
fileIter_ = fileIterBegin_;
}
initFile(false);
assert(rootFile_);
rootFile_->setAtEventEntry(IndexIntoFile::invalidEntry);
completed = rootFile_->skipEntries(offset);
}
}

Expand Down
16 changes: 16 additions & 0 deletions IOPool/Input/src/RootTree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,22 @@ namespace edm {
}
}

bool
RootTree::skipEntries(unsigned int& offset) {
entryNumber_ += offset;
bool retval = (entryNumber_ < entries_);
if(retval) {
offset = 0;
} else {
// Not enough entries in the file to skip.
// The +1 is needed because entryNumber_ is -1 at the initialization of the tree, not 0.
long long overshoot = entryNumber_ + 1 - entries_;
entryNumber_ = entries_;
offset = overshoot;
}
return retval;
}

void
RootTree::startTraining() {
if (cacheSize_ == 0) {
Expand Down
1 change: 1 addition & 0 deletions IOPool/Input/src/RootTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ namespace edm {
bool current(EntryNumber entry) const {return entry < entries_ && entry >= 0;}
void rewind() {entryNumber_ = 0;}
void close();
bool skipEntries(unsigned int& offset);
EntryNumber const& entryNumber() const {return entryNumber_;}
EntryNumber const& entryNumberForIndex(unsigned int index) const;
EntryNumber const& entries() const {return entries_;}
Expand Down