jhplot.io
Class EFile

java.lang.Object
  extended by jhplot.io.EFile

public class EFile
extends java.lang.Object

Write data structures in sequential order into ntuples using Google's Prototype Buffer. The same class can be used to read data from ntuples. Each data record inside files is compressed on-fly using zip. Normally, files should extension "nbu" (ntuples). A protocol Buffers file is provided which can be used for C++ input. Use the CBook package to create such files in C++.


Constructor Summary
EFile(java.lang.String file)
          Open file for reading objects from a serialized file in sequential order.
EFile(java.lang.String file, java.lang.String option)
          Open a file to write/read objects to/from a file in sequential order.
 
Method Summary
 boolean close()
          Close the file
 java.lang.String entriesToString()
          Get a string representing file content.
 int getNEntries()
          Get number of events stored in the file.
 int getVersion()
          Get version of the input file.
 PEventFile.HEvent read()
          Read next event
 PEventFile.HEvent read(int index)
          Get object from a file using its index.
 int size()
          Get the number of events stored in the file.
 boolean write(PEventFile.HEvent.Builder ev)
          Add a data structure to a file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EFile

public EFile(java.lang.String file,
             java.lang.String option)
Open a file to write/read objects to/from a file in sequential order. If "w" option is set, the old file will be removed. Use close() to flash the buffer and close the file.

Parameters:
file - File name
option - Option to create the file. If "w" - write a file (or read) file, if "r" only read created file.

EFile

public EFile(java.lang.String file)
Open file for reading objects from a serialized file in sequential order.

Parameters:
file - File name
Method Detail

getVersion

public int getVersion()
Get version of the input file. The version is an integer written as an additional entry in the file "version". Check this by unzipping the file.

Returns:
version of the created file.

write

public boolean write(PEventFile.HEvent.Builder ev)
Add a data structure to a file

Parameters:
ev - Data in form HEvent class.
Returns:
true if success

size

public int size()
Get the number of events stored in the file.

Returns:
number of stored objects

getNEntries

public int getNEntries()
Get number of events stored in the file. Same as size()

Returns:
number of stored objects

entriesToString

public java.lang.String entriesToString()
Get a string representing file content.

Returns:
File content.

read

public PEventFile.HEvent read()
Read next event

Returns:
next object.

read

public PEventFile.HEvent read(int index)
Get object from a file using its index.

Parameters:
index - of the object
Returns:
Object extracted object (or null)

close

public boolean close()
Close the file

Returns:


jHepWork 2.8 (©) S.Chekanov