|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jlab.coda.jevio.EvioCompactReader
public class EvioCompactReader
This class is used to read an evio version 4 formatted file or buffer and extract specific evio containers (bank, seg, or tagseg) with actual data in them given a tag/num pair. It is theoretically thread-safe. It is designed to be fast and does NOT do a full deserialization on each event examined.
Nested Class Summary | |
---|---|
static class |
EvioCompactReader.ReadStatus
This enum denotes the status of a read. |
Field Summary | |
---|---|
java.util.ArrayList<EvioNode> |
eventNodes
Stores info of all the (top-level) events. |
Constructor Summary | |
---|---|
EvioCompactReader(java.nio.ByteBuffer byteBuffer)
Constructor for reading a buffer. |
|
EvioCompactReader(java.io.File file)
Constructor for reading an event file. |
|
EvioCompactReader(java.lang.String path)
Constructor for reading an event file. |
Method Summary | |
---|---|
java.nio.ByteBuffer |
addStructure(int eventNumber,
java.nio.ByteBuffer addBuffer)
This method adds a bank, segment, or tag segment onto the end of an event. |
void |
close()
This only sets the position to its initial value. |
long |
fileSize()
Get the size of the file being read, in bytes. |
int |
getBlockCount()
This is the number of blocks in the file including the empty block usually at the end of version 4 files/buffers. |
java.nio.ByteBuffer |
getByteBuffer()
Get the byte buffer being read directly or corresponding to the event file. |
java.nio.ByteBuffer |
getData(EvioNode node)
Get the data associated with an evio structure in ByteBuffer form. |
java.nio.ByteBuffer |
getData(EvioNode node,
boolean copy)
Get the data associated with an evio structure in ByteBuffer form. |
EvioXMLDictionary |
getDictionary()
Get the evio dictionary if is there is one. |
java.lang.String |
getDictionaryXML()
Get the XML format dictionary is there is one. |
EvioNode |
getEvent(int eventNumber)
Get the EvioNode object associated with a particular event number. |
int |
getEventCount()
This is the number of events in the file. |
int |
getEvioVersion()
Get the evio version number. |
java.nio.MappedByteBuffer |
getMappedByteBuffer()
Get the memory mapped buffer corresponding to the event file. |
java.lang.String |
getPath()
Get the path to the file. |
boolean |
hasDictionary()
Does this evio file have an associated XML dictionary? |
java.util.List<EvioNode> |
searchEvent(int eventNumber,
int tag,
int num)
This method searches the specified event in a file/buffer and returns a list of objects each of which contain information about a single evio structure which matches the given tag and num. |
java.util.List<EvioNode> |
searchEvent(int eventNumber,
java.lang.String dictName,
EvioXMLDictionary dictionary)
This method searches the specified event in a file/buffer and returns a list of objects each of which contain information about a single evio structure which matches the given dictionary entry name. |
void |
setBuffer(java.nio.ByteBuffer buf)
This method can be used to avoid creating additional EvioCompactReader objects by reusing this one with another buffer. |
void |
toFile(java.io.File file)
Save the internal byte buffer to the given file (overwrites existing file). |
void |
toFile(java.lang.String fileName)
Save the internal byte buffer to the given file (overwrites existing file). |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public final java.util.ArrayList<EvioNode> eventNodes
Constructor Detail |
---|
public EvioCompactReader(java.lang.String path) throws EvioException, java.io.IOException
path
- the full path to the file that contains events.
For writing event files, use an EventWriter
object.
java.io.IOException
- if read failure
EvioException
- if file arg is nullEventWriter
public EvioCompactReader(java.io.File file) throws EvioException, java.io.IOException
file
- the file that contains events.
java.io.IOException
- if read failure
EvioException
- if file arg is null; file is too large;
if first block number != 1 when checkBlkNumSeq arg is trueEventWriter
public EvioCompactReader(java.nio.ByteBuffer byteBuffer) throws EvioException
byteBuffer
- the buffer that contains events.
EvioException
- if file arg is null;
if first block number != 1 when checkBlkNumSeq arg is true;
failure to read first block headerEventWriter
Method Detail |
---|
public void setBuffer(java.nio.ByteBuffer buf) throws EvioException
close()
is called before anything else.
buf
- ByteBuffer to be read
EvioException
- if first block number != 1 when checkBlkNumSeq arg is true;
failure to read first block headerpublic int getEvioVersion()
public java.lang.String getPath()
public java.lang.String getDictionaryXML()
public EvioXMLDictionary getDictionary()
public boolean hasDictionary()
true
if this evio file has an associated XML dictionary,
else false
public java.nio.MappedByteBuffer getMappedByteBuffer()
public java.nio.ByteBuffer getByteBuffer()
public long fileSize()
public EvioNode getEvent(int eventNumber)
eventNumber
- number of event (place in file/buffer) starting at 1.
public java.util.List<EvioNode> searchEvent(int eventNumber, int tag, int num) throws EvioException
eventNumber
- place of event in buffer (starting with 1)tag
- tag to matchnum
- num to match
EvioException
- if bad arg value(s)public java.util.List<EvioNode> searchEvent(int eventNumber, java.lang.String dictName, EvioXMLDictionary dictionary) throws EvioException
eventNumber
- place of event in buffer (starting with 1)dictName
- name of dictionary entry to search for
EvioException
- if dictName is null;
if dictName is an invalid dictionary entry;
if dictionary is null and none provided in file/buffer being readpublic java.nio.ByteBuffer addStructure(int eventNumber, java.nio.ByteBuffer addBuffer) throws EvioException
BaseStructure.write(java.nio.ByteBuffer)
,
BaseStructure.write(java.nio.ByteBuffer)
or
BaseStructure.write(java.nio.ByteBuffer)
depending on whether
a bank, seg, or tagseg is being added.
A note about files here. If the constructor of this reader read in data
from a file, it will now switch to using a new, internal buffer which
is returned by this method or can be retrieved by calling
getByteBuffer()
. It will not expand the file originally used.
A new file can be created by calling either the toFile(String)
or
toFile(java.io.File)
methods.
The given buffer argument must be ready to read with its position and limit defining the limits of the data to copy. This method is synchronized due to the bulk, relative puts.
eventNumber
- number of event to which addBuffer is to be addedaddBuffer
- buffer containing evio data to add (not evio file format,
i.e. no bank headers)
EvioException
- if trying to add to a file;
if eventNumber < 1;
if addBuffer is null;
if addBuffer arg is empty or has non-evio format;
if added data is not the proper length (i.e. multiple of 4 bytes);
if the event number does not correspond to an existing event;
if there is an internal programming error;public java.nio.ByteBuffer getData(EvioNode node)
node
- evio structure whose data is to be retrieved
public java.nio.ByteBuffer getData(EvioNode node, boolean copy)
This method is synchronized due to the bulk, relative gets & puts.
node
- evio structure whose data is to be retrievedcopy
- if true
, then return a copy as opposed to a
view into this reader object's buffer.
public void close()
public int getEventCount()
public int getBlockCount()
public void toFile(java.lang.String fileName) throws EvioException, java.io.IOException
fileName
-
java.io.IOException
EvioException
- if fileName arg is nullpublic void toFile(java.io.File file) throws EvioException, java.io.IOException
file
-
EvioException
- if file arg is null
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |