org.jlab.hipo.io
Class HipoRecord
- java.lang.Object
-
- org.jlab.hipo.io.HipoRecord
-
public class HipoRecord extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor and Description HipoRecord()creates and empty record ready for adding events and removing events.HipoRecord(byte[] array)Initializes a record from it's binary form and creates arrays as events that can be accessed through the interface.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddEvent(byte[] array)add an byte array into the record.java.nio.ByteBufferbuild()Builds the record into a ByteBuffer includes the Header, Index Array and Event Buffer.byte[]buildDataBytes()returns one byte[] containing all the events chained togetherbyte[]buildIndexBytes()returns a byte[] array with index for each event.booleancompressed()returns the value of the compression flag bitintgetBytesWritten()intgetDataBytesSize()returns the total size of the all events combinedbyte[]getEvent(int index)intgetEventCount()returns number of events contained in the recordstatic voidmain(java.lang.String[] args)voidreset()initializes an empty record.voidsetCompressionType(int type)sets the compression type for the record.voidshow()prints on the screen information about record.
-
-
-
Constructor Detail
-
HipoRecord
public HipoRecord()
creates and empty record ready for adding events and removing events.
-
HipoRecord
public HipoRecord(byte[] array)
Initializes a record from it's binary form and creates arrays as events that can be accessed through the interface. also contains options flags such as version, type of data stored an compression flag.- Parameters:
array-
-
-
Method Detail
-
reset
public final void reset()
initializes an empty record. writes the identifying string "RC_G" to the first byte, this makes it easy to search in binary buffer for record start bytes in case there is a corruption in the stream.
-
addEvent
public void addEvent(byte[] array)
add an byte array into the record.- Parameters:
array-
-
getBytesWritten
public int getBytesWritten()
-
build
public java.nio.ByteBuffer build()
Builds the record into a ByteBuffer includes the Header, Index Array and Event Buffer. If compression type is specified the event buffer will be compressed, and header will contain different sizes for event size compressed and event size uncompressed. NOTE: the record Header is never compressed.- Returns:
-
setCompressionType
public void setCompressionType(int type)
sets the compression type for the record. 0 - no compression 1 - GZIP compression 2 - LZ4 compression- Parameters:
type-
-
getDataBytesSize
public int getDataBytesSize()
returns the total size of the all events combined- Returns:
-
buildIndexBytes
public byte[] buildIndexBytes()
returns a byte[] array with index for each event.- Returns:
-
buildDataBytes
public byte[] buildDataBytes()
returns one byte[] containing all the events chained together- Returns:
-
getEventCount
public int getEventCount()
returns number of events contained in the record- Returns:
-
getEvent
public byte[] getEvent(int index)
-
show
public void show()
prints on the screen information about record.
-
compressed
public boolean compressed()
returns the value of the compression flag bit- Returns:
- 0 if compression flag is not set, 1 - if set
-
main
public static void main(java.lang.String[] args)
-
-
DMelt 3.0 © DataMelt by jWork.ORG