public final class EventWriter
extends java.lang.Object
implements java.lang.AutoCloseable
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.
Constructor and Description |
---|
EventWriter(java.nio.ByteBuffer buf)
Create an
EventWriter for writing events to a ByteBuffer. |
EventWriter(java.nio.ByteBuffer buf,
int maxRecordSize,
int maxEventCount,
java.lang.String xmlDictionary,
int recordNumber,
CompressionType compressionType)
Create an
EventWriter for writing events to a ByteBuffer. |
EventWriter(java.nio.ByteBuffer buf,
java.lang.String xmlDictionary)
Create an
EventWriter for writing events to a ByteBuffer. |
EventWriter(java.io.File file)
Creates an
EventWriter for writing to a file in native byte order. |
EventWriter(java.io.File file,
boolean append)
Creates an
EventWriter for writing to a file in native byte order. |
EventWriter(java.io.File file,
java.lang.String dictionary,
boolean append)
Creates an
EventWriter for writing to a file in NATIVE byte order. |
EventWriter(java.lang.String filename)
Creates an
EventWriter for writing to a file in native byte order. |
EventWriter(java.lang.String filename,
boolean append)
Creates an
EventWriter for writing to a file in NATIVE byte order. |
EventWriter(java.lang.String filename,
boolean append,
java.nio.ByteOrder byteOrder)
Creates an
EventWriter for writing to a file in the
specified byte order. |
EventWriter(java.lang.String baseName,
java.lang.String directory,
java.lang.String runType,
int runNumber,
long split,
int maxRecordSize,
int maxEventCount,
java.nio.ByteOrder byteOrder,
java.lang.String xmlDictionary,
boolean overWriteOK,
boolean append,
EvioBank firstEvent,
int streamId,
int splitNumber,
int splitIncrement,
int streamCount,
CompressionType compressionType,
int compressionThreads,
int ringSize,
int bufferSize)
Create an
EventWriter for writing events to a file. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This method flushes any remaining data to file and disables this object.
|
void |
flush()
This method flushes any remaining internally buffered data to file.
|
int |
getBlockNumber()
Get the current block (record) number.
|
java.nio.ByteBuffer |
getByteBuffer()
If writing to a file, return null.
|
java.nio.ByteOrder |
getByteOrder()
Get the byte order of the buffer/file being written into.
|
int |
getBytesWrittenToBuffer()
If writing to a buffer, get the number of bytes written to it
including the trailer.
|
java.lang.String |
getCurrentFilename()
Get the name of the current file being written to.
|
java.lang.String |
getCurrentFilePath()
Get the full name or path of the current file being written to.
|
int |
getEventsWritten()
Get the number of events written to a file/buffer.
|
int |
getRecordNumber()
Get the current record number.
|
int |
getSplitCount()
Get the number of split files produced by this writer.
|
int |
getSplitNumber()
Get the current split number which is the split number of file
to be written next.
|
boolean |
hasRoom(int 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.
|
boolean |
isClosed()
Has
close() been called (without reopening by calling
setBuffer(ByteBuffer) ) ? |
boolean |
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.
|
void |
setBuffer(java.nio.ByteBuffer buf)
Set the buffer being written into (initially set in constructor).
|
void |
setBuffer(java.nio.ByteBuffer buf,
java.util.BitSet bitInfo,
int recordNumber)
Set the buffer being written into (initially set in constructor).
|
void |
setEventType(int type)
Set the bit info of a record header for a specified CODA event type.
|
void |
setFirstEvent(java.nio.ByteBuffer buffer)
Set an event which will be written to the file as
well as to all split files.
|
void |
setFirstEvent(EvioBank bank)
Set an event which will be written to the file as
well as to all split files.
|
void |
setFirstEvent(EvioNode node)
Set an event which will be written to the file as
well as to all split files.
|
void |
setSourceId(int sourceId)
Set the value of the source Id in the first block header.
|
void |
setStartingBlockNumber(int startingRecordNumber)
Set the number with which to start block (record) numbers.
|
void |
setStartingRecordNumber(int startingRecordNumber)
Set the number with which to start record numbers.
|
boolean |
toFile()
Is this object writing to file?
|
boolean |
writeEvent(java.nio.ByteBuffer bankBuffer)
Write an event (bank) into a record in evio/hipo version 6 format.
|
boolean |
writeEvent(java.nio.ByteBuffer bankBuffer,
boolean force)
Write an event (bank) into a record in evio/hipo version 6 format.
|
boolean |
writeEvent(EvioBank bank)
Write an event (bank) into a record in evio/hipo version 6 format.
|
boolean |
writeEvent(EvioBank bank,
boolean force)
Write an event (bank) into a record in evio/hipo version 6 format.
|
boolean |
writeEvent(EvioNode node,
boolean force)
Write an event (bank) into a record in evio/hipo version 6 format.
|
boolean |
writeEvent(EvioNode node,
boolean force,
boolean duplicate)
Write an event (bank) into a record in evio/hipo version 6 format.
|
boolean |
writeEventToFile(EvioBank bank,
java.nio.ByteBuffer bankBuffer,
boolean force)
Write an event (bank) into a record and eventually to a file in evio/hipo
version 6 format.
|
boolean |
writeEventToFile(EvioNode node,
boolean force,
boolean duplicate)
Write an event (bank) into a record and eventually to a file in evio/hipo
version 6 format.
|
public EventWriter(java.io.File file) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten.
If it doesn't exist, it will be created.file
- the file object to write to.EvioException
- file cannot be createdpublic EventWriter(java.io.File file, boolean append) throws EvioException
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.file
- the file object to write to.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.EvioException
- file cannot be createdpublic EventWriter(java.io.File file, java.lang.String dictionary, boolean append) throws EvioException
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.file
- the file object to write to.dictionary
- dictionary in xml format or null if none.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.EvioException
- file cannot be createdpublic EventWriter(java.lang.String filename) throws EvioException
EventWriter
for writing to a file in native byte order.
If the file already exists, its contents will be overwritten.
If it doesn't exist, it will be created.filename
- name of the file to write to.EvioException
- file cannot be createdpublic EventWriter(java.lang.String filename, boolean append) throws EvioException
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.filename
- name of the file to write to.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.EvioException
- file cannot be createdpublic EventWriter(java.lang.String filename, boolean append, java.nio.ByteOrder byteOrder) throws EvioException
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.filename
- name of the file to write to.append
- if true
and the file already exists,
all events to be written will be appended to the
end of the file.byteOrder
- the byte order in which to write the file.EvioException
- file cannot be createdpublic EventWriter(java.lang.String baseName, java.lang.String directory, java.lang.String runType, int runNumber, long split, int maxRecordSize, int maxEventCount, java.nio.ByteOrder byteOrder, java.lang.String xmlDictionary, boolean overWriteOK, boolean append, EvioBank firstEvent, int streamId, int splitNumber, int splitIncrement, int streamCount, CompressionType compressionType, int compressionThreads, int ringSize, int bufferSize) throws EvioException
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 $(ENV_VAR) 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.
baseName
- base file name used to generate complete file name (may not be null)directory
- directory in which file is to be placedrunType
- name of run type configuration to be used in naming filesrunNumber
- number of the CODA run, used in naming filessplit
- if < 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.maxRecordSize
- max 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.maxEventCount
- max number of events each record can hold.
Value <= O means use default (1M).byteOrder
- the byte order in which to write the file. This is ignored
if appending to existing file. Defaults to Big Endian if null.xmlDictionary
- dictionary in xml format or null if none.overWriteOK
- if false
and the file already exists,
an exception is thrown rather than overwriting it.append
- if true
append written data to given file.firstEvent
- the 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.streamId
- streamId number (100 > id > -1) for file namesplitNumber
- number at which to start the split numberssplitIncrement
- amount to increment split number each time another file is created.streamCount
- total number of streams in DAQ.compressionType
- type of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip).compressionThreads
- number of threads doing compression simultaneously.ringSize
- number 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.bufferSize
- number of bytes to make each internal buffer which will
be storing events before writing them to a file.
9MB = default if bufferSize = 0.EvioException
- if 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.public EventWriter(java.nio.ByteBuffer buf) throws EvioException
EventWriter
for writing events to a ByteBuffer.
Uses the default number and size of records in buffer.
Will overwrite any existing data in buffer!buf
- the buffer to write to.EvioException
- if buf arg is nullpublic EventWriter(java.nio.ByteBuffer buf, java.lang.String xmlDictionary) throws EvioException
EventWriter
for writing events to a ByteBuffer.
Uses the default number and size of records in buffer.buf
- the buffer to write to.xmlDictionary
- dictionary in xml format or null if none.EvioException
- if buf arg is nullpublic EventWriter(java.nio.ByteBuffer buf, int maxRecordSize, int maxEventCount, java.lang.String xmlDictionary, int recordNumber, CompressionType compressionType) throws EvioException
EventWriter
for writing events to a ByteBuffer.
The buffer's position is set to 0 before writing.buf
- the buffer to write to starting at position = 0.maxRecordSize
- max 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.maxEventCount
- max number of events each record can hold.
Value <= O means use default (1M).xmlDictionary
- dictionary in xml format or null if none.recordNumber
- number at which to start record number counting.compressionType
- type of data compression to do (0=none, 1=lz4 fast, 2=lz4 best, 3=gzip)EvioException
- if maxRecordSize or maxEventCount exceed limits;
if buf arg is null;public boolean isDiskFull()
public void setBuffer(java.nio.ByteBuffer buf, java.util.BitSet bitInfo, int recordNumber) throws EvioException
Do not use this method unless you know what you are doing.
buf
- the buffer to write to.bitInfo
- set of bits to include in first record header.recordNumber
- number at which to start record number counting.EvioException
- if this object was not closed prior to resetting the buffer,
buffer arg is null, or writing to file.public void setBuffer(java.nio.ByteBuffer buf) throws EvioException
Do not use this method unless you know what you are doing.
buf
- the buffer to write to.EvioException
- if this object was not closed prior to resetting the buffer,
buffer arg is null, or writing to file.public java.nio.ByteBuffer getByteBuffer()
public void setSourceId(int sourceId)
sourceId
- value of the source Id.public void setEventType(int type)
RecordHeader.setBitInfo(boolean, boolean)
or
RecordHeader.setBitInfoWord(int)
in order to have change preserved.
This should only be used internally by CODA in emu software.type
- event type (0=ROC raw, 1=Physics, 2=Partial Physics,
3=Disentangled, 4=User, 5=Control, 15=Other,
else = nothing set).public boolean toFile()
true
if writing to file, else false
.public boolean isClosed()
close()
been called (without reopening by calling
setBuffer(ByteBuffer)
) ?true
if this object closed, else false
.public java.lang.String getCurrentFilename()
public int getBytesWrittenToBuffer()
public java.lang.String getCurrentFilePath()
public int getSplitNumber()
public int getSplitCount()
public int getBlockNumber()
public int getRecordNumber()
public int getEventsWritten()
public java.nio.ByteOrder getByteOrder()
public void setStartingBlockNumber(int startingRecordNumber)
startingRecordNumber
- the number with which to start block
(record) numbers.public void setStartingRecordNumber(int startingRecordNumber)
startingRecordNumber
- the number with which to start record numbers.public void setFirstEvent(EvioNode node) throws EvioException, java.io.IOException
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.
node
- node representing event to be placed first in each file written
including all splits. If null, no more first events are written
to any files.java.io.IOException
- if error writing to fileEvioException
- 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;public void setFirstEvent(java.nio.ByteBuffer buffer) throws EvioException, java.io.IOException
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.
buffer
- buffer containing event to be placed first in each file written
including all splits. If null, no more first events are written
to any files.java.io.IOException
- if error writing to fileEvioException
- 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;public void setFirstEvent(EvioBank bank) throws EvioException, java.io.IOException
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.
bank
- event to be placed first in each file written including all splits.
If null, no more first events are written to any files.java.io.IOException
- if error writing to fileEvioException
- 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;public void flush()
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.
public void close()
close
in interface java.lang.AutoCloseable
public boolean hasRoom(int bytes)
bytes
- number of bytes to writetrue
if there still room in the output buffer, else false
.public boolean writeEvent(EvioNode node, boolean force) throws EvioException, java.io.IOException
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.
node
- object representing the event to write in buffer formforce
- if writing to disk, force it to write event to the disk.java.io.IOException
- if error writing fileEvioException
- 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;public boolean writeEvent(EvioNode node, boolean force, boolean duplicate) throws EvioException, java.io.IOException
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.
node
- object representing the event to write in buffer formforce
- if writing to disk, force it to write event to the disk.duplicate
- if true, duplicate node's buffer so its position and limit
can be changed without issue.java.io.IOException
- if error writing fileEvioException
- 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;public boolean writeEventToFile(EvioNode node, boolean force, boolean duplicate) throws EvioException, java.io.IOException
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(EvioBank, ByteBuffer, boolean)
(or the various writeEvent() methods which call it).
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.
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.
node
- object representing the event to write in buffer formforce
- if writing to disk, force it to write event to the disk.duplicate
- if true, duplicate node's buffer so its position and limit
can be changed without issue.java.io.IOException
- if error writing fileEvioException
- 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;public boolean writeEvent(java.nio.ByteBuffer bankBuffer) throws EvioException, java.io.IOException
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.
bankBuffer
- the bank (as a ByteBuffer object) to write.java.io.IOException
- if error writing fileEvioException
- 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.public boolean writeEvent(java.nio.ByteBuffer bankBuffer, boolean force) throws EvioException, java.io.IOException
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.
bankBuffer
- the bank (as a ByteBuffer object) to write.force
- if writing to disk, force it to write event to the disk.java.io.IOException
- if error writing fileEvioException
- 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.public boolean writeEvent(EvioBank bank) throws EvioException, java.io.IOException
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.
bank
- the bank to write.java.io.IOException
- if error writing fileEvioException
- if close() already called;
if file could not be opened for writing;
if file exists but user requested no over-writing;.public boolean writeEvent(EvioBank bank, boolean force) throws EvioException, java.io.IOException
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.
bank
- the bank to write.force
- if writing to disk, force it to write event to the disk.java.io.IOException
- if error writing fileEvioException
- if close() already called;
if file could not be opened for writing;
if file exists but user requested no over-writing;.public boolean writeEventToFile(EvioBank bank, java.nio.ByteBuffer bankBuffer, boolean force) throws EvioException, java.io.IOException
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(EvioBank, ByteBuffer, boolean)
(or the various writeEvent() methods which call it).
Results are unpredictable as it messes up the
logic used to quit writing to full disk.
The event to be written may be in one of two forms.
The first is as an EvioBank object and the second is as a ByteBuffer
containing only the event's data (event header and event data) and must
not be in complete evio file format.
The first non-null of the bank arguments will be written.
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.
bank
- the bank (as an EvioBank object) to write.bankBuffer
- the bank (as a ByteBuffer object) to write.force
- if writing to disk, force it to write event to the disk.java.io.IOException
- if error writing fileEvioException
- if event is opposite byte order of internal buffer;
if both buffer args are null;
if bad bankBuffer format;
if close() already called;
if not writing to file;
if file could not be opened for writing;
if file exists but user requested no over-writing.