LCIO
02.17
|
Manager class for LCIO direct access. More...
#include <LCIORandomAccessMgr.h>
Public Types | |
typedef RunEvent::long64 | long64 |
typedef std::list < std::shared_ptr < LCIORandomAccess > > | LCIORandomAccessList |
Public Member Functions | |
LCIORandomAccessMgr ()=default | |
LCIORandomAccessMgr (const LCIORandomAccessMgr &)=delete | |
LCIORandomAccessMgr & | operator= (const LCIORandomAccessMgr &)=delete |
~LCIORandomAccessMgr ()=default | |
long64 | getPosition (const RunEvent &re) |
Return the position of the specified Event record or Run record respectively (if EventNum == -1 ). More... | |
void | add (const RunEvent &re, long64 pos) |
Add a new entry to the event map - if the RunEvent already exists the new position will be stored. More... | |
bool | createEventMap (sio::ifstream &stream) |
Get the run and event header map from the stream - either by reading the random access records or by recreating it for old files. More... | |
std::shared_ptr< RunEventMap > | getEventMap () |
Return the event map - it will be empty, if not yet created. More... | |
bool | initAppend (sio::ifstream &stream) |
Initialize random access for append mode: read last LCIORandomAccess record if it exists - recreate the RunEvent map from the file if not (old files). More... | |
void | writeRandomAccessRecords (sio::ofstream &stream) |
Write the current random access records LCIOIndex and LCIORandomAccess to the stream. More... | |
void | clear () |
Clear all lists and maps before closing a file. More... | |
void | seekStream (sio::ifstream &stream, long64 pos) |
Seek the stream at the given position. More... | |
Protected Member Functions | |
std::shared_ptr< LCIORandomAccess > | createFromEventMap () const |
Prepare an LCIORandomAccess object from the current contents of RunEventMap (all file locations set to 0). More... | |
void | addLCIORandomAccess (std::shared_ptr< LCIORandomAccess > ra) |
Add a new LCIORandomAccess object to the list. More... | |
bool | readLCIORandomAccessAt (sio::ifstream &stream, long64 pos) |
Read the LCIORandomAccess record at the specified position. More... | |
bool | readLCIOIndexAt (sio::ifstream &stream, long64 pos) |
Read the LCIOIndex record at the specified position. More... | |
bool | recreateEventMap (sio::ifstream &stream) |
Fill the RunEventMap from the event and run header records in the file. More... | |
bool | readLCIORandomAccess (sio::ifstream &stream) |
Helper for reading the next LCIORandomAccess record (need preceeding call to LCSIO::seek() ) More... | |
bool | readLCIOIndex (sio::ifstream &stream) |
Helper for reading the next LCIOIndex record (need preceeding call to LCSIO::seek() ) More... | |
void | createFileRecord () |
Create file record from all LCIORandomAccess records. More... | |
const std::shared_ptr < LCIORandomAccess > | lastLCIORandomAccess () const |
Pointer to the last LCIORandomAccess in the list. More... | |
Private Attributes | |
sio::buffer | _rawBuffer { 32*sio::kbyte } |
sio::buffer | _compressBuffer { 32*sio::kbyte } |
std::shared_ptr< RunEventMap > | _runEvtMap {std::make_shared<RunEventMap>()} |
Map with RunHeader and EventHeader record positions. More... | |
LCIORandomAccessList | _list {} |
List of LCIORandomAccess objects. More... | |
std::shared_ptr< LCIORandomAccess > | _fileRecord {nullptr} |
The file record summary. More... | |
Friends | |
class | SIOIndexHandler |
class | SIORandomAccessHandler |
std::ostream & | operator<< (std::ostream &os, const LCIORandomAccessMgr &ra) |
Manager class for LCIO direct access.
Provides the functionality for reading and writing the LCIORandomAccess and LCIOIndex records as needed by SIOReader and SIOWriter. Direct Access is implemented through appending LCIOIndex and LCIORandomAccess and records to the end of the LCIO file. The LCIOIndex records hold the locations of the RunHeader and EventHeader in the file and are referenced by corresponding LCIORandomAccess records. The last record in the file will always be an LCIORandomAccess record - and previous records can be found through pointers to the previous record (simply linked list). LCIORandomAccess are always stored uncompressed. When reading a file with direct access mode a RunEvent map is created by reading all LCIORandomAccess and LCIOIndex records or - for old files - is recreated from all RunHeader and EventHeader records in the file. If an old file is opened in APPEND mode the corresponding records are created and written at the end on close()
Definition at line 43 of file LCIORandomAccessMgr.h.
typedef std::list<std::shared_ptr<LCIORandomAccess> > SIO::LCIORandomAccessMgr::LCIORandomAccessList |
Definition at line 50 of file LCIORandomAccessMgr.h.
Definition at line 49 of file LCIORandomAccessMgr.h.
|
default |
|
delete |
|
default |
Add a new entry to the event map - if the RunEvent already exists the new position will be stored.
Definition at line 67 of file LCIORandomAccessMgr.h.
References _runEvtMap.
Referenced by SIO::SIOWriter::writeEvent(), and SIO::SIOWriter::writeRunHeader().
|
protected |
Add a new LCIORandomAccess object to the list.
Definition at line 80 of file LCIORandomAccessMgr.cc.
References _list, and std::list< T >::push_back().
Referenced by readLCIORandomAccess(), and writeRandomAccessRecords().
void SIO::LCIORandomAccessMgr::clear | ( | ) |
Clear all lists and maps before closing a file.
Definition at line 23 of file LCIORandomAccessMgr.cc.
References _fileRecord, _list, _runEvtMap, and std::list< T >::clear().
Referenced by SIO::SIOWriter::close().
bool SIO::LCIORandomAccessMgr::createEventMap | ( | sio::ifstream & | stream | ) |
Get the run and event header map from the stream - either by reading the random access records or by recreating it for old files.
Definition at line 191 of file LCIORandomAccessMgr.cc.
References _fileRecord, _list, std::list< T >::back(), lastLCIORandomAccess(), std::list< T >::pop_back(), SIO::LCSIO::RandomAccessSize, readLCIOIndexAt(), readLCIORandomAccessAt(), recreateEventMap(), and seekStream().
|
protected |
Create file record from all LCIORandomAccess records.
Definition at line 47 of file LCIORandomAccessMgr.cc.
References _fileRecord, _list, std::list< T >::begin(), and std::list< T >::end().
Referenced by writeRandomAccessRecords().
|
protected |
Prepare an LCIORandomAccess object from the current contents of RunEventMap (all file locations set to 0).
Definition at line 31 of file LCIORandomAccessMgr.cc.
References _runEvtMap.
Referenced by writeRandomAccessRecords().
|
inline |
Return the event map - it will be empty, if not yet created.
Definition at line 78 of file LCIORandomAccessMgr.h.
References _runEvtMap.
Return the position of the specified Event record or Run record respectively (if EventNum == -1 ).
Returns RunEventMap::NPos if no record found.
Definition at line 61 of file LCIORandomAccessMgr.h.
References _runEvtMap.
bool SIO::LCIORandomAccessMgr::initAppend | ( | sio::ifstream & | stream | ) |
Initialize random access for append mode: read last LCIORandomAccess record if it exists - recreate the RunEvent map from the file if not (old files).
Definition at line 175 of file LCIORandomAccessMgr.cc.
References _fileRecord, _list, std::list< T >::back(), std::list< T >::pop_back(), SIO::LCSIO::RandomAccessSize, readLCIORandomAccessAt(), and recreateEventMap().
Referenced by SIO::SIOWriter::open().
|
inlineprotected |
Pointer to the last LCIORandomAccess in the list.
Definition at line 124 of file LCIORandomAccessMgr.h.
References _list, std::list< T >::back(), and std::list< T >::empty().
Referenced by createEventMap(), and writeRandomAccessRecords().
|
delete |
|
protected |
Helper for reading the next LCIOIndex record (need preceeding call to LCSIO::seek() )
Definition at line 134 of file LCIORandomAccessMgr.cc.
References _rawBuffer, _runEvtMap, SIO::LCSIO::IndexRecordName, and seekStream().
Referenced by readLCIOIndexAt().
Read the LCIOIndex record at the specified position.
Definition at line 127 of file LCIORandomAccessMgr.cc.
References readLCIOIndex(), and seekStream().
Referenced by createEventMap().
|
protected |
Helper for reading the next LCIORandomAccess record (need preceeding call to LCSIO::seek() )
Definition at line 93 of file LCIORandomAccessMgr.cc.
References _rawBuffer, SIO::LCSIO::AccessRecordName, addLCIORandomAccess(), and seekStream().
Referenced by readLCIORandomAccessAt().
|
protected |
Read the LCIORandomAccess record at the specified position.
Definition at line 86 of file LCIORandomAccessMgr.cc.
References readLCIORandomAccess(), and seekStream().
Referenced by createEventMap(), and initAppend().
|
protected |
Fill the RunEventMap from the event and run header records in the file.
Definition at line 226 of file LCIORandomAccessMgr.cc.
References _compressBuffer, _rawBuffer, _runEvtMap, std::set< K >::end(), std::endl(), event, std::set< K >::find(), SIO::LCSIO::HeaderRecordName, SIO::SIOEventHeaderRecord::readBlocks(), SIO::SIORunHeaderRecord::readBlocks(), SIO::LCSIO::RunRecordName, and seekStream().
Referenced by createEventMap(), and initAppend().
void SIO::LCIORandomAccessMgr::seekStream | ( | sio::ifstream & | stream, |
long64 | pos | ||
) |
Seek the stream at the given position.
Definition at line 347 of file LCIORandomAccessMgr.cc.
References std::stringstream::rdstate(), and std::stringstream::str().
Referenced by createEventMap(), readLCIOIndex(), readLCIOIndexAt(), readLCIORandomAccess(), readLCIORandomAccessAt(), and recreateEventMap().
void SIO::LCIORandomAccessMgr::writeRandomAccessRecords | ( | sio::ofstream & | stream | ) |
Write the current random access records LCIOIndex and LCIORandomAccess to the stream.
Definition at line 289 of file LCIORandomAccessMgr.cc.
References _fileRecord, _rawBuffer, _runEvtMap, SIO::LCSIO::AccessRecordName, addLCIORandomAccess(), createFileRecord(), createFromEventMap(), SIO::LCSIO::IndexRecordName, and lastLCIORandomAccess().
Referenced by SIO::SIOWriter::close().
|
friend |
|
friend |
Definition at line 44 of file LCIORandomAccessMgr.h.
|
friend |
Definition at line 45 of file LCIORandomAccessMgr.h.
|
private |
Definition at line 131 of file LCIORandomAccessMgr.h.
Referenced by recreateEventMap().
|
private |
The file record summary.
Definition at line 137 of file LCIORandomAccessMgr.h.
Referenced by clear(), createEventMap(), createFileRecord(), initAppend(), and writeRandomAccessRecords().
|
private |
List of LCIORandomAccess objects.
Definition at line 135 of file LCIORandomAccessMgr.h.
Referenced by addLCIORandomAccess(), clear(), createEventMap(), createFileRecord(), initAppend(), lastLCIORandomAccess(), and SIO::operator<<().
|
private |
Definition at line 129 of file LCIORandomAccessMgr.h.
Referenced by readLCIOIndex(), readLCIORandomAccess(), recreateEventMap(), and writeRandomAccessRecords().
|
private |
Map with RunHeader and EventHeader record positions.
Definition at line 133 of file LCIORandomAccessMgr.h.
Referenced by add(), clear(), createFromEventMap(), getEventMap(), getPosition(), SIO::operator<<(), readLCIOIndex(), recreateEventMap(), and writeRandomAccessRecords().