Skip to content

Commit

Permalink
add constructor that sets first record event type
Browse files Browse the repository at this point in the history
  • Loading branch information
carltimmer committed Feb 16, 2024
1 parent 929aa65 commit 07b9478
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 4 deletions.
40 changes: 39 additions & 1 deletion java/org/jlab/coda/jevio/EventWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1316,9 +1316,44 @@ public EventWriter(ByteBuffer buf, String xmlDictionary) throws EvioException {
* @throws EvioException if maxRecordSize or maxEventCount exceed limits;
* if buf arg is null;
*/
public EventWriter(ByteBuffer buf, int maxRecordSize, int maxEventCount,
String xmlDictionary, int recordNumber,
CompressionType compressionType)
throws EvioException {

this(buf, maxRecordSize, maxEventCount, xmlDictionary, recordNumber, compressionType, -1);
}

/**
* Create an <code>EventWriter</code> for writing events to a ByteBuffer.
* The buffer's position is set to 0 before writing.
* When writing a buffer, only 1 record is used.
* Any dictionary will be put in a commonRecord and that record will be
* placed in the user header associated with the single record.
*
* @param buf the buffer to write to starting at position = 0.
* @param maxRecordSize max number of data bytes each record can hold.
* Value of &lt; 8MB results in default of 8MB.
* The size of the record will not be larger than this size
* <b>Currently this arg is unused. Only 1 record will be
* used in the given buffer.</b>
* unless a single event itself is larger.
* @param maxEventCount max number of events each record can hold.
* Value &lt;= O means use default (1M).
* @param xmlDictionary dictionary in xml format or null if none.
* @param recordNumber number at which to start record number counting.
* @param compressionType type of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip)
* @param eventType first record header holds the following type of event encoded in bitInfo,
* (0=RocRaw, 1=Physics, 2=Partial Physics, 3=Disentangled,
* 4=User, 5=Control, 6=Mixed, 8=RocRawStream, 9=PhysicsStream, 15=Other).
* If &lt; 0 or &gt; 15, this arg is ignored.
*
* @throws EvioException if maxRecordSize or maxEventCount exceed limits;
* if buf arg is null;
*/
public EventWriter(ByteBuffer buf, int maxRecordSize, int maxEventCount,
String xmlDictionary, int recordNumber,
CompressionType compressionType)
CompressionType compressionType, int eventType)
throws EvioException {

if (buf == null) {
Expand Down Expand Up @@ -1368,6 +1403,9 @@ public EventWriter(ByteBuffer buf, int maxRecordSize, int maxEventCount,

RecordHeader header = currentRecord.getHeader();
header.setBitInfo(false, xmlDictionary != null);
if (eventType >=0 && eventType <= 15) {
header.setBitInfoEventType(eventType);
}
}


Expand Down
44 changes: 42 additions & 2 deletions java/org/jlab/coda/jevio/EventWriterUnsync.java
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ public EventWriterUnsync(ByteBuffer buf, String xmlDictionary) throws EvioExcept
/**
* Create an <code>EventWriter</code> for writing events to a ByteBuffer.
* The buffer's position is set to 0 before writing.
* When writing a buffer, only 1 record is used.
* <b>When writing a buffer, only 1 record is used.</b>
* Any dictionary will be put in a commonRecord and that record will be
* placed in the user header associated with the single record.
*
Expand All @@ -1364,6 +1364,43 @@ public EventWriterUnsync(ByteBuffer buf, int maxRecordSize, int maxEventCount,
CompressionType compressionType)
throws EvioException {

this(buf, maxRecordSize, maxEventCount, xmlDictionary, recordNumber, compressionType, -1);
}



/**
* Create an <code>EventWriter</code> for writing events to a ByteBuffer.
* The buffer's position is set to 0 before writing.
* <b>When writing a buffer, only 1 record is used.</b>
* Any dictionary will be put in a commonRecord and that record will be
* placed in the user header associated with the single record.
*
* @param buf the buffer to write to starting at position = 0.
* @param maxRecordSize max number of data bytes each record can hold.
* Value of &lt; 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.
* <b>Currently this arg is unused. Only 1 record will be
* used in the given buffer.</b>
* @param maxEventCount max number of events each record can hold.
* Value &lt;= O means use default (1M).
* @param xmlDictionary dictionary in xml format or null if none.
* @param recordNumber number at which to start record number counting.
* @param compressionType type of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip)
* @param eventType first record header holds the following type of event encoded in bitInfo,
* (0=RocRaw, 1=Physics, 2=Partial Physics, 3=Disentangled,
* 4=User, 5=Control, 6=Mixed, 8=RocRawStream, 9=PhysicsStream, 15=Other).
* If &lt; 0 or &gt; 15, this arg is ignored.
*
* @throws EvioException if maxRecordSize or maxEventCount exceed limits;
* if buf arg is null;
*/
public EventWriterUnsync(ByteBuffer buf, int maxRecordSize, int maxEventCount,
String xmlDictionary, int recordNumber,
CompressionType compressionType, int eventType)
throws EvioException {

if (buf == null) {
throw new EvioException("Buffer arg cannot be null");
}
Expand Down Expand Up @@ -1411,6 +1448,9 @@ public EventWriterUnsync(ByteBuffer buf, int maxRecordSize, int maxEventCount,

RecordHeader header = currentRecord.getHeader();
header.setBitInfo(false, xmlDictionary != null);
if (eventType >=0 && eventType <= 15) {
header.setBitInfoEventType(eventType);
}
}


Expand All @@ -1421,7 +1461,7 @@ public EventWriterUnsync(ByteBuffer buf, int maxRecordSize, int maxEventCount,
* {@link #setBuffer(ByteBuffer, BitSet, int)}.
*
* @param buf the buffer to write to.
* @param bitInfo set of bits to include in first record header.
* @param bitInfo set of bits to include in 6th word of first record header.
* @param recordNumber number at which to start record number counting.
* @param useCurrentBitInfo regardless of bitInfo arg's value, use the
* current value of bitInfo in the reinitialized buffer.
Expand Down
38 changes: 37 additions & 1 deletion src/libsrc++/EventWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,40 @@ namespace evio {
EventWriter::EventWriter(std::shared_ptr<ByteBuffer> & buf,
uint32_t maxRecordSize, uint32_t maxEventCount,
const std::string & xmlDictionary, uint32_t recordNumber,
Compressor::CompressionType compressionType) {
Compressor::CompressionType compressionType) :

EventWriter(buf, maxRecordSize, maxEventCount, xmlDictionary, recordNumber,
compressionType, -1) {
}


/**
* Create an <code>EventWriter</code> for writing events to a ByteBuffer.
* The buffer's position is set to 0 before writing.
* Any dictionary will be put in a commonRecord and that record will be
* placed in the user header associated with the single record.
*
* @param buf the buffer to write to starting at position = 0.
* @param maxRecordSize max number of data bytes each record can hold.
* Value of &lt; 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.
* @param maxEventCount max number of events each record can hold.
* Value &lt;= O means use default (1M).
* @param xmlDictionary dictionary in xml format or null if none.
* @param recordNumber number at which to start record number counting.
* @param compressionType type of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip)
* @param eventType first record header holds the following type of event encoded in bitInfo,
* (0=RocRaw, 1=Physics, 2=Partial Physics, 3=Disentangled,
* 4=User, 5=Control, 6=Mixed, 8=RocRawStream, 9=PhysicsStream, 15=Other).
* If &lt; 0 or &gt; 15, this arg is ignored.
*
* @throws EvioException if maxRecordSize or maxEventCount exceed limits;
*/
EventWriter::EventWriter(std::shared_ptr<ByteBuffer> & buf,
uint32_t maxRecordSize, uint32_t maxEventCount,
const std::string & xmlDictionary, uint32_t recordNumber,
Compressor::CompressionType compressionType, int eventType) {

this->toFile = false;
this->append = false;
Expand Down Expand Up @@ -529,6 +562,9 @@ namespace evio {

auto & header = currentRecord->getHeader();
header->setBitInfo(false, !xmlDictionary.empty());
if (eventType >=0 && eventType <= 15) {
header.setBitInfoEventType(eventType);
}
}


Expand Down
3 changes: 3 additions & 0 deletions src/libsrc++/EventWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,9 @@ namespace evio {
EventWriter(std::shared_ptr<ByteBuffer> & buf, uint32_t maxRecordSize, uint32_t maxEventCount,
const std::string & xmlDictionary, uint32_t recordNumber,
Compressor::CompressionType compressionType);
EventWriter(std::shared_ptr<ByteBuffer> & buf, uint32_t maxRecordSize, uint32_t maxEventCount,
const std::string & xmlDictionary, uint32_t recordNumber,
Compressor::CompressionType compressionType, int eventType);

private:

Expand Down

0 comments on commit 07b9478

Please sign in to comment.