evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
evio::EventWriter Class Reference

An EventWriter object is used for writing events to a file or to a byte buffer. More...

#include <EventWriter.h>

Public Member Functions

 EventWriter (std::string &filename, const ByteOrder &byteOrder=ByteOrder::nativeOrder(), bool append=false)
 Creates an EventWriter for writing to a file in the specified byte order. More...
 
 EventWriter (std::string &filename, std::string &dictionary, const ByteOrder &byteOrder=ByteOrder::nativeOrder(), bool append=false)
 Creates an EventWriter for writing to a file in NATIVE byte order. More...
 
 EventWriter (std::string baseName, const std::string &directory, const std::string &runType, uint32_t runNumber, uint64_t split, uint32_t maxRecordSize, uint32_t maxEventCount, const ByteOrder &byteOrder, const std::string &xmlDictionary, bool overWriteOK, bool append, std::shared_ptr< EvioBank > firstEvent, uint32_t streamId, uint32_t splitNumber, uint32_t splitIncrement, uint32_t streamCount, Compressor::CompressionType compressionType, uint32_t compressionThreads, uint32_t ringSize, uint32_t bufferSize)
 Create an EventWriter for writing events to a file. More...
 
 EventWriter (std::shared_ptr< ByteBuffer > &buf)
 Create an EventWriter for writing events to a ByteBuffer. More...
 
 EventWriter (std::shared_ptr< ByteBuffer > &buf, std::string &xmlDictionary)
 Create an EventWriter for writing events to a ByteBuffer. More...
 
 EventWriter (std::shared_ptr< ByteBuffer > &buf, uint32_t maxRecordSize, uint32_t maxEventCount, const std::string &xmlDictionary, uint32_t recordNumber, Compressor::CompressionType compressionType)
 Create an EventWriter for writing events to a ByteBuffer. More...
 
bool isDiskFull ()
 If writing file, is the partition it resides on full? Not full, in this context, means there's enough space to write a full split file + a full record + an extra 10MB as a safety factor. More...
 
void setBuffer (std::shared_ptr< ByteBuffer > &buf, std::bitset< 24 > *bitInfo, uint32_t recNumber)
 Set the buffer being written into (initially set in constructor). More...
 
void setBuffer (std::shared_ptr< ByteBuffer > &buf)
 Set the buffer being written into (initially set in constructor). More...
 
std::shared_ptr< ByteBuffergetByteBuffer ()
 If writing to a file, return null. More...
 
void setSourceId (int sId)
 Set the value of the source Id in the first block header. More...
 
void setEventType (int type)
 Set the bit info of a record header for a specified CODA event type. More...
 
bool writingToFile () const
 Is this object writing to file? More...
 
bool isClosed () const
 Has close() been called (without reopening by calling setBuffer()) ? More...
 
std::string getCurrentFilename () const
 Get the name of the current file being written to. More...
 
size_t getBytesWrittenToBuffer () const
 If writing to a buffer, get the number of bytes written to it including the trailer. More...
 
std::string getCurrentFilePath () const
 Get the full name or path of the current file being written to. More...
 
uint32_t getSplitNumber () const
 Get the current split number which is the split number of file to be written next. More...
 
uint32_t getSplitCount () const
 Get the number of split files produced by this writer. More...
 
uint32_t getRecordNumber () const
 Get the current record number. More...
 
uint32_t getEventsWritten () const
 Get the number of events written to a file/buffer. More...
 
ByteOrder getByteOrder () const
 Get the byte order of the buffer/file being written into. More...
 
void setStartingRecordNumber (uint32_t startingRecordNumber)
 Set the number with which to start block (record) numbers. More...
 
void setFirstEvent (std::shared_ptr< EvioNode > &node)
 Set an event which will be written to the file as well as to all split files. More...
 
void setFirstEvent (std::shared_ptr< ByteBuffer > &buf)
 Set an event which will be written to the file as well as to all split files. More...
 
void setFirstEvent (std::shared_ptr< EvioBank > bank)
 Set an event which will be written to the file as well as to all split files. More...
 
void flush ()
 This method flushes any remaining internally buffered data to file. More...
 
void close ()
 This method flushes any remaining data to file and disables this object. More...
 
bool hasRoom (uint32_t bytes)
 Is there room to write this many bytes to an output buffer as a single event? Will always return true when writing to a file. More...
 
bool writeEvent (std::shared_ptr< EvioNode > &node, bool force)
 Write an event (bank) into a record in evio/hipo version 6 format. More...
 
bool writeEvent (std::shared_ptr< EvioNode > &node, bool force, bool duplicate)
 Write an event (bank) into a record in evio/hipo version 6 format. More...
 
bool writeEventToFile (std::shared_ptr< EvioNode > &node, bool force, bool duplicate)
 Write an event (bank) into a record and eventually to a file in evio/hipo version 6 format. More...
 
bool writeEvent (std::shared_ptr< ByteBuffer > &bankBuffer)
 Write an event (bank) into a record in evio/hipo version 6 format. More...
 
bool writeEvent (std::shared_ptr< ByteBuffer > &bankBuffer, bool force)
 Write an event (bank) into a record in evio/hipo version 6 format. More...
 
bool writeEvent (std::shared_ptr< EvioBank > bank)
 Write an event (bank) into a record in evio/hipo version 6 format. More...
 
bool writeEvent (std::shared_ptr< EvioBank > bank, bool force)
 Write an event (bank) into a record in evio/hipo version 6 format. More...
 

Protected Member Functions

void examineFileHeader ()
 Reads part of the file header in order to determine the evio version # and endianness of the file in question. More...
 

Detailed Description

An EventWriter object is used for writing events to a file or to a byte buffer.

This class does NOT write versions 1-4 data, only version 6! This class is not thread-safe.

           FILE Uncompressed
   +----------------------------------+
   +                                  +
   +      General File Header         +
   +                                  +
   +----------------------------------+
   +----------------------------------+
   +                                  +
   +     Index Array (optional)       +
   +                                  +
   +----------------------------------+
   +----------------------------------+
   +      User Header (optional)      +
   +        --------------------------+
   +       |        Padding           +
   +----------------------------------+
   +----------------------------------+
   +                                  +
   +          Data Record 1           +
   +                                  +
   +----------------------------------+
                   ___
                   ___
                   ___
   +----------------------------------+
   +                                  +
   +          Data Record N           +
   +                                  +
   +----------------------------------+
=============================================
=============================================
             FILE Compressed
   +----------------------------------+
   +                                  +
   +      General File Header         +
   +                                  +
   +----------------------------------+
   +----------------------------------+
   +                                  +
   +     Index Array (optional)       +
   +                                  +
   +----------------------------------+
   +----------------------------------+
   +      User Header (optional)      +
   +        --------------------------+
   +       |         Padding          +
   +----------------------------------+
   +----------------------------------+
   +           Compressed             +
   +          Data Record 1           +
   +                                  +
   +----------------------------------+
                   ___
                   ___
                   ___
   +----------------------------------+
   +           Compressed             +
   +          Data Record N           +
   +                                  +
   +----------------------------------+
   The User Header contains a data record which
   holds the dictionary and first event, if any.
   The general file header, index array, and
   user header are never compressed.
   Writing a buffer is done without the general file header
   and the index array and user header which follow.
Date
01/21/2020
Author
timmer

Constructor & Destructor Documentation

evio::EventWriter::EventWriter ( std::string &  filename,
const ByteOrder byteOrder = ByteOrder::nativeOrder(),
bool  append = false 
)
explicit

Creates an EventWriter for writing to a file in the specified byte order.

If the file already exists, its contents will be overwritten unless it is being appended to. If it doesn't exist, it will be created.

Parameters
filenamename of the file to write to.
byteOrderthe byte order in which to write the file.
appendif true and the file already exists, all events to be written will be appended to the end of the file.
Exceptions
EvioExceptionfile cannot be created
evio::EventWriter::EventWriter ( std::string &  filename,
std::string &  dictionary,
const ByteOrder byteOrder = ByteOrder::nativeOrder(),
bool  append = false 
)

Creates an EventWriter for writing to a file in NATIVE byte order.

If the file already exists, its contents will be overwritten unless it is being appended to. If it doesn't exist, it will be created.

Parameters
filenamethe file object to write to.
dictionarydictionary in xml format or null if none.
byteOrderthe byte order in which to write the file.
appendif true and the file already exists, all events to be written will be appended to the end of the file.
Exceptions
EvioExceptionfile cannot be created
evio::EventWriter::EventWriter ( std::string  baseName,
const std::string &  directory,
const std::string &  runType,
uint32_t  runNumber,
uint64_t  split,
uint32_t  maxRecordSize,
uint32_t  maxEventCount,
const ByteOrder byteOrder,
const std::string &  xmlDictionary,
bool  overWriteOK,
bool  append,
std::shared_ptr< EvioBank firstEvent,
uint32_t  streamId,
uint32_t  splitNumber,
uint32_t  splitIncrement,
uint32_t  streamCount,
Compressor::CompressionType  compressionType,
uint32_t  compressionThreads,
uint32_t  ringSize,
uint32_t  bufferSize 
)

Create an EventWriter for writing events to a file.

If the file already exists, its contents will be overwritten unless the "overWriteOK" argument is false in which case an exception will be thrown. Unless ..., the option to append these events to an existing file is true, in which case everything is fine. If the file doesn't exist, it will be created. Byte order defaults to big endian if arg is null. File can be split while writing.

The base file name may contain up to 2, C-style integer format specifiers using "d" and "x" (such as %03d, or x). If more than 2 are found, an exception will be thrown. If no "0" precedes any integer between the "%" and the "d" or "x" of the format specifier, it will be added automatically in order to avoid spaces in the file name. The first specifier will be substituted with the given runNumber value. If the file is being split, the second will be substituted with the split number which starts at 0. If 2 specifiers exist and the file is not being split, no substitutions are made. If no specifier for the splitNumber exists, it is tacked onto the end of the file name after a dot (.). If streamCount > 1, the split number is calculated starting with streamId and incremented by streamCount each time. In this manner, all split files will have unique, sequential names even though there are multiple parallel ERs.

The base file name may contain characters of the form which will be substituted with the value of the associated environmental variable or a blank string if none is found.

The base file name may also contain occurrences of the string "%s" which will be substituted with the value of the runType arg or nothing if the runType is null.

If multiple streams of data, each writing a file, end up with the same file name, they can be difcompressionferentiated by a stream id, starting split # and split increment.

Parameters
baseNamebase file name used to generate complete file name (may not be null)
directorydirectory in which file is to be placed
runTypename of run type configuration to be used in naming files
runNumbernumber of the CODA run, used in naming files
splitif < 1, do not split file, write to only one file of unlimited size. Else this is max size in bytes to make a file before closing it and starting writing another.
maxRecordSizemax number of uncompressed data bytes each record can hold. Value of < 8MB results in default of 8MB. The size of the record will not be larger than this size unless a single event itself is larger.
maxEventCountmax number of events each record can hold. Value <= O means use default (1M).
byteOrderthe byte order in which to write the file. This is ignored if appending to existing file. Defaults to Big Endian if null.
xmlDictionarydictionary in xml format or null if none.
overWriteOKif false and the file already exists, an exception is thrown rather than overwriting it.
appendif true append written data to given file.
firstEventthe first event written into each file (after any dictionary) including all split files; may be null. Useful for adding common, static info into each split file.
streamIdstreamId number (100 > id > -1) for file name
splitNumbernumber at which to start the split numbers
splitIncrementamount to increment split number each time another file is created.
streamCounttotal number of streams in DAQ.
compressionTypetype of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).
compressionThreadsnumber of threads doing compression simultaneously.
ringSizenumber of records in supply ring. If set to < compressionThreads, it is forced to equal that value and is also forced to be a multiple of 2, rounded up.
bufferSizenumber of bytes to make each internal buffer which will be storing events before writing them to a file. 9MB = default if bufferSize = 0.
Exceptions
EvioExceptionif maxRecordSize or maxEventCount exceed limits; if streamCount > 1 and streamId < 0; if defined dictionary or first event while appending; if splitting file while appending; if file name arg is null; if file could not be opened, positioned, or written to; if file exists but user requested no over-writing or appending; if streamId < 0, splitNumber < 0, or splitIncrement < 1.

References evio::HeaderType::EVIO_RECORD, examineFileHeader(), evio::Util::generateBaseFileName(), evio::Util::generateFileName(), evio::Compressor::GZIP, evio::RecordHeader::HEADER_SIZE_BYTES, evio::Compressor::LZ4, evio::Compressor::LZ4_BEST, evio::Util::powerOfTwo(), and evio::Compressor::UNCOMPRESSED.

evio::EventWriter::EventWriter ( std::shared_ptr< ByteBuffer > &  buf)
explicit

Create an EventWriter for writing events to a ByteBuffer.

Uses the default number and size of records in buffer. Will overwrite any existing data in buffer!

Parameters
bufthe buffer to write to.
Exceptions
EvioExceptionif buf arg is null
evio::EventWriter::EventWriter ( std::shared_ptr< ByteBuffer > &  buf,
std::string &  xmlDictionary 
)

Create an EventWriter for writing events to a ByteBuffer.

Uses the default number and size of records in buffer.

Parameters
bufthe buffer to write to.
xmlDictionarydictionary in xml format or null if none.
Exceptions
EvioExceptionif buf arg is null
evio::EventWriter::EventWriter ( std::shared_ptr< ByteBuffer > &  buf,
uint32_t  maxRecordSize,
uint32_t  maxEventCount,
const std::string &  xmlDictionary,
uint32_t  recordNumber,
Compressor::CompressionType  compressionType 
)

Create an EventWriter for writing events to a ByteBuffer.

The buffer's position is set to 0 before writing.

Parameters
bufthe buffer to write to starting at position = 0.
maxRecordSizemax number of data bytes each record can hold. Value of < 8MB results in default of 8MB. The size of the record will not be larger than this size unless a single event itself is larger.
maxEventCountmax number of events each record can hold. Value <= O means use default (1M).
xmlDictionarydictionary in xml format or null if none.
recordNumbernumber at which to start record number counting.
compressionTypetype of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip)
Exceptions
EvioExceptionif maxRecordSize or maxEventCount exceed limits;

References evio::HeaderType::EVIO_RECORD, evio::Compressor::GZIP, evio::RecordHeader::HEADER_SIZE_BYTES, evio::Compressor::LZ4, evio::Compressor::LZ4_BEST, and evio::Compressor::UNCOMPRESSED.

Member Function Documentation

void evio::EventWriter::close ( )

This method flushes any remaining data to file and disables this object.

May not call this when simultaneously calling writeEvent, flush, setFirstEvent, or getByteBuffer.

References evio::ByteBuffer::array(), evio::ByteBuffer::order(), evio::ByteBuffer::putInt(), and evio::FileHeader::RECORD_COUNT_OFFSET.

Referenced by evio::EventBuilder::main().

void evio::EventWriter::examineFileHeader ( )
protected

Reads part of the file header in order to determine the evio version # and endianness of the file in question.

Exceptions
EvioExceptionnot in append mode, contains too little data, is not in proper format, version earlier than 6, premature EOF or file reading error, and all other exceptions.

References evio::FileHeader::getByteOrder(), evio::FileHeader::getIndexLength(), evio::FileHeader::getUserHeaderLength(), evio::FileHeader::getUserHeaderLengthPadding(), evio::FileHeader::hasDictionary(), evio::FileHeader::hasTrailerWithIndex(), evio::FileHeader::HEADER_SIZE_BYTES, evio::ByteBuffer::position(), and evio::FileHeader::readHeader().

Referenced by EventWriter().

void evio::EventWriter::flush ( )

This method flushes any remaining internally buffered data to file.

Calling close() automatically does this so it isn't necessary to call before closing. This method should only be used when writing events at such a low rate that it takes an inordinate amount of time for internally buffered data to be written to the file.

Calling this may easily kill performance. May not call this when simultaneously calling writeEvent, close, setFirstEvent, or getByteBuffer.

std::shared_ptr< ByteBuffer > evio::EventWriter::getByteBuffer ( )

If writing to a file, return null.

If writing to a buffer, get a duplicate of the user-given buffer being written into. The buffer's position will be 0 and its limit will be the size of the valid data. Basically, it's ready to be read from. The returned buffer shares data with the original buffer but has separate limit, position, and mark. Useful if trying to send buffer over the network. Do not call this while simultaneously calling close, flush, setFirstEvent, or writeEvent.

Returns
buffer being written into, made ready for reading; null if writing to file
ByteOrder evio::EventWriter::getByteOrder ( ) const

Get the byte order of the buffer/file being written into.

Returns
byte order of the buffer/file being written into.
size_t evio::EventWriter::getBytesWrittenToBuffer ( ) const

If writing to a buffer, get the number of bytes written to it including the trailer.

Returns
number of bytes written to buffer
std::string evio::EventWriter::getCurrentFilename ( ) const

Get the name of the current file being written to.

Returns empty string if no file.

Returns
the name of the current file being written to.
std::string evio::EventWriter::getCurrentFilePath ( ) const

Get the full name or path of the current file being written to.

Returns empty string if no file.

Returns
the full name or path of the current file being written to.
uint32_t evio::EventWriter::getEventsWritten ( ) const

Get the number of events written to a file/buffer.

Remember that a particular event may not yet be flushed to the file/buffer. If the file being written to is split, the returned value refers to all split files taken together.

Returns
number of events written to a file/buffer.
uint32_t evio::EventWriter::getRecordNumber ( ) const

Get the current record number.

Warning, this value may be changing.

Returns
the current record number.
uint32_t evio::EventWriter::getSplitCount ( ) const

Get the number of split files produced by this writer.

Returns
number of split files produced by this writer.
uint32_t evio::EventWriter::getSplitNumber ( ) const

Get the current split number which is the split number of file to be written next.

Warning, this value may be changing.

Returns
the current split number which is the split number of file to be written next.
bool evio::EventWriter::hasRoom ( uint32_t  bytes)

Is there room to write this many bytes to an output buffer as a single event? Will always return true when writing to a file.

Parameters
bytesnumber of bytes to write
Returns
true
if there still room in the output buffer, else
false
.

References writingToFile().

bool evio::EventWriter::isClosed ( ) const

Has close() been called (without reopening by calling setBuffer()) ?

Returns
true
if this object closed, else
false
.
bool evio::EventWriter::isDiskFull ( )

If writing file, is the partition it resides on full? Not full, in this context, means there's enough space to write a full split file + a full record + an extra 10MB as a safety factor.

Returns
true if the partition the file resides on is full, else false.
void evio::EventWriter::setBuffer ( std::shared_ptr< ByteBuffer > &  buf,
std::bitset< 24 > *  bitInfo,
uint32_t  recNumber 
)

Set the buffer being written into (initially set in constructor).

This method allows the user to avoid having to create a new EventWriter each time a bank needs to be written to a different buffer. This does nothing if writing to a file.

Do not use this method unless you know what you are doing.

Parameters
bufthe buffer to write to.
bitInfoset of bits to include in first record header.
recNumbernumber at which to start record number counting.
Exceptions
EvioExceptionif this object was not closed prior to resetting the buffer, buffer arg is null, or writing to file.
void evio::EventWriter::setBuffer ( std::shared_ptr< ByteBuffer > &  buf)

Set the buffer being written into (initially set in constructor).

This method allows the user to avoid having to create a new EventWriter each time a bank needs to be written to a different buffer. This does nothing if writing to a file.

Do not use this method unless you know what you are doing.

Parameters
bufthe buffer to write to.
Exceptions
EvioExceptionif this object was not closed prior to resetting the buffer, buffer arg is null, or writing to file.
void evio::EventWriter::setEventType ( int  type)

Set the bit info of a record header for a specified CODA event type.

Must be called AFTER RecordHeader#setBitInfo(bool, bool) or RecordHeader#setBitInfoWord(uint32_t) in order to have change preserved. This should only be used internally by CODA in emu software.

Parameters
typeevent type (0=ROC raw, 1=Physics, 2=Partial Physics, 3=Disentangled, 4=User, 5=Control, 15=Other, else = nothing set).
void evio::EventWriter::setFirstEvent ( std::shared_ptr< EvioNode > &  node)

Set an event which will be written to the file as well as to all split files.

It's called the "first event" as it will be the first event written to each split file if this method is called early enough or the first event was defined in the constructor. In evio version 6, any dictionary and the first event are written to a common record which is stored in the user-header part of the file header if writing to a file. When writing to a buffer it's stored in the first record's user-header. The common record data is never compressed.

FILE: Since this method can only be called after the constructor, the common record may have already been written with its dictionary and possibly another firstEvent. If that is the case, the event given here will be written immediately somewhere in the body of the file. Any subsequent splits will have this event as the first event in the file header. On the other hand, if the common record has not yet been written to the file, this event becomes the first event in the file header.

BUFFER: By its nature this method is not all that useful for writing to a buffer since the buffer is never split. For that reason it throws an exception.

Do not call this while simultaneously calling close, flush, writeEvent, or getByteBuffer.

Parameters
nodenode representing event to be placed first in each file written including all splits.
Exceptions
EvioExceptionif error writing to file if first event is opposite byte order of internal buffer; if bad data format; if close() already called; if writing to buffer; if file could not be opened for writing; if file exists but user requested no over-writing; if no room when writing to user-given buffer;

References writeEvent().

void evio::EventWriter::setFirstEvent ( std::shared_ptr< ByteBuffer > &  buf)

Set an event which will be written to the file as well as to all split files.

It's called the "first event" as it will be the first event written to each split file if this method is called early enough or the first event was defined in the constructor. In evio version 6, any dictionary and the first event are written to a common record which is stored in the user-header part of the file header if writing to a file. When writing to a buffer it's stored in the first record's user-header. The common record data is never compressed.

FILE: Since this method can only be called after the constructor, the common record may have already been written with its dictionary and possibly another firstEvent. If that is the case, the event given here will be written immediately somewhere in the body of the file. Any subsequent splits will have this event as the first event in the file header. On the other hand, if the common record has not yet been written to the file, this event becomes the first event in the file header.

BUFFER: By its nature this method is not all that useful for writing to a buffer since the buffer is never split. For that reason it throws an exception.

Do not call this while simultaneously calling close, flush, writeEvent, or getByteBuffer.

Parameters
bufbuffer containing event to be placed first in each file written including all splits.
Exceptions
EvioExceptionif error writing to file if first event is opposite byte order of internal buffer; if bad data format; if close() already called; if writing to buffer; if file could not be opened for writing; if file exists but user requested no over-writing; if no room when writing to user-given buffer;

References writeEvent().

void evio::EventWriter::setFirstEvent ( std::shared_ptr< EvioBank bank)

Set an event which will be written to the file as well as to all split files.

It's called the "first event" as it will be the first event written to each split file if this method is called early enough or the first event was defined in the constructor. In evio version 6, any dictionary and the first event are written to a common record which is stored in the user-header part of the file header if writing to a file. When writing to a buffer it's stored in the first record's user-header. The common record data is never compressed.

FILE: Since this method can only be called after the constructor, the common record may have already been written with its dictionary and possibly another firstEvent. If that is the case, the event given here will be written immediately somewhere in the body of the file. Any subsequent splits will have this event as the first event in the file header. On the other hand, if the common record has not yet been written to the file, this event becomes the first event in the file header.

BUFFER: By its nature this method is not all that useful for writing to a buffer since the buffer is never split. For that reason it throws an exception.

Do not call this while simultaneously calling close, flush, writeEvent, or getByteBuffer.

Parameters
bankevent to be placed first in each file written including all splits.
Exceptions
EvioExceptionif error writing to file if first event is opposite byte order of internal buffer; if bad data format; if close() already called; if writing to buffer; if file could not be opened for writing; if file exists but user requested no over-writing; if no room when writing to user-given buffer;

References writeEvent().

void evio::EventWriter::setSourceId ( int  sId)

Set the value of the source Id in the first block header.

Only necessary to do this when using EventWriter in EMU's RocSimulation module. Only the ROC sends sourceId in header. In evio 6, the source id is stored in user register 1. In earlier versions it's stored in reserved1. This should only be used internally by CODA in emu software.

Parameters
sIdvalue of the source Id.
void evio::EventWriter::setStartingRecordNumber ( uint32_t  startingRecordNumber)

Set the number with which to start block (record) numbers.

This method does nothing if events have already been written.

Parameters
startingRecordNumberthe number with which to start block (record) numbers. Set the number with which to start record numbers. This method does nothing if events have already been written.
startingRecordNumberthe number with which to start record numbers.
bool evio::EventWriter::writeEvent ( std::shared_ptr< EvioNode > &  node,
bool  force 
)

Write an event (bank) into a record in evio/hipo version 6 format.

Once the record is full and if writing to a file (for multiple compression threads), the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If writing to a buffer, once the record is full this method returns false - indicating that the last event was NOT written to the record. To finish the writing process, call close(). This will compress the data if desired and then write it to the buffer.

The buffer must contain only the event's data (event header and event data) and must not be in complete evio file format. Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

Be warned that injudicious use of a true 2nd arg, the force flag, will kill performance when writing to a file.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Parameters
nodeobject representing the event to write in buffer form
forceif writing to disk, force it to write event to the disk.
Returns
if writing to buffer: true if event was added to record, false if buffer full, or record event count limit exceeded.
Exceptions
EvioExceptionif error writing file if event is opposite byte order of internal buffer; if close() already called; if bad eventBuffer format; if file could not be opened for writing; if file exists but user requested no over-writing; if null node arg;

Referenced by evio::EventBuilder::main(), setFirstEvent(), and writeEvent().

bool evio::EventWriter::writeEvent ( std::shared_ptr< EvioNode > &  node,
bool  force,
bool  duplicate 
)

Write an event (bank) into a record in evio/hipo version 6 format.

Once the record is full and if writing to a file (for multiple compression threads), the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If writing to a buffer, once the record is full this method returns false - indicating that the last event was NOT written to the record. To finish the writing process, call close(). This will compress the data if desired and then write it to the buffer.

The buffer must contain only the event's data (event header and event data) and must not be in complete evio file format. Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

Be warned that injudicious use of a true 2nd arg, the force flag, will kill performance when writing to a file. A true 3rd arg can be used when the backing buffer of the node is accessed by multiple threads simultaneously. This allows that buffer's limit and position to be changed without interfering with the other threads.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Parameters
nodeobject representing the event to write in buffer form
forceif writing to disk, force it to write event to the disk.
duplicateif true, duplicate node's buffer so its position and limit can be changed without issue.
Returns
if writing to buffer: true if event was added to record, false if buffer full, or record event count limit exceeded.
Exceptions
EvioExceptionif error writing file if event is opposite byte order of internal buffer; if close() already called; if bad eventBuffer format; if file could not be opened for writing; if file exists but user requested no over-writing;

References writeEvent().

bool evio::EventWriter::writeEvent ( std::shared_ptr< ByteBuffer > &  bankBuffer)

Write an event (bank) into a record in evio/hipo version 6 format.

Once the record is full and if writing to a file (for multiple compression threads), the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If writing to a buffer, once the record is full this method returns false - indicating that the last event was NOT written to the record. To finish the writing process, call close(). This will compress the data if desired and then write it to the buffer.

The buffer must contain only the event's data (event header and event data) and must not be in complete evio file format. Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Parameters
bankBufferthe bank (as a ByteBuffer object) to write.
Returns
if writing to buffer: true if event was added to record, false if buffer full, or record event count limit exceeded.
Exceptions
EvioExceptionif error writing file if event is opposite byte order of internal buffer; if close() already called; if bad eventBuffer format; if file could not be opened for writing; if file exists but user requested no over-writing.

References writeEvent().

bool evio::EventWriter::writeEvent ( std::shared_ptr< ByteBuffer > &  bankBuffer,
bool  force 
)

Write an event (bank) into a record in evio/hipo version 6 format.

Once the record is full and if writing to a file (for multiple compression threads), the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If writing to a buffer, once the record is full this method returns false - indicating that the last event was NOT written to the record. To finish the writing process, call close(). This will compress the data if desired and then write it to the buffer.

The buffer must contain only the event's data (event header and event data) and must not be in complete evio file format. Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

Be warned that injudicious use of a true 2nd arg, the force flag, will kill performance when writing to a file.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Parameters
bankBufferthe bank (as a ByteBuffer object) to write.
forceif writing to disk, force it to write event to the disk.
Returns
if writing to buffer: true if event was added to record, false if buffer full, or record event count limit exceeded.
Exceptions
EvioExceptionif error writing file if event is opposite byte order of internal buffer; if close() already called; if bad eventBuffer format; if file could not be opened for writing; if file exists but user requested no over-writing.

References writeEvent().

bool evio::EventWriter::writeEvent ( std::shared_ptr< EvioBank bank)

Write an event (bank) into a record in evio/hipo version 6 format.

Once the record is full and if writing to a file (for multiple compression threads), the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If writing to a buffer, once the record is full this method returns false - indicating that the last event was NOT written to the record. To finish the writing process, call close(). This will compress the data if desired and then write it to the buffer.

Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Parameters
bankthe bank to write.
Returns
if writing to buffer: true if event was added to record, false if buffer full, or record event count limit exceeded.
Exceptions
EvioExceptionif error writing file if close() already called; if file could not be opened for writing; if file exists but user requested no over-writing;.

References writeEvent().

bool evio::EventWriter::writeEvent ( std::shared_ptr< EvioBank bank,
bool  force 
)

Write an event (bank) into a record in evio/hipo version 6 format.

Once the record is full and if writing to a file (for multiple compression threads), the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If writing to a buffer, once the record is full this method returns false - indicating that the last event was NOT written to the record. To finish the writing process, call close(). This will compress the data if desired and then write it to the buffer.

Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Be warned that injudicious use of the 2nd arg, the force flag, will kill performance when writing to a file.

Parameters
bankthe bank to write.
forceif writing to disk, force it to write event to the disk.
Returns
if writing to buffer: true if event was added to record, false if buffer full, or record event count limit exceeded.
Exceptions
EvioExceptionif error writing file if close() already called; if file could not be opened for writing; if file exists but user requested no over-writing;.

References writeEvent().

bool evio::EventWriter::writeEventToFile ( std::shared_ptr< EvioNode > &  node,
bool  force,
bool  duplicate 
)

Write an event (bank) into a record and eventually to a file in evio/hipo version 6 format.

Once the record is full and if writing with multiple compression threads, the record will be sent to a thread which may compress the data, then it will be sent to a thread to write the record to file. If there is only 1 compression thread, it's all done in the thread which call this method.

If splitting files, this method returns false if disk partition is too full to write the complete, next split file. If force arg is true, write anyway. DO NOT mix calling this method with calling writeEvent() (all variants). Results are unpredictable as it messes up the logic used to quit writing to full disk.

The buffer must contain only the event's data (event header and event data) and must not be in complete evio file format. Do not call this while simultaneously calling close, flush, setFirstEvent, or getByteBuffer.

Be warned that injudicious use of a true 2nd arg, the force flag, will kill performance when writing to a file. A true 3rd arg can be used when the backing buffer of the node is accessed by multiple threads simultaneously. This allows that buffer's limit and position to be changed without interfering with the other threads.

This method is not used to write the dictionary or the first event which are both placed in the common record which, in turn, is the user header part of the file header.

Parameters
nodeobject representing the event to write in buffer form
forceif writing to disk, force it to write event to the disk.
duplicateif true, duplicate node's buffer so its position and limit can be changed without issue.
Returns
true if event was added to record. If splitting files, false if disk partition too full to write the complete, next split file. False if interrupted. If force arg is true, write anyway.
Exceptions
EvioExceptionif error writing file if event is opposite byte order of internal buffer; if close() already called; if bad eventBuffer format; if file could not be opened for writing; if file exists but user requested no over-writing;
bool evio::EventWriter::writingToFile ( ) const

Is this object writing to file?

Returns
true
if writing to file, else
false
.

Referenced by hasRoom().


The documentation for this class was generated from the following files: