class EvioCompactReaderUnsyncV4 extends java.lang.Object implements IEvioCompactReader
Modifier and Type | Field and Description |
---|---|
(package private) static int |
BLOCK_EVENT_COUNT
Offset to get block event count from start of block.
|
(package private) static int |
BLOCK_HEADER_SIZE_OFFSET
Offset to get block header size from start of block.
|
(package private) static int |
BLOCK_NUMBER
Offset to get block number from start of block.
|
(package private) static int |
BLOCK_RESERVED_1
Offset to get block size from start of block.
|
(package private) static int |
BLOCK_SIZE_OFFSET
Offset to get block size from start of block.
|
(package private) static int |
VERSION_MASK
Mask to get version number from 6th int in block.
|
MAGIC_OFFSET, VERSION_OFFSET
Constructor and Description |
---|
EvioCompactReaderUnsyncV4(java.nio.ByteBuffer byteBuffer)
Constructor for reading a buffer.
|
EvioCompactReaderUnsyncV4(java.nio.ByteBuffer byteBuffer,
EvioNodeSource pool)
Constructor for reading a buffer.
|
Modifier and Type | Method and Description |
---|---|
java.nio.ByteBuffer |
addStructure(int eventNumber,
java.nio.ByteBuffer addBuffer)
This method adds an evio container (bank, segment, or tag segment) as the last
structure contained in 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.
|
(package private) void |
generateEventPositionTable()
Generate a table (ArrayList) of positions of events in file/buffer.
|
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.ByteOrder |
getByteOrder()
Get the byte order of the file/buffer being read.
|
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.
|
java.nio.ByteBuffer |
getEventBuffer(int eventNumber)
Get an evio bank or event in ByteBuffer form.
|
java.nio.ByteBuffer |
getEventBuffer(int eventNumber,
boolean copy)
Get an evio bank or event in ByteBuffer form.
|
int |
getEventCount()
This is the number of events in the file/buffer.
|
int |
getEvioVersion()
Get the evio version number.
|
java.nio.ByteOrder |
getFileByteOrder()
Since we're not reading a file, always return null.
|
IBlockHeader |
getFirstBlockHeader()
This returns the FIRST block (or record) header.
|
java.nio.MappedByteBuffer |
getMappedByteBuffer()
Get the memory mapped buffer corresponding to the event file.
|
java.lang.String |
getPath()
Get the path to the file.
|
EvioNode |
getScannedEvent(int eventNumber)
Get the EvioNode object associated with a particular event number
which has been scanned so all substructures are contained in the
node.allNodes list.
|
EvioNode |
getScannedEvent(int eventNumber,
EvioNodeSource nodeSource)
Get the EvioNode object associated with a particular event number
which has been scanned so all substructures are contained in the
node.allNodes list.
|
java.nio.ByteBuffer |
getStructureBuffer(EvioNode node)
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.
|
java.nio.ByteBuffer |
getStructureBuffer(EvioNode node,
boolean copy)
Get an evio structure (bank, seg, or tagseg) in ByteBuffer form.
|
boolean |
hasDictionary()
Does this evio file have an associated XML dictionary?
|
boolean |
isClosed()
Has
close() been called (without reopening by calling
setBuffer(ByteBuffer) )? |
boolean |
isCompressed()
Is the data in the file/buffer compressed?
|
boolean |
isFile()
Is this reader reading a file? Always false for this class.
|
java.nio.ByteBuffer |
removeEvent(int eventNumber)
This method removes the data of the given event from the buffer.
|
java.nio.ByteBuffer |
removeStructure(EvioNode removeNode)
This method removes the data, represented by the given node, from the buffer.
|
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 |
setBuffer(java.nio.ByteBuffer buf,
EvioNodeSource pool)
This method can be used to avoid creating additional EvioCompactReader
objects by reusing this one with another buffer.
|
java.nio.ByteBuffer |
setCompressedBuffer(java.nio.ByteBuffer buf,
EvioNodeSource pool) |
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).
|
static final int BLOCK_SIZE_OFFSET
static final int BLOCK_NUMBER
static final int BLOCK_HEADER_SIZE_OFFSET
static final int BLOCK_EVENT_COUNT
static final int BLOCK_RESERVED_1
static final int VERSION_MASK
public EvioCompactReaderUnsyncV4(java.nio.ByteBuffer byteBuffer) throws EvioException
byteBuffer
- the buffer that contains events.EvioException
- if buffer arg is null;
failure to read first block headerEventWriter
public EvioCompactReaderUnsyncV4(java.nio.ByteBuffer byteBuffer, EvioNodeSource pool) throws EvioException
byteBuffer
- the buffer that contains events.pool
- pool of EvioNode objects to use when parsing buf.EvioException
- if buffer arg is null;
failure to read first block headerEventWriter
public void setBuffer(java.nio.ByteBuffer buf) throws EvioException
close()
is called before anything else.setBuffer
in interface IEvioCompactReader
buf
- ByteBuffer to be readEvioException
- if arg is null;
if failure to read first block headerpublic void setBuffer(java.nio.ByteBuffer buf, EvioNodeSource pool) throws EvioException
close()
is called before anything else.setBuffer
in interface IEvioCompactReader
buf
- ByteBuffer to be readpool
- pool of EvioNode objects to use when parsing buf to avoid garbage collection.EvioException
- if arg is null;
if failure to read first block headerpublic java.nio.ByteBuffer setCompressedBuffer(java.nio.ByteBuffer buf, EvioNodeSource pool) throws EvioException
EvioException
public boolean isFile()
isFile
in interface IEvioCompactReader
public boolean isCompressed()
isCompressed
in interface IEvioCompactReader
public boolean isClosed()
close()
been called (without reopening by calling
setBuffer(ByteBuffer)
)?isClosed
in interface IEvioCompactReader
true
if this object closed, else false
.public java.nio.ByteOrder getByteOrder()
getByteOrder
in interface IEvioCompactReader
public int getEvioVersion()
getEvioVersion
in interface IEvioCompactReader
public java.lang.String getPath()
getPath
in interface IEvioCompactReader
public java.nio.ByteOrder getFileByteOrder()
getFileByteOrder
in interface IEvioCompactReader
public java.lang.String getDictionaryXML() throws EvioException
getDictionaryXML
in interface IEvioCompactReader
EvioException
- if object closed and dictionary still unreadpublic EvioXMLDictionary getDictionary() throws EvioException
getDictionary
in interface IEvioCompactReader
EvioException
- if object closed and dictionary still unreadpublic boolean hasDictionary()
hasDictionary
in interface IEvioCompactReader
true
if this evio file has an associated XML dictionary,
else false
public java.nio.ByteBuffer getByteBuffer()
getByteBuffer
in interface IEvioCompactReader
public java.nio.MappedByteBuffer getMappedByteBuffer()
getMappedByteBuffer
in interface IEvioCompactReader
public long fileSize()
fileSize
in interface IEvioCompactReader
public EvioNode getEvent(int eventNumber)
getEvent
in interface IEvioCompactReader
eventNumber
- number of event (place in file/buffer) starting at 1.public EvioNode getScannedEvent(int eventNumber)
getScannedEvent
in interface IEvioCompactReader
eventNumber
- number of event (place in file/buffer) starting at 1.public EvioNode getScannedEvent(int eventNumber, EvioNodeSource nodeSource)
getScannedEvent
in interface IEvioCompactReader
eventNumber
- number of event (place in file/buffer) starting at 1.nodeSource
- source of EvioNode objects to use while parsing evio data.void generateEventPositionTable() throws EvioException
setBuffer(ByteBuffer)
.EvioException
- if bytes not in evio formatpublic IBlockHeader getFirstBlockHeader()
getFirstBlockHeader
in interface IEvioCompactReader
public java.util.List<EvioNode> searchEvent(int eventNumber, int tag, int num) throws EvioException
searchEvent
in interface IEvioCompactReader
eventNumber
- place of event in buffer (starting with 1)tag
- tag to matchnum
- num to matchEvioException
- if bad arg value(s);
if object closedpublic java.util.List<EvioNode> searchEvent(int eventNumber, java.lang.String dictName, EvioXMLDictionary dictionary) throws EvioException
searchEvent
in interface IEvioCompactReader
eventNumber
- place of event in buffer (starting with 1)dictName
- name of dictionary entry to search fordictionary
- dictionary to use; if null, use dictionary with file/bufferEvioException
- if dictName is null;
if dictName is an invalid dictionary entry;
if dictionary is null and none provided in file/buffer being read;
if object closedpublic java.nio.ByteBuffer removeEvent(int eventNumber) throws EvioException
removeEvent
in interface IEvioCompactReader
eventNumber
- number of event to remove from bufferEvioException
- if eventNumber < 1;
if event number does not correspond to existing event;
if object closed;
if node was not found in any event;
if internal programming errorpublic java.nio.ByteBuffer removeStructure(EvioNode removeNode) throws EvioException
removeStructure
in interface IEvioCompactReader
removeNode
- evio structure to remove from bufferEvioException
- if object closed;
if node was not found in any event;
if internal programming errorpublic java.nio.ByteBuffer addStructure(int eventNumber, java.nio.ByteBuffer addBuffer) throws EvioException
To produce such evio data use BaseStructure.write(ByteBuffer)
,
BaseStructure.write(ByteBuffer)
or
BaseStructure.write(ByteBuffer)
depending on whether
a bank, seg, or tagseg is being added.
The given buffer argument must be ready to read with its position and limit defining the limits of the data to copy.
addStructure
in interface IEvioCompactReader
eventNumber
- number of event to which addBuffer is to be addedaddBuffer
- buffer containing evio data to add (not evio file format,
i.e. no block headers)EvioException
- if eventNumber < 1;
if addBuffer is null;
if addBuffer arg is empty or has non-evio format;
if addBuffer is opposite endian to current event buffer;
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;
if object closedpublic java.nio.ByteBuffer getData(EvioNode node) throws EvioException
getData
in interface IEvioCompactReader
node
- evio structure whose data is to be retrievedEvioException
- if object closed or node arg is null.public java.nio.ByteBuffer getData(EvioNode node, boolean copy) throws EvioException
getData
in interface IEvioCompactReader
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.EvioException
- if object closed or node arg is null.public java.nio.ByteBuffer getEventBuffer(int eventNumber) throws EvioException
getEventBuffer
in interface IEvioCompactReader
eventNumber
- number of event of interestEvioException
- if eventNumber < 1;
if the event number does not correspond to an existing event;
if object closedpublic java.nio.ByteBuffer getEventBuffer(int eventNumber, boolean copy) throws EvioException
getEventBuffer
in interface IEvioCompactReader
eventNumber
- number of event of interestcopy
- if true
, then return a copy as opposed to a
view into this reader object's buffer.EvioException
- if eventNumber < 1;
if the event number does not correspond to an existing event;
if object closedpublic java.nio.ByteBuffer getStructureBuffer(EvioNode node) throws EvioException
getStructureBuffer
in interface IEvioCompactReader
node
- node object representing evio structure of interestEvioException
- if node is null;
if object closedpublic java.nio.ByteBuffer getStructureBuffer(EvioNode node, boolean copy) throws EvioException
getStructureBuffer
in interface IEvioCompactReader
node
- node object representing evio structure of interestcopy
- if true
, then return a copy as opposed to a
view into this reader object's buffer.EvioException
- if node is null;
if object closedpublic void close()
close
in interface IEvioCompactReader
public int getEventCount()
getEventCount
in interface IEvioCompactReader
public int getBlockCount()
getBlockCount
in interface IEvioCompactReader
public void toFile(java.lang.String fileName) throws EvioException, java.io.IOException
toFile
in interface IEvioCompactReader
fileName
- name of file to writejava.io.IOException
- if error writing to fileEvioException
- if fileName arg is null;
if object closedpublic void toFile(java.io.File file) throws EvioException, java.io.IOException
toFile
in interface IEvioCompactReader
file
- object of file to writeEvioException
- if file arg is null;
if object closedjava.io.IOException
- if error writing to file