|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jlab.coda.jevio.BlockHeader
public class BlockHeader
This holds a evio block header, also known as a physical record header. Unfortunately, in version 2, evio files impose an anachronistic block structure. The complication that arises is that logical records (events) will sometimes cross physical record boundaries. This block structure is changed in version 3 so that blockd only contain integral numbers of events.
Field Summary | |
---|---|
static int |
MAGIC_NUMBER
The magic number, should be the value of magicNumber . |
static int |
MAX_BLOCK_SIZE
The maximum block size in 32 bit ints in this (version 2) implementation of evio. |
Constructor Summary | |
---|---|
BlockHeader()
Null constructor initializes all fields to zero. |
|
BlockHeader(int size,
int number)
Creates a BlockHeader for evio version 2 format. |
|
BlockHeader(int size,
int number,
int version)
Creates a BlockHeader. |
Method Summary | |
---|---|
int |
bytesRemaining(int position)
Gives the bytes remaining in this block (physical record) given a buffer position. |
int |
firstEventStartingPosition()
Determines where the start of the first event (logical record) in this block (physical record) is located (in bytes). |
int |
getBufferStartingPosition()
Get the starting position in the buffer (in bytes) from which this header was read--if that happened. This is not part of the block header proper. |
int |
getEnd()
Get the ending position of the block (physical record.) This is the number of valid words (header + data) in the block (physical record.) This is normally the same as the block size, except for the last block (physical record) in the file. NOTE: for evio files, even if end < size (blocksize) for the last block (physical record), the data behind it will be padded with zeroes so that the file size is an integer multiple of the block size. |
int |
getEventCount()
Get the number of events completely contained in the block. |
int |
getHeaderLength()
Get the block header length, in ints. |
int |
getMagicNumber()
Get the magic number the block (physical record) header which should be 0xc0da0100. |
int |
getNumber()
Get the block number for this block (physical record). |
int |
getReserved1()
Get the first reserved word in the block (physical record) header. |
int |
getSize()
Get the size of the block (physical record). |
int |
getStart()
Get the starting position of the block (physical record.). |
int |
getVersion()
Get the evio version of the block (physical record) header. |
int |
nextBufferStartingPosition()
Determines where the start of the next block (physical record) header in some buffer is located (in bytes). |
void |
setBufferStartingPosition(int bufferStartingPosition)
Set the starting position in the buffer (in bytes) from which this header was read--if that happened. This is not part of the block header proper. |
void |
setEnd(int end)
Set the ending position of the block (physical record.) This is the number of valid words (header + data) in the block (physical record.) This is normally the same as the block size, except for the last block (physical record) in the file. |
void |
setEventCount(int count)
Set the number of events completely contained in the block. |
void |
setHeaderLength(int headerLength)
Set the block header length, in ints. |
void |
setMagicNumber(int magicNumber)
Sets the value of magicNumber. |
void |
setNumber(int number)
Set the block number for this block (physical record). |
void |
setReserved1(int reserved1)
Sets the value of reserved 1. |
void |
setSize(int size)
Set the size of the block (physical record). |
void |
setStart(int start)
Set the starting position of the block (physical record.). |
void |
setVersion(int version)
Sets the evio version. |
java.lang.String |
toString()
Obtain a string representation of the block (physical record) header. |
int |
write(java.nio.ByteBuffer byteBuffer)
Write myself out a byte buffer. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MAX_BLOCK_SIZE
public static final int MAGIC_NUMBER
magicNumber
.
Constructor Detail |
---|
public BlockHeader()
public BlockHeader(int size, int number)
size
and (block) headerLength
is initialized to 8start
is initialized to 8end
is initialized to size
version
is initialized to 2reserved1
is initialized to 0magicNumber
is initialized to MAGIC_NUMBER
size
- the size of the block in ints.number
- the block number--usually sequential.public BlockHeader(int size, int number, int version)
size
, (block) version
are provided. Only version numbers 2 or 3 are allowed.
The other five words, which can be modified by setters, are initialized to these values:headerLength
is initialized to 8start
is initialized to 8 (ver2) or 0 (ver3)end
is initialized to size
reserved1
is initialized to 0magicNumber
is initialized to MAGIC_NUMBER
size
- the size of the block in ints.number
- the block number -- usually sequential.version
- the version number -- 2 or 3.Method Detail |
---|
public int getSize()
public void setSize(int size) throws EvioException
size
- the new value for the size, in ints.
EvioException
public int getEventCount()
reserved1
element in the block header is used to store the number
of events in the block.
NOTE: There are no partial events, only complete events stored in one block.
public void setEventCount(int count) throws EvioException
reserved1
element in the block header is used to store the number
of events in the block. Some trivial checking is done.
NOTE: There are no partial events, only complete events stored in one block.
count
- the new number of events in the block.
EvioException
public int getStart()
start = 0
.
NOTE: a logical record (event) that spans three blocks (physical records) will have start = 0
.
public void setStart(int start) throws EvioException
start = 0
.
NOTE: a logical record (event) that spans three blocks (physical records) will have start = 0
.
start
- the new value for the start.
EvioException
public int getEnd()
public void setEnd(int end) throws EvioException
end
- the new value for the end.
EvioException
public int getNumber()
public void setNumber(int number)
number
- the number of the block (physical record).public int getHeaderLength()
public void setHeaderLength(int headerLength) throws EvioException
EvioException
- if headerLength is not 8.public int getVersion()
public void setVersion(int version)
version
- the evio version of evio.public int getReserved1()
reserved1
is used to store the number of events in the block
(physical record) header.
public void setReserved1(int reserved1)
reserved1
- the value for reserved1.public int getMagicNumber()
public void setMagicNumber(int magicNumber) throws EvioException
magicNumber
- the new value for magic number.
EvioException
public java.lang.String toString()
toString
in class java.lang.Object
public int getBufferStartingPosition()
public void setBufferStartingPosition(int bufferStartingPosition)
bufferStartingPosition
- the starting position in the buffer from which this header was read--if that
happened.public int nextBufferStartingPosition()
public int firstEventStartingPosition()
public int bytesRemaining(int position) throws EvioException
bufferStartingPosition
is
being maintained properly by the reader.
position
- the absolute current position is a byte buffer.
EvioException
public int write(java.nio.ByteBuffer byteBuffer)
write
in interface IEvioWriter
byteBuffer
- the byteBuffer to write to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |