org.jlab.hipo.io
Class HipoWriter
- java.lang.Object
-
- org.jlab.hipo.io.HipoWriter
-
public class HipoWriter extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field and Description static intCUSTOMHEADERstatic intDICTIONARY
-
Constructor Summary
Constructors Constructor and Description HipoWriter()HipoWriter(java.lang.String file)creates new Writer with an empty record store and associates with an external file with given name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddHeader(java.lang.String config)Adds string to configuration record, this record will be written the first initiation of write operation.voidclose()destructor substitute.HipoEventcreateEvent()Create a new HipoEvent with SchemaFactory of the writer.voiddefineSchema(Schema schema)voiddefineSchema(java.lang.String name, int group, java.lang.String format)SchemaFactorygetSchemaFactory()Returns the Schema factory of the writer.java.lang.StringgetStatusString()returns a status string containing statistics for all interactions with the writer.static voidmain(java.lang.String[] args)Main program to run internal tests and validations.voidopen(java.lang.String name)open a file and empty the record store.voidopen(java.lang.String name, byte[] array)Opens a file, initializes it with a header.voidsetCompression(boolean flag)set compression flag for the writer, if set TRUE all records will be compressed before being written into the file.voidsetCompressionType(int type)Sets the compression type for the records.voidsetMaxRecordCount(int maxCount)sets maximum allowed events in the record until it's flushed into the stream.voidsetMaxRecordSize(int maxSize)sets the maximum buffer size for the records.voidwrite()Writes the content of the record into the file and resets the record buffer so new data can be added.voidwriteEvent(byte[] event)adds an event to the records, not actually written to the disk at this point.voidwriteEvent(HipoEvent event)writes a HipoEvent into a record.
-
-
-
Constructor Detail
-
HipoWriter
public HipoWriter()
-
HipoWriter
public HipoWriter(java.lang.String file)
creates new Writer with an empty record store and associates with an external file with given name.- Parameters:
file-
-
-
Method Detail
-
open
public final void open(java.lang.String name)
open a file and empty the record store.- Parameters:
name- file name to write data in
-
open
public final void open(java.lang.String name, byte[] array)Opens a file, initializes it with a header. and appends provided array to the header. the array content is upto the user, and it can be accessed in the reader once the file is opened for reading.- Parameters:
name- name of the file to open.array- array to write as a header.
-
addHeader
public void addHeader(java.lang.String config)
Adds string to configuration record, this record will be written the first initiation of write operation. It will be record number 0 in the file.- Parameters:
config-
-
write
public void write()
Writes the content of the record into the file and resets the record buffer so new data can be added.
-
writeEvent
public void writeEvent(byte[] event)
adds an event to the records, not actually written to the disk at this point. if the record size or record length exceed the default maximum values the record will be written to the disk and the record container will be reset.- Parameters:
event- byte array to add to the events record.
-
writeEvent
public void writeEvent(HipoEvent event)
writes a HipoEvent into a record.- Parameters:
event- HipoEvent class
-
close
public void close()
destructor substitute. it has to be called at the end of program to make sure the incomplete record is flushed to the file, and file stream is properly closed.
-
getStatusString
public java.lang.String getStatusString()
returns a status string containing statistics for all interactions with the writer. number of records written, number of bytes written, and the performance statistics.- Returns:
-
setCompression
public void setCompression(boolean flag)
set compression flag for the writer, if set TRUE all records will be compressed before being written into the file.- Parameters:
flag-
-
setMaxRecordCount
public void setMaxRecordCount(int maxCount)
sets maximum allowed events in the record until it's flushed into the stream.- Parameters:
maxCount- maximum number of records.
-
setCompressionType
public void setCompressionType(int type)
Sets the compression type for the records. 0 - sets compression flag to false 1 - sets compression algorithm to GZIP 2 - sets compression algorithm to LZ4- Parameters:
type-
-
setMaxRecordSize
public void setMaxRecordSize(int maxSize)
sets the maximum buffer size for the records. this value is used to check size of the record uncompressed, actual record size written on the disk will be compressed size.- Parameters:
maxSize- maximum size in bytes for the record
-
defineSchema
public void defineSchema(java.lang.String name, int group, java.lang.String format)
-
defineSchema
public void defineSchema(Schema schema)
-
getSchemaFactory
public SchemaFactory getSchemaFactory()
Returns the Schema factory of the writer.- Returns:
-
createEvent
public HipoEvent createEvent()
Create a new HipoEvent with SchemaFactory of the writer.- Returns:
- HipoEvent object with Schema factory
-
main
public static void main(java.lang.String[] args)
Main program to run internal tests and validations.- Parameters:
args-
-
-
DMelt 3.0 © DataMelt by jWork.ORG