evio
6.0
|
Reader class that reads files stored in the HIPO format. More...
#include <Reader.h>
Public Member Functions | |
Reader () | |
Default constructor. More... | |
Reader (std::string const &filename) | |
Constructor with filename. More... | |
Reader (std::string const &filename, bool forceScan) | |
Constructor with filename. More... | |
Reader (std::shared_ptr< ByteBuffer > &buffer, bool checkRecordNumSeq=false) | |
Constructor for reading buffer with evio data. More... | |
~Reader ()=default | |
void | open (std::string const &filename, bool scan=true) |
Opens an input stream in binary mode. More... | |
void | close () |
This closes the file. More... | |
bool | isClosed () const |
Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))? More... | |
bool | isFile () const |
Is a file being read? More... | |
std::string | getFileName () const |
Get the name of the file being read. More... | |
size_t | getFileSize () const |
Get the size of the file being read, in bytes. More... | |
void | setBuffer (std::shared_ptr< ByteBuffer > &buf) |
This method can be used to avoid creating additional Reader objects by reusing this one with another buffer. More... | |
std::shared_ptr< ByteBuffer > | getBuffer () |
Get the buffer being read, if any. More... | |
size_t | getBufferOffset () const |
Get the beginning position of the buffer being read. More... | |
FileHeader & | getFileHeader () |
Get the file header from reading a file. More... | |
std::shared_ptr< RecordHeader > & | getFirstRecordHeader () |
Get the first record header from reading a file/buffer. More... | |
ByteOrder & | getByteOrder () |
Get the byte order of the file/buffer being read. More... | |
uint32_t | getVersion () const |
Get the Evio format version number of the file/buffer being read. More... | |
bool | isCompressed () const |
Is the data in the file/buffer compressed? More... | |
bool | isEvioFormat () const |
Does this file/buffer contain non-evio format events? More... | |
std::string | getDictionary () |
Get the XML format dictionary if there is one. More... | |
bool | hasDictionary () const |
Does this evio file/buffer have an associated XML dictionary? More... | |
std::shared_ptr< uint8_t > & | getFirstEvent (uint32_t *size) |
Get a byte array representing the first event. More... | |
uint32_t | getFirstEventSize () |
Get size, in bytes, of byte array representing the first event. More... | |
bool | hasFirstEvent () const |
Does this evio file/buffer have an associated first event? More... | |
uint32_t | getEventCount () const |
Get the number of events in file/buffer. More... | |
uint32_t | getRecordCount () const |
Get the number of records read from the file/buffer. More... | |
std::vector< RecordPosition > & | getRecordPositions () |
Returns a reference to the list of record positions in the file. More... | |
std::vector< std::shared_ptr < EvioNode > > & | getEventNodes () |
Get a reference to the list of EvioNode objects contained in the buffer being read. More... | |
bool | getCheckRecordNumberSequence () const |
Get whether or not record numbers are enforced to be sequential. More... | |
uint32_t | getNumEventsRemaining () const |
Get the number of events remaining in the file/buffer. More... | |
std::shared_ptr< uint8_t > | getNextEvent (uint32_t *len) |
Get a byte array representing the next event from the file/buffer while sequentially reading. More... | |
std::shared_ptr< uint8_t > | getPrevEvent (uint32_t *len) |
Get a byte array representing the previous event from the sequential queue. More... | |
std::shared_ptr< EvioNode > | getNextEventNode () |
Get an EvioNode representing the next event from the buffer while sequentially reading. More... | |
std::shared_ptr< ByteBuffer > | readUserHeader () |
Reads user header of the file header/first record header of buffer. More... | |
std::shared_ptr< uint8_t > | getEvent (uint32_t index, uint32_t *len) |
Get a byte array representing the specified event from the file/buffer. More... | |
ByteBuffer & | getEvent (ByteBuffer &buf, uint32_t index) |
Get a byte array representing the specified event from the file/buffer and place it in the given buf. More... | |
std::shared_ptr< ByteBuffer > | getEvent (std::shared_ptr< ByteBuffer > &buf, uint32_t index) |
Get a byte array representing the specified event from the file/buffer and place it in the given buf. More... | |
uint32_t | getEventLength (uint32_t index) |
Returns the length of the event with given index. More... | |
std::shared_ptr< EvioNode > | getEventNode (uint32_t index) |
Get an EvioNode representing the specified event from the buffer. More... | |
bool | hasNext () const |
Checks if the file has an event to read next. More... | |
bool | hasPrev () const |
Checks if the stream has previous event to be accessed through, getPrevEvent() More... | |
uint32_t | getRecordEventCount () const |
Get the number of events in current record. More... | |
uint32_t | getCurrentRecord () const |
Get the index of the current record. More... | |
RecordInput & | getCurrentRecordStream () |
Get the current record stream. More... | |
bool | readRecord (uint32_t index) |
Reads record from the file/buffer at the given record index. More... | |
Protected Member Functions | |
void | extractDictionaryAndFirstEvent () |
Extract dictionary and first event from file/buffer if possible, else do nothing. More... | |
void | extractDictionaryFromBuffer () |
Extract dictionary and first event from buffer if possible, else do nothing. More... | |
void | extractDictionaryFromFile () |
Extract dictionary and first event from file if possible, else do nothing. More... | |
std::shared_ptr< ByteBuffer > | scanBuffer () |
This method scans a buffer to find all records and store their position, length, and event count. More... | |
void | scanUncompressedBuffer () |
Scan buffer containing uncompressed data to find all records and store their position, length, and event count. More... | |
void | forceScanFile () |
Scan file to find all records and store their position, length, and event count. More... | |
void | scanFile (bool force) |
Scans the file to index all the record positions. More... | |
std::shared_ptr< ByteBuffer > & | addStructure (uint32_t eventNumber, ByteBuffer &addBuffer) |
This method adds an evio container (bank, segment, or tag segment) as the last structure contained in an event. More... | |
std::shared_ptr< ByteBuffer > & | removeStructure (std::shared_ptr< EvioNode > &removeNode) |
This method removes the data, represented by the given node, from the buffer. More... | |
void | show () const |
Print out all record position information. More... | |
Static Protected Member Functions | |
static void | findRecordInfo (std::shared_ptr< ByteBuffer > &buf, uint32_t offset, uint32_t *info, uint32_t infoLen) |
Reads data from a record header in order to determine things like the bitInfo word, various lengths, etc. More... | |
static void | findRecordInfo (ByteBuffer &buf, uint32_t offset, uint32_t *info, uint32_t infoLen) |
Reads data from a record header in order to determine things like the bitInfo word, various lengths, etc. More... | |
Friends | |
class | EvioCompactReaderV6 |
Reader class that reads files stored in the HIPO format.
File has this structure:
+----------------------------------+
| General File Header |
+----------------------------------+
+----------------------------------+
| Index (optional) |
+----------------------------------+
+----------------------------------+
| User Header (optional) |
+----------------------------------+
+----------------------------------+
| |
| Record 1 |
| |
| |
| |
+----------------------------------+
...
+----------------------------------+
| |
| Record N |
| |
| |
| |
+----------------------------------+
+----------------------------------+
| Trailer (optional) |
+----------------------------------+
+----------------------------------+
| Trailer's Index (optional) |
+----------------------------------+
Buffer or streamed data has this structure:
+----------------------------------+
| |
| Record 1 |
| |
| |
| |
+----------------------------------+
...
+----------------------------------+
| |
| Record N |
| |
| |
| |
+----------------------------------+
+----------------------------------+
| Trailer (optional) |
+----------------------------------+
The important thing with a buffer or streaming is for the last header or
trailer to set the "last record" bit.
Something to keep in mind is one can intersperse sequential calls (getNextEvent, getPrevEvent, or getNextEventNode) with random access calls (getEvent or getEventNode), and the sequence remains unchanged after the random access.
evio::Reader::Reader | ( | ) |
Default constructor.
Does nothing. The open(std::string const &, bool) method has to be called to open the input stream. Also forceScanFile() needs to be called to find records.
|
explicit |
Constructor with filename.
Creates instance and opens the input stream with given name. Uses existing indexes in file before scanning.
filename | input file name. |
IOException | if error reading file |
EvioException | if file is not in the proper format or earlier than version 6 |
References open().
evio::Reader::Reader | ( | std::string const & | filename, |
bool | forceScan | ||
) |
Constructor with filename.
Creates instance and opens the input stream with given name.
filename | input file name. |
forceScan | if true, force a scan of file, else use existing indexes first. |
IOException | if error reading file |
EvioException | if file is not in the proper format or earlier than version 6 |
References open(), and scanFile().
|
explicit |
Constructor for reading buffer with evio data.
Buffer must be ready to read with position and limit set properly. If the given buffer contains compressed data, it is uncompressed into another buffer. The buffer containing the newly uncompressed data then becomes the internal buffer of this object. It can be obtained by calling getBuffer.
buffer | buffer with evio data. |
checkRecordNumSeq | if true, check to see if all record numbers are in order, if not throw exception. |
EvioException | if buffer too small, not in the proper format, or earlier than version 6; if checkRecordNumSeq is true and records are out of sequence. |
References scanBuffer().
|
default |
|
protected |
This method adds an evio container (bank, segment, or tag segment) as the last structure contained in an event.
It is the responsibility of the caller to make sure that the buffer argument contains valid evio data (only data representing the structure to be added - not in file format with record header and the like) which is compatible with the type of data stored in the given event.
To produce such evio data use EvioBank#write(ByteBuffer &), EvioSegment#write(ByteBuffer &) or EvioTagSegment#write(ByteBuffer &) depending on whether a bank, seg, or tagseg is being added.
The given buffer argument must be ready to read with its position and limit defining the limits of the data to copy.
eventNumber | number of event to which addBuffer is to be added |
addBuffer | buffer containing evio data to add (not evio file format, i.e. no record headers) |
EvioException | if eventNumber out of bounds; if addBuffer arg is empty or has non-evio format; if addBuffer is opposite endian to current event buffer; if added data is not the proper length (i.e. multiple of 4 bytes); if the event number does not correspond to an existing event; if there is an internal programming error; if object closed |
References evio::ByteBuffer::order(), evio::ByteBuffer::remaining(), scanBuffer(), and evio::RecordHeader::UNCOMPRESSED_LENGTH_OFFSET.
Referenced by evio::EvioCompactReaderV6::addStructure().
void evio::Reader::close | ( | ) |
This closes the file.
Referenced by setBuffer().
|
protected |
Extract dictionary and first event from file/buffer if possible, else do nothing.
References extractDictionaryFromBuffer(), and extractDictionaryFromFile().
Referenced by getDictionary(), getFirstEvent(), and getFirstEventSize().
|
protected |
Extract dictionary and first event from buffer if possible, else do nothing.
References evio::RecordInput::getEvent(), and evio::RecordInput::readRecord().
Referenced by extractDictionaryAndFirstEvent().
|
protected |
Extract dictionary and first event from file if possible, else do nothing.
References evio::FileHeader::getByteOrder(), evio::RecordInput::getEvent(), evio::FileHeader::getHeaderLength(), evio::FileHeader::getIndexLength(), evio::FileHeader::getUserHeaderLength(), evio::FileHeader::hasDictionary(), evio::FileHeader::hasFirstEvent(), and evio::RecordInput::readRecord().
Referenced by extractDictionaryAndFirstEvent().
|
staticprotected |
Reads data from a record header in order to determine things like the bitInfo word, various lengths, etc.
Does not change the position or limit of buffer.
buf | buffer containing evio header. |
offset | byte offset into buffer. |
info | array in which to store header info. Elements are:
|
infoLen | len in 32-bit words of array at info. |
underflow_error | if not enough data in buffer. |
EvioException | null info arg or info.length < 7. |
|
staticprotected |
Reads data from a record header in order to determine things like the bitInfo word, various lengths, etc.
Does not change the position or limit of buffer.
buf | buffer containing evio header. |
offset | byte offset into buffer. |
info | array in which to store header info. Elements are:
|
infoLen | len in 32-bit words of array at info. |
underflow_error | if not enough data in buffer. |
EvioException | null info arg or info.length < 7. |
References evio::RecordHeader::BIT_INFO_OFFSET, evio::ByteBuffer::capacity(), evio::RecordHeader::COMPRESSION_TYPE_OFFSET, evio::RecordHeader::EVENT_COUNT_OFFSET, evio::ByteBuffer::getInt(), evio::RecordHeader::HEADER_LENGTH_OFFSET, evio::RecordHeader::INDEX_ARRAY_OFFSET, evio::ByteBuffer::limit(), evio::RecordHeader::RECORD_LENGTH_OFFSET, evio::RecordHeader::UNCOMPRESSED_LENGTH_OFFSET, and evio::RecordHeader::USER_LENGTH_OFFSET.
|
protected |
Scan file to find all records and store their position, length, and event count.
Safe to call this method successively.
IOException | if error reading file |
EvioException | if file is not in the proper format or earlier than version 6; if checkRecordNumberSequence is true and records are out of sequence. |
References evio::FileEventIndex::addEventSize(), evio::FileEventIndex::clear(), evio::FileHeader::getByteOrder(), evio::RecordHeader::getEntries(), evio::FileHeader::getHeaderLength(), evio::FileHeader::getIndexLength(), evio::RecordHeader::getLength(), evio::RecordHeader::getRecordNumber(), evio::FileHeader::getUserHeaderLength(), evio::FileHeader::getUserHeaderLengthPadding(), evio::FileHeader::getVersion(), evio::RecordHeader::HEADER_SIZE_BYTES, evio::FileHeader::readHeader(), evio::RecordHeader::readHeader(), and evio::Compressor::UNCOMPRESSED.
Referenced by scanFile().
std::shared_ptr< ByteBuffer > evio::Reader::getBuffer | ( | ) |
Get the buffer being read, if any.
This may not be the buffer given in the constructor or in setBuffer if the original data was compressed. All data in the returned buffer is uncompressed.
Referenced by evio::EvioCompactReaderV6::close(), evio::EvioCompactReaderV6::getByteBuffer(), and evio::EvioCompactReaderV6::toFile().
size_t evio::Reader::getBufferOffset | ( | ) | const |
Get the beginning position of the buffer being read.
Referenced by evio::EvioCompactReaderV6::close().
ByteOrder & evio::Reader::getByteOrder | ( | ) |
Get the byte order of the file/buffer being read.
Referenced by evio::EvioCompactReaderV6::getByteOrder(), and evio::EvioCompactReaderV6::getFileByteOrder().
bool evio::Reader::getCheckRecordNumberSequence | ( | ) | const |
Get whether or not record numbers are enforced to be sequential.
uint32_t evio::Reader::getCurrentRecord | ( | ) | const |
Get the index of the current record.
RecordInput & evio::Reader::getCurrentRecordStream | ( | ) |
Get the current record stream.
std::string evio::Reader::getDictionary | ( | ) |
Get the XML format dictionary if there is one.
References extractDictionaryAndFirstEvent().
Referenced by evio::EvioCompactReaderV6::getDictionary(), and evio::EvioCompactReaderV6::getDictionaryXML().
std::shared_ptr< uint8_t > evio::Reader::getEvent | ( | uint32_t | index, |
uint32_t * | len | ||
) |
Get a byte array representing the specified event from the file/buffer.
If index is out of bounds, null is returned.
index | index of specified event within the entire file/buffer, contiguous starting at 0. |
len | pointer to int that gets filled with the returned event's len in bytes. |
EvioException | if file/buffer not in hipo format |
References evio::RecordInput::getEntries(), evio::RecordInput::getEvent(), evio::FileEventIndex::getMaxEvents(), evio::FileEventIndex::getRecordEventNumber(), evio::FileEventIndex::getRecordNumber(), readRecord(), and evio::FileEventIndex::setEvent().
Referenced by getEvent(), getNextEvent(), and getPrevEvent().
ByteBuffer & evio::Reader::getEvent | ( | ByteBuffer & | buf, |
uint32_t | index | ||
) |
Get a byte array representing the specified event from the file/buffer and place it in the given buf.
If no buf is given (arg is null), create a buffer internally and return it. If index is out of bounds, null is returned.
buf | buffer in which to place event data. |
index | index of specified event within the entire file/buffer, contiguous starting at 0. |
EvioException | if file/buffer not in hipo format, if buf has insufficient space to contain event (buf.capacity() < event size), or index too large. |
References evio::RecordInput::getEntries(), evio::RecordInput::getEvent(), evio::FileEventIndex::getMaxEvents(), evio::FileEventIndex::getRecordEventNumber(), evio::FileEventIndex::getRecordNumber(), readRecord(), and evio::FileEventIndex::setEvent().
std::shared_ptr< ByteBuffer > evio::Reader::getEvent | ( | std::shared_ptr< ByteBuffer > & | buf, |
uint32_t | index | ||
) |
Get a byte array representing the specified event from the file/buffer and place it in the given buf.
If no buf is given (arg is null), create a buffer internally and return it. If index is out of bounds, null is returned.
buf | buffer in which to place event data. |
index | index of specified event within the entire file/buffer, contiguous starting at 0. |
EvioException | if file/buffer not in hipo format, if buf has insufficient space to contain event (buf.capacity() < event size), or index too large. |
References getEvent().
uint32_t evio::Reader::getEventCount | ( | ) | const |
Get the number of events in file/buffer.
References evio::FileEventIndex::getMaxEvents().
Referenced by evio::EvioCompactReaderV6::getEventCount(), and evio::EvioCompactReaderV6::searchEvent().
uint32_t evio::Reader::getEventLength | ( | uint32_t | index | ) |
Returns the length of the event with given index.
index | index of the event |
References evio::RecordInput::getEntries(), evio::RecordInput::getEventLength(), evio::FileEventIndex::getMaxEvents(), evio::FileEventIndex::getRecordEventNumber(), evio::FileEventIndex::getRecordNumber(), readRecord(), and evio::FileEventIndex::setEvent().
std::shared_ptr< EvioNode > evio::Reader::getEventNode | ( | uint32_t | index | ) |
Get an EvioNode representing the specified event from the buffer.
If index is out of bounds, nullptr is returned.
index | index of specified event within the entire buffer, starting at 0. |
EvioException | index too large or reading from file. |
References evio::FileEventIndex::getMaxEvents().
Referenced by evio::EvioCompactReaderV6::getEvent(), evio::EvioCompactReaderV6::getEventBuffer(), and evio::EvioCompactReaderV6::removeEvent().
std::vector< std::shared_ptr< EvioNode > > & evio::Reader::getEventNodes | ( | ) |
FileHeader & evio::Reader::getFileHeader | ( | ) |
Get the file header from reading a file.
std::string evio::Reader::getFileName | ( | ) | const |
Get the name of the file being read.
size_t evio::Reader::getFileSize | ( | ) | const |
Get the size of the file being read, in bytes.
Referenced by evio::EvioCompactReaderV6::fileSize().
std::shared_ptr< uint8_t > & evio::Reader::getFirstEvent | ( | uint32_t * | size | ) |
Get a byte array representing the first event.
size | pointer filled with the size, in bytes, of the first event (0 if none). If null, this is ignored. |
References extractDictionaryAndFirstEvent().
uint32_t evio::Reader::getFirstEventSize | ( | ) |
Get size, in bytes, of byte array representing the first event.
References extractDictionaryAndFirstEvent().
std::shared_ptr< RecordHeader > & evio::Reader::getFirstRecordHeader | ( | ) |
Get the first record header from reading a file/buffer.
Referenced by evio::EvioCompactReaderV6::getFirstBlockHeader().
std::shared_ptr< uint8_t > evio::Reader::getNextEvent | ( | uint32_t * | len | ) |
Get a byte array representing the next event from the file/buffer while sequentially reading.
If the previous call was to getPrevEvent, this will get the event past what that returned. Once the last event is returned, this will return null.
len | pointer to int that gets filled with the returned event's len in bytes. |
EvioException | if file/buffer not in hipo format |
References getEvent().
std::shared_ptr< EvioNode > evio::Reader::getNextEventNode | ( | ) |
Get an EvioNode representing the next event from the buffer while sequentially reading.
Calling this and calling getNextEvent() have the same effect in terms of advancing the same internal counter. If the previous call was to getPrevEvent, this will get the event past what that returned. Once the last event is returned, this will return null.
References evio::FileEventIndex::getMaxEvents().
uint32_t evio::Reader::getNumEventsRemaining | ( | ) | const |
Get the number of events remaining in the file/buffer.
Useful only if doing a sequential read.
References evio::FileEventIndex::getMaxEvents().
std::shared_ptr< uint8_t > evio::Reader::getPrevEvent | ( | uint32_t * | len | ) |
Get a byte array representing the previous event from the sequential queue.
If the previous call was to getNextEvent, this will get the event previous to what that returned. If this is called before getNextEvent, it will always return null. Once the first event is returned, this will return null.
len | pointer to int that gets filled with the returned event's len in bytes. |
EvioException | if the file/buffer is not in HIPO format |
References getEvent().
uint32_t evio::Reader::getRecordCount | ( | ) | const |
Get the number of records read from the file/buffer.
Referenced by evio::EvioCompactReaderV6::getBlockCount().
uint32_t evio::Reader::getRecordEventCount | ( | ) | const |
Get the number of events in current record.
References evio::RecordInput::getEntries().
std::vector< Reader::RecordPosition > & evio::Reader::getRecordPositions | ( | ) |
Returns a reference to the list of record positions in the file.
uint32_t evio::Reader::getVersion | ( | ) | const |
Get the Evio format version number of the file/buffer being read.
Referenced by evio::EvioCompactReaderV6::getEvioVersion().
bool evio::Reader::hasDictionary | ( | ) | const |
Does this evio file/buffer have an associated XML dictionary?
true
if this evio file/buffer has an associated XML dictionary, else false
. References evio::FileHeader::hasDictionary().
Referenced by evio::EvioCompactReaderV6::hasDictionary().
bool evio::Reader::hasFirstEvent | ( | ) | const |
Does this evio file/buffer have an associated first event?
true
if this evio file/buffer has an associated first event, else false
. References evio::FileHeader::hasFirstEvent().
bool evio::Reader::hasNext | ( | ) | const |
Checks if the file has an event to read next.
References evio::FileEventIndex::canAdvance().
bool evio::Reader::hasPrev | ( | ) | const |
Checks if the stream has previous event to be accessed through, getPrevEvent()
References evio::FileEventIndex::canRetreat().
bool evio::Reader::isClosed | ( | ) | const |
Has close() been called (without reopening by calling setBuffer(std::shared_ptr<ByteBuffer> &))?
bool evio::Reader::isCompressed | ( | ) | const |
Is the data in the file/buffer compressed?
Referenced by evio::EvioCompactReaderV6::isCompressed().
bool evio::Reader::isEvioFormat | ( | ) | const |
Does this file/buffer contain non-evio format events?
Referenced by evio::EvioCompactReaderV6::EvioCompactReaderV6(), and evio::EvioCompactReaderV6::setBuffer().
bool evio::Reader::isFile | ( | ) | const |
Is a file being read?
Referenced by evio::EvioCompactReaderV6::isFile().
void evio::Reader::open | ( | std::string const & | filename, |
bool | scan = true |
||
) |
Opens an input stream in binary mode.
Scans for records in the file and stores record information in internal array. Each record can be read from the file.
filename | input file name |
scan | if true, call scanFile(false). |
EvioException | if error handling file |
References scanFile().
Referenced by evio::EvioCompactReaderV6::EvioCompactReaderV6(), and Reader().
bool evio::Reader::readRecord | ( | uint32_t | index | ) |
Reads record from the file/buffer at the given record index.
index | record index (starting at 0). |
EvioException | if file/buffer not in hipo format |
References evio::RecordInput::readRecord().
Referenced by getEvent(), and getEventLength().
std::shared_ptr< ByteBuffer > evio::Reader::readUserHeader | ( | ) |
Reads user header of the file header/first record header of buffer.
The returned ByteBuffer also contains endianness of the file/buffer.
IOException | if error reading file |
References evio::FileHeader::getByteOrder(), evio::FileHeader::getHeaderLength(), evio::FileHeader::getIndexLength(), and evio::FileHeader::getUserHeaderLength().
|
protected |
This method removes the data, represented by the given node, from the buffer.
It also marks all nodes taken from that buffer as obsolete. They must not be used anymore.
removeNode | evio structure to remove from buffer |
EvioException | if object closed; if node was not found in any event; if internal programming error; if buffer has compressed data; |
References evio::ByteBuffer::limit(), scanBuffer(), evio::Compressor::UNCOMPRESSED, and evio::RecordHeader::UNCOMPRESSED_LENGTH_OFFSET.
Referenced by evio::EvioCompactReaderV6::removeStructure().
|
protected |
This method scans a buffer to find all records and store their position, length, and event count.
It also finds all events and creates & stores their associated EvioNode objects. The difficulty with doing this is that the buffer may contain compressed data. It must then be uncompressed into a different buffer.
EvioException | if buffer not in the proper format or earlier than version 6; if checkRecordNumberSequence is true and records are out of sequence. |
underflow_error | if not enough data in buffer. |
References evio::FileEventIndex::addEventSize(), evio::ByteBuffer::array(), evio::ByteBuffer::arrayOffset(), evio::FileEventIndex::clear(), evio::HeaderType::EVIO_RECORD, evio::EvioNode::extractEventNode(), evio::RecordHeader::getByteOrder(), evio::RecordHeader::getEntries(), evio::RecordHeader::getHeaderLength(), evio::RecordHeader::getLength(), evio::RecordHeader::getRecordNumber(), evio::RecordHeader::getUncompressedRecordLength(), evio::RecordHeader::getVersion(), evio::RecordHeader::HEADER_SIZE_BYTES, evio::RecordHeader::isCompressed(), evio::RecordHeader::isLastRecord(), evio::ByteBuffer::order(), evio::ByteBuffer::position(), scanUncompressedBuffer(), and evio::RecordInput::uncompressRecord().
Referenced by addStructure(), Reader(), removeStructure(), and setBuffer().
|
protected |
Scans the file to index all the record positions.
It takes advantage of any existing indexes in file.
force | if true, force a file scan even if header or trailer have index info. |
IOException | if error reading file |
EvioException | if file is not in the proper format or earlier than version 6 |
References evio::FileEventIndex::addEventSize(), evio::FileEventIndex::clear(), forceScanFile(), evio::FileHeader::getByteOrder(), evio::FileHeader::getHeaderLength(), evio::FileHeader::getIndexLength(), evio::RecordHeader::getIndexLength(), evio::FileHeader::getLength(), evio::FileHeader::getTrailerPosition(), evio::FileHeader::getVersion(), evio::FileHeader::hasIndex(), evio::FileHeader::hasTrailerWithIndex(), evio::FileHeader::HEADER_SIZE_BYTES, evio::RecordHeader::HEADER_SIZE_BYTES, evio::FileHeader::readHeader(), evio::RecordHeader::readHeader(), evio::Util::toIntArray(), and evio::Compressor::UNCOMPRESSED.
|
protected |
Scan buffer containing uncompressed data to find all records and store their position, length, and event count.
Also finds all events and creates & stores their associated EvioNode objects.
EvioException | if buffer too small, not in the proper format, or earlier than version 6; if checkRecordNumberSequence is true and records are out of sequence. |
References evio::FileEventIndex::addEventSize(), evio::ByteBuffer::array(), evio::FileEventIndex::clear(), evio::EvioNode::extractEventNode(), evio::RecordHeader::getByteOrder(), evio::RecordHeader::getCompressionType(), evio::RecordHeader::getEntries(), evio::RecordHeader::getHeaderLength(), evio::RecordHeader::getIndexLength(), evio::RecordHeader::getLength(), evio::RecordHeader::getRecordNumber(), evio::RecordHeader::getUserHeaderLengthWords(), evio::RecordHeader::getVersion(), evio::RecordHeader::HEADER_SIZE_BYTES, evio::RecordHeader::readHeader(), and evio::Compressor::UNCOMPRESSED.
Referenced by scanBuffer().
void evio::Reader::setBuffer | ( | std::shared_ptr< ByteBuffer > & | buf | ) |
This method can be used to avoid creating additional Reader objects by reusing this one with another buffer.
If the given buffer contains compressed data, it is uncompressed into another buffer. The buffer containing the newly uncompressed data then becomes the internal buffer of this object. It can be obtained by calling getBuffer.
buf | ByteBuffer to be read |
underflow_error | if not enough data in buffer. |
EvioException | if buf arg is null, not in the proper format, or earlier than version 6 |
References evio::FileEventIndex::clear(), close(), and scanBuffer().
Referenced by evio::EvioCompactReaderV6::EvioCompactReaderV6(), and evio::EvioCompactReaderV6::setBuffer().
|
protected |
Print out all record position information.
|
friend |