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

Class which handles the creation and use of Evio & HIPO Records. More...

#include <RecordOutput.h>

Public Member Functions

 RecordOutput ()
 Default, no-arg constructor. More...
 
 RecordOutput (const ByteOrder &order, uint32_t maxEventCount=1000000, uint32_t maxBufferSize=8 *ONE_MEG, Compressor::CompressionType compressionType=Compressor::UNCOMPRESSED, HeaderType hType=HeaderType::EVIO_RECORD)
 Constructor with arguments. More...
 
 RecordOutput (std::shared_ptr< ByteBuffer > &buffer, uint32_t maxEventCount, Compressor::CompressionType compressionType, HeaderType hType)
 Constructor with arguments. More...
 
 RecordOutput (const RecordOutput &srcRec)
 Copy constructor. More...
 
 RecordOutput (RecordOutput &&srcBuf) noexcept
 Move constructor. More...
 
RecordOutputoperator= (RecordOutput &&other) noexcept
 Move assignment operator. More...
 
RecordOutputoperator= (const RecordOutput &other)
 Assignment operator. More...
 
 ~RecordOutput ()=default
 
void setBuffer (std::shared_ptr< ByteBuffer > &buf)
 Reset internal buffers and set the buffer in which to build this record. More...
 
void transferDataForReading (const RecordOutput &rec)
 Copy the contents of the arg into this object and get data buffer ready for reading. More...
 
uint32_t getUserBufferSize () const
 Get the number of initially available bytes to be written into in the user-given buffer, that goes from position to limit. More...
 
uint32_t getUncompressedSize () const
 Get the current uncompressed size of the record in bytes. More...
 
uint32_t getInternalBufferCapacity () const
 Get the capacity of the internal buffer in bytes. More...
 
uint32_t getMaxEventCount () const
 Get the maximum number of events allowed in this record. More...
 
uint32_t getEventCount () const
 Get the number of events written so far into the buffer. More...
 
std::shared_ptr< RecordHeader > & getHeader ()
 Get the general header of this record. More...
 
const ByteOrdergetByteOrder () const
 Get the byte order of the record to be built. More...
 
const std::shared_ptr< ByteBuffergetBinaryBuffer () const
 Get the internal ByteBuffer used to construct binary representation of this record. More...
 
const Compressor::CompressionType getCompressionType () const
 Get the compression type of the contained record. More...
 
const HeaderType getHeaderType () const
 Get the header type of the contained record. More...
 
bool hasUserProvidedBuffer () const
 Was the internal buffer provided by the user? More...
 
bool roomForEvent (uint32_t length) const
 Is there room in this record's memory for an additional event of the given length in bytes (length NOT including accompanying index). More...
 
bool oneTooMany () const
 Does adding one more event exceed the event count limit? More...
 
bool addEvent (const uint8_t *event, uint32_t eventLen, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (const std::vector< uint8_t > &event)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (const std::vector< uint8_t > &event, size_t offset, uint32_t eventLen, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (const ByteBuffer &event, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (const std::shared_ptr< ByteBuffer > &event, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (EvioNode &node, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (std::shared_ptr< EvioNode > &node, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (EvioBank &event, uint32_t extraDataLen)
 Adds an event's ByteBuffer into the record. More...
 
bool addEvent (std::shared_ptr< EvioBank > &event, uint32_t extraDataLen=0)
 Adds an event's ByteBuffer into the record. More...
 
void reset ()
 Reset internal buffers. More...
 
void setStartingBufferPosition (size_t pos)
 Set the starting position of the user-given buffer being written into. More...
 
void build ()
 Builds the record. More...
 
void build (std::shared_ptr< ByteBuffer > userHeader)
 Builds the record. More...
 
void build (const ByteBuffer &userHeader)
 Builds the record. More...
 

Public Attributes

uint32_t MAX_EVENT_COUNT = 1000000
 Maximum number of events per record. More...
 
uint32_t MAX_BUFFER_SIZE = 8*ONE_MEG
 Size of some internal buffers in bytes. More...
 
uint32_t RECORD_BUFFER_SIZE = 9*ONE_MEG
 Size of buffer holding built record in bytes. More...
 
uint32_t userBufferSize = 0
 The number of initially available bytes to be written into in the user-given buffer, that go from position to limit. More...
 
uint32_t eventCount = 0
 Number of events written to this Record. More...
 
uint32_t indexSize = 0
 Number of valid bytes in recordIndex buffer. More...
 
uint32_t eventSize = 0
 Number of valid bytes in recordEvents buffer. More...
 
size_t startingPosition = 0
 The starting position of a user-given buffer. More...
 
std::shared_ptr< ByteBufferrecordIndex
 This buffer stores event lengths (in bytes) ONLY. More...
 
std::shared_ptr< ByteBufferrecordEvents
 This buffer stores event data ONLY. More...
 
std::shared_ptr< ByteBufferrecordData
 This buffer stores data that will be compressed. More...
 
std::shared_ptr< ByteBufferrecordBinary
 Buffer in which to put constructed (& compressed) binary record. More...
 
std::shared_ptr< RecordHeaderheader
 Header of this Record. More...
 
ByteOrder byteOrder {ByteOrder::ENDIAN_LOCAL}
 Byte order of record byte arrays to build. More...
 
bool userProvidedBuffer = false
 Is recordBinary a user provided buffer? More...
 

Static Public Attributes

static constexpr int ONE_MEG = 1024*1024
 Maximum number of events per record. More...
 

Detailed Description

Class which handles the creation and use of Evio & HIPO Records.


RECORD STRUCTURE:
              Uncompressed                                      Compressed
   +----------------------------------+            +----------------------------------+
   |       General Record Header      |            |       General Record Header      |
   +----------------------------------+            +----------------------------------+
   +----------------------------------+ ---------> +----------------------------------+
   |      Index Array (bytes)         |            |        Compressed Data           |
   +----------------------------------+            |             Record               |
                                                   |                                  |
   +----------------------------------+            |                                  |
   |           User Header            |            |                  ----------------|
   |           (Optional)             |            |                  |    Pad 3      |
   |                  ----------------|            +----------------------------------+
   |                  |    Pad 1      |           ^
   +----------------------------------+          /
                                                /
   +----------------------------------+        /
   |           Data Record            |       /
   |                                  |      /
   |                  ----------------|     /
   |                  |    Pad 2      |    /
   +----------------------------------+----
GENERAL RECORD HEADER STRUCTURE ( see RecordHeader.java )
   +----------------------------------+
 1 |         Record Length            | // 32bit words, inclusive
   +----------------------------------+
 2 +         Record Number            |
   +----------------------------------+
 3 +         Header Length            | // 14 (words)
   +----------------------------------+
 4 +       Event (Index) Count        |
   +----------------------------------+
 5 +      Index Array Length          | // bytes
   +-----------------------+---------+
 6 +       Bit Info        | Version  | // version (8 bits)
   +-----------------------+----------+
 7 +      User Header Length          | // bytes
   +----------------------------------+
 8 +          Magic Number            | // 0xc0da0100
   +----------------------------------+
 9 +     Uncompressed Data Length     | // bytes
   +------+---------------------------+
10 +  CT  |  Data Length Compressed   | // CT = compression type (4 bits)
   +----------------------------------+
11 +        General Register 1        | // UID 1st (64 bits)
   +--                              --+
12 +                                  |
   +----------------------------------+
13 +        General Register 2        | // UID 2nd (64 bits)
   +--                              --+
14 +                                  |
   +----------------------------------+
Version
6.0
Since
6.0 4/9/2019
Author
timmer

Constructor & Destructor Documentation

evio::RecordOutput::RecordOutput ( )

Default, no-arg constructor.

Little endian. No compression.

evio::RecordOutput::RecordOutput ( const ByteOrder order,
uint32_t  maxEventCount = 1000000,
uint32_t  maxBufferSize = 8*ONE_MEG,
Compressor::CompressionType  compressionType = Compressor::UNCOMPRESSED,
HeaderType  hType = HeaderType::EVIO_RECORD 
)
explicit

Constructor with arguments.

Parameters
orderbyte order of built record byte arrays.
maxEventCountmax number of events this record can hold. Value <= O means use default (1M).
maxBufferSizemax number of uncompressed data bytes this record can hold. Value of < 8MB results in default of 8MB.
compressionTypetype of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).
hTypetype of record header to use.

References byteOrder, evio::HeaderType::EVIO_RECORD, evio::HeaderType::EVIO_TRAILER, header, evio::HeaderType::HIPO_RECORD, evio::HeaderType::HIPO_TRAILER, evio::HeaderType::isEvioFileHeader(), evio::HeaderType::isHipoFileHeader(), MAX_BUFFER_SIZE, MAX_EVENT_COUNT, RECORD_BUFFER_SIZE, and recordIndex.

evio::RecordOutput::RecordOutput ( std::shared_ptr< ByteBuffer > &  buffer,
uint32_t  maxEventCount,
Compressor::CompressionType  compressionType,
HeaderType  hType 
)

Constructor with arguments.

Parameters
bufferbuffer in which to put constructed (& compressed) binary record. Must have position and limit set to accept new data.
maxEventCountmax number of events this record can hold. Value <= O means use default (1M).
compressionTypetype of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).
hTypetype of record header to use.

References byteOrder, evio::HeaderType::EVIO_RECORD, evio::HeaderType::EVIO_TRAILER, header, evio::HeaderType::HIPO_RECORD, evio::HeaderType::HIPO_TRAILER, evio::HeaderType::isEvioFileHeader(), evio::HeaderType::isHipoFileHeader(), MAX_BUFFER_SIZE, MAX_EVENT_COUNT, RECORD_BUFFER_SIZE, recordBinary, recordIndex, startingPosition, userBufferSize, and userProvidedBuffer.

evio::RecordOutput::RecordOutput ( const RecordOutput rec)

Copy constructor.

Parameters
recRecordOutput to copy.
Exceptions
EvioExceptionif trying to copy bigger record and internal buffer was provided by user.

References recordBinary, recordEvents, and recordIndex.

evio::RecordOutput::RecordOutput ( RecordOutput &&  rec)
noexcept

Move constructor.

Parameters
recRecordOutput object to move.
evio::RecordOutput::~RecordOutput ( )
default

Member Function Documentation

bool evio::RecordOutput::addEvent ( const uint8_t *  event,
uint32_t  eventLen,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's byte array.
eventLennumber of bytes from byte array to add.
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References eventCount, eventSize, indexSize, MAX_BUFFER_SIZE, ONE_MEG, oneTooMany(), RECORD_BUFFER_SIZE, recordEvents, recordIndex, reset(), roomForEvent(), and userProvidedBuffer.

Referenced by addEvent(), and evio::Writer::createRecord().

bool evio::RecordOutput::addEvent ( const std::vector< uint8_t > &  event)

Adds an event's ByteBuffer into the record.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's data in vector.
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References addEvent().

bool evio::RecordOutput::addEvent ( const std::vector< uint8_t > &  event,
size_t  offset,
uint32_t  eventLen,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's data in vector.
offsetoffset into vector's elements from which to begin reading.
eventLennumber of bytes from vector to add.
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References addEvent().

bool evio::RecordOutput::addEvent ( const ByteBuffer event,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's ByteBuffer object.
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References evio::ByteBuffer::array(), eventCount, eventSize, indexSize, MAX_BUFFER_SIZE, ONE_MEG, oneTooMany(), RECORD_BUFFER_SIZE, recordEvents, recordIndex, reset(), roomForEvent(), and userProvidedBuffer.

bool evio::RecordOutput::addEvent ( const std::shared_ptr< ByteBuffer > &  event,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's ByteBuffer object.
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References addEvent().

bool evio::RecordOutput::addEvent ( EvioNode node,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor! This method is not thread-safe with respect to the node as it's backing ByteBuffer's limit and position may be concurrently changed.

Parameters
nodeevent's EvioNode object
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.
Exceptions
EvioExceptionif node does not correspond to a bank.

References evio::ByteBuffer::array(), evio::ByteBuffer::arrayOffset(), eventCount, eventSize, evio::EvioNode::getStructureBuffer(), evio::EvioNode::getTotalBytes(), evio::EvioNode::getTypeObj(), indexSize, evio::DataType::isBank(), MAX_BUFFER_SIZE, ONE_MEG, oneTooMany(), evio::ByteBuffer::position(), RECORD_BUFFER_SIZE, recordEvents, recordIndex, reset(), roomForEvent(), evio::DataType::toString(), and userProvidedBuffer.

bool evio::RecordOutput::addEvent ( std::shared_ptr< EvioNode > &  node,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor! This method is not thread-safe with respect to the node as it's backing ByteBuffer's limit and position may be concurrently changed.

Parameters
nodeevent's EvioNode object
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.
Exceptions
EvioExceptionif node does not correspond to a bank.

References addEvent().

bool evio::RecordOutput::addEvent ( EvioBank event,
uint32_t  extraDataLen 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's EvioBank object.
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References eventCount, eventSize, indexSize, MAX_BUFFER_SIZE, ONE_MEG, oneTooMany(), RECORD_BUFFER_SIZE, recordEvents, recordIndex, reset(), roomForEvent(), and userProvidedBuffer.

bool evio::RecordOutput::addEvent ( std::shared_ptr< EvioBank > &  event,
uint32_t  extraDataLen = 0 
)

Adds an event's ByteBuffer into the record.

Can specify the length of additional data to follow the event (such as an evio trailer record) to see if by adding this event everything will fit in the available memory.

If a single event is too large for the internal buffers, more memory is allocated. On the other hand, if the buffer was provided by the user, then obviously the buffer cannot be expanded and false is returned.

The byte order of event must match the byte order given in constructor!

Parameters
eventevent's EvioBank object.
extraDataLenadditional data bytes to follow event (e.g. trailer length).
Returns
true if event was added; false if the event was not added because the count limit would be exceeded or the buffer is full and cannot be expanded since it's user-provided.

References addEvent().

void evio::RecordOutput::build ( )

Builds the record.

Compresses data, header is constructed, then header & data written into internal buffer. This method may be called multiple times in succession without any problem.

References evio::Compressor::compressLZ4(), evio::Compressor::compressLZ4Best(), eventCount, eventSize, evio::Compressor::getInstance(), header, evio::RecordHeader::HEADER_SIZE_BYTES, indexSize, recordBinary, recordData, recordEvents, recordIndex, startingPosition, and evio::Compressor::UNCOMPRESSED.

Referenced by build(), evio::Writer::createRecord(), and evio::Writer::writeRecord().

void evio::RecordOutput::build ( std::shared_ptr< ByteBuffer userHeader)

Builds the record.

Compresses data, header is constructed, then header & data written into internal buffer. If user header is not padded to 4-byte boundary, it's done here. This method may be called multiple times in succession without any problem.

Parameters
userHeaderuser's ByteBuffer which must be READY-TO-READ!

References build().

void evio::RecordOutput::build ( const ByteBuffer userHeader)

Builds the record.

Compresses data, header is constructed, then header & data written into internal buffer. If user header is not padded to 4-byte boundary, it's done here. This method may be called multiple times in succession without any problem.

Parameters
userHeaderuser's ByteBuffer which must be READY-TO-READ!

References evio::ByteBuffer::array(), build(), evio::Compressor::compressLZ4(), evio::Compressor::compressLZ4Best(), eventCount, eventSize, evio::Compressor::getInstance(), header, evio::RecordHeader::HEADER_SIZE_BYTES, indexSize, evio::ByteBuffer::position(), recordBinary, recordData, recordEvents, recordIndex, evio::ByteBuffer::remaining(), startingPosition, and evio::Compressor::UNCOMPRESSED.

const std::shared_ptr< ByteBuffer > evio::RecordOutput::getBinaryBuffer ( ) const

Get the internal ByteBuffer used to construct binary representation of this record.

Returns
internal ByteBuffer used to construct binary representation of this record.

References recordBinary.

Referenced by evio::Writer::createRecord(), and evio::Writer::writeRecord().

const ByteOrder & evio::RecordOutput::getByteOrder ( ) const

Get the byte order of the record to be built.

Returns
byte order of the record to be built.

References byteOrder.

Referenced by evio::Writer::writeRecord(), and evio::WriterMT::writeRecord().

const Compressor::CompressionType evio::RecordOutput::getCompressionType ( ) const

Get the compression type of the contained record.

Implemented to allow "const" in RecordRingItem equal operator and copy constructor.

Returns
compression type of the contained record.

References header.

uint32_t evio::RecordOutput::getEventCount ( ) const

Get the number of events written so far into the buffer.

Returns
number of events written so far into the buffer

References eventCount.

std::shared_ptr< RecordHeader > & evio::RecordOutput::getHeader ( )

Get the general header of this record.

Returns
general header of this record.

References header.

Referenced by evio::Writer::writeRecord().

const HeaderType evio::RecordOutput::getHeaderType ( ) const

Get the header type of the contained record.

Implemented to allow "const" in RecordRingItem equal operator and copy constructor.

Returns
compression type of the contained record.

References header.

uint32_t evio::RecordOutput::getInternalBufferCapacity ( ) const

Get the capacity of the internal buffer in bytes.

This is the upper limit of the memory needed to store this uncompressed record.

Returns
capacity of the internal buffer in bytes.

References MAX_BUFFER_SIZE.

Referenced by evio::Writer::createRecord().

uint32_t evio::RecordOutput::getMaxEventCount ( ) const

Get the maximum number of events allowed in this record.

Returns
maximum number of events allowed in this record.

References MAX_EVENT_COUNT.

uint32_t evio::RecordOutput::getUncompressedSize ( ) const

Get the current uncompressed size of the record in bytes.

This does NOT count any user header.

Returns
current uncompressed size of the record in bytes.

References eventSize, evio::RecordHeader::HEADER_SIZE_BYTES, and indexSize.

uint32_t evio::RecordOutput::getUserBufferSize ( ) const

Get the number of initially available bytes to be written into in the user-given buffer, that goes from position to limit.

The user-given buffer is referenced by recordBinary.

Returns
umber of initially available bytes to be written into in the user-given buffer.

References userBufferSize.

bool evio::RecordOutput::hasUserProvidedBuffer ( ) const

Was the internal buffer provided by the user?

Returns
true if internal buffer provided by user.

References userProvidedBuffer.

bool evio::RecordOutput::oneTooMany ( ) const

Does adding one more event exceed the event count limit?

Returns
true
if one more event exceeds count limit, else
false
.

References eventCount, and MAX_EVENT_COUNT.

Referenced by addEvent().

RecordOutput & evio::RecordOutput::operator= ( RecordOutput &&  other)
noexcept

Move assignment operator.

Parameters
otherright side object.
Returns
left side object.

References byteOrder, eventCount, eventSize, header, indexSize, MAX_BUFFER_SIZE, MAX_EVENT_COUNT, RECORD_BUFFER_SIZE, recordBinary, recordData, recordEvents, recordIndex, startingPosition, userBufferSize, and userProvidedBuffer.

RecordOutput & evio::RecordOutput::operator= ( const RecordOutput other)

Assignment operator.

Parameters
otherright side object.
Returns
left side object.
Exceptions
EvioExceptionif trying to copy bigger record and internal buffer was provided by user.

References recordBinary, recordEvents, and recordIndex.

void evio::RecordOutput::reset ( )

Reset internal buffers.

The buffer is ready to receive new data. Also resets the header including removing any compression. If data buffer externally provided, the starting position is set to 0.

References eventCount, eventSize, header, indexSize, recordBinary, recordData, recordEvents, recordIndex, and startingPosition.

Referenced by addEvent(), and setBuffer().

bool evio::RecordOutput::roomForEvent ( uint32_t  length) const

Is there room in this record's memory for an additional event of the given length in bytes (length NOT including accompanying index).

Parameters
lengthlength of data to add in bytes
Returns
true
if room in record, else
false
.

References eventSize, evio::RecordHeader::HEADER_SIZE_BYTES, indexSize, and MAX_BUFFER_SIZE.

Referenced by addEvent().

void evio::RecordOutput::setBuffer ( std::shared_ptr< ByteBuffer > &  buf)

Reset internal buffers and set the buffer in which to build this record.

The given buffer should be made ready to receive new data by setting its position and limit properly. Its byte order is set to the same as this writer's. The argument ByteBuffer can be retrieved by calling getBinaryBuffer().

Parameters
bufbuffer in which to build this record.

References byteOrder, MAX_BUFFER_SIZE, RECORD_BUFFER_SIZE, recordBinary, reset(), startingPosition, userBufferSize, and userProvidedBuffer.

void evio::RecordOutput::setStartingBufferPosition ( size_t  pos)

Set the starting position of the user-given buffer being written into.

Calling this may be necessary from EventWriter(Unsync) when a common record (dictionary + first event) is written after the constructor for this object has been called, but before any events have been written. This method should not be called in general as it will MESS UP THE WRITING OF DATA!

Parameters
posposition in buffer to start writing.

References recordBinary, and startingPosition.

void evio::RecordOutput::transferDataForReading ( const RecordOutput rec)

Copy the contents of the arg into this object and get data buffer ready for reading.

If the arg has more data than will fit, increase buffer sizes. If the arg has more events than our allowed max, increase the max.

Parameters
recobject to copy, must be ready to read
Exceptions
EvioExceptionif we cannot replace internal buffer if it needs to be expanded since it was provided by the user.

References eventSize, indexSize, recordBinary, recordEvents, and recordIndex.

Member Data Documentation

ByteOrder evio::RecordOutput::byteOrder {ByteOrder::ENDIAN_LOCAL}

Byte order of record byte arrays to build.

Referenced by getByteOrder(), operator=(), RecordOutput(), and setBuffer().

uint32_t evio::RecordOutput::eventCount = 0

Number of events written to this Record.

Referenced by addEvent(), build(), getEventCount(), oneTooMany(), operator=(), and reset().

uint32_t evio::RecordOutput::eventSize = 0

Number of valid bytes in recordEvents buffer.

Referenced by addEvent(), build(), getUncompressedSize(), operator=(), reset(), roomForEvent(), and transferDataForReading().

std::shared_ptr<RecordHeader> evio::RecordOutput::header
uint32_t evio::RecordOutput::indexSize = 0

Number of valid bytes in recordIndex buffer.

Will always be multiple of 4 since indexes are ints.

Referenced by addEvent(), build(), getUncompressedSize(), operator=(), reset(), roomForEvent(), and transferDataForReading().

uint32_t evio::RecordOutput::MAX_BUFFER_SIZE = 8*ONE_MEG

Size of some internal buffers in bytes.

If the recordBinary buffer is passed into the constructor or given through setBuffer(std::shared_ptr<ByteBuffer> &), then this value is 91% of the its size (from position to capacity). This allows some margin for compressed data to be larger than the uncompressed - which may happen if data is random. It also allows other records to have been previously stored in the given buffer (eg. common record) since it starts writing at the buffer position which may not be 0.

Referenced by addEvent(), getInternalBufferCapacity(), operator=(), RecordOutput(), roomForEvent(), and setBuffer().

uint32_t evio::RecordOutput::MAX_EVENT_COUNT = 1000000

Maximum number of events per record.

Referenced by getMaxEventCount(), oneTooMany(), operator=(), and RecordOutput().

constexpr int evio::RecordOutput::ONE_MEG = 1024*1024
static

Maximum number of events per record.

Referenced by addEvent().

uint32_t evio::RecordOutput::RECORD_BUFFER_SIZE = 9*ONE_MEG

Size of buffer holding built record in bytes.

If the recordBinary buffer is passed into the constructor or given through setBuffer(std::shared_ptr<ByteBuffer> &), then this value is set to be 10% bigger than MAX_BUFFER_SIZE. This allows some margin for compressed data to be larger than the uncompressed - which may happen if data is random.

Referenced by addEvent(), operator=(), RecordOutput(), and setBuffer().

std::shared_ptr<ByteBuffer> evio::RecordOutput::recordBinary

Buffer in which to put constructed (& compressed) binary record.

May be provided by user.

Referenced by build(), getBinaryBuffer(), operator=(), RecordOutput(), reset(), setBuffer(), setStartingBufferPosition(), and transferDataForReading().

std::shared_ptr<ByteBuffer> evio::RecordOutput::recordData

This buffer stores data that will be compressed.

Referenced by build(), operator=(), and reset().

std::shared_ptr<ByteBuffer> evio::RecordOutput::recordEvents

This buffer stores event data ONLY.

Referenced by addEvent(), build(), operator=(), RecordOutput(), reset(), and transferDataForReading().

std::shared_ptr<ByteBuffer> evio::RecordOutput::recordIndex

This buffer stores event lengths (in bytes) ONLY.

Referenced by addEvent(), build(), operator=(), RecordOutput(), reset(), and transferDataForReading().

size_t evio::RecordOutput::startingPosition = 0

The starting position of a user-given buffer.

No data will be written before this position.

Referenced by build(), operator=(), RecordOutput(), reset(), setBuffer(), and setStartingBufferPosition().

uint32_t evio::RecordOutput::userBufferSize = 0

The number of initially available bytes to be written into in the user-given buffer, that go from position to limit.

The user-given buffer is stored in recordBinary.

Referenced by getUserBufferSize(), operator=(), RecordOutput(), and setBuffer().

bool evio::RecordOutput::userProvidedBuffer = false

Is recordBinary a user provided buffer?

Referenced by addEvent(), hasUserProvidedBuffer(), operator=(), RecordOutput(), and setBuffer().


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