Table of Contents

Using Java serialization

SCaVis Serialized class

Data can be serialised into a file using the Serialized class.
The only limitation is the computer memory, since the object has to be created first.
In this example we create a list with two 2D arrays and write it to the file. Then we restore it.

HFile class

The class HFile is designed to
store any Java object (including containers) in a compact serialized form.
It is designed to store large data volumes without memory limitations (unlike the class Serialized considered above).
It is well suited for sequential input and outputs.
For example one can store data containers and functions described Data structures and functions.
The class is based on the standard Java serialization mechanism (compression is by default, but can be switched off).
A typical extension for such files is “.ser”.

Essentially, almost any Java object can be stored and retrieved from the HFile file

Data stored in a file created by the class HFile
can be viewed in the browser based on the class HFileBrowser

Let us give an example: we create 3 objects (array and two histograms) and write then into compressed serialized
file (use HFileXML to write into XML format). The we read this file and create these objects:

You can append any any number of objects to this file. You can even make a Jython map or list
from different objects and write such containers in one go.

There is no any restriction on which Java object is written. One can write arbitrary complicated data in form of
arrays, strings, lists, tuples, maps, dictionaries, SCaVis functions, histograms etc. Any Java, Jython, SCaVis or any third-party Java
container which can hold data can
be written into a file. If you want to write objects which can be retrieved using keys, use maps or dictionaries.

Using the keys

Before we considered data records organized sequentially. One can also store objects using keys in form of string.
The keys should be unique.

The notion of “directory” is important. Now one can organize data using some meaningful logic and open data in a browser as will be discussed below.

Be careful mixing data inside HFile without keys and with keys. If you have inserted a lot of records without using keys, you will pay a penalty in retrieval of objects with keys, since objects with keys will always be extracted last, after scanning through all other objects without the keys.

DataBrowser to open ".jser" files

All SCaVis objects stored in compressed Java-serialized files can be viewed
using a browser. For example, if a serialized file contains P1D, P0D, H1D objects,
one can view them and plot them using a mouse-click approach.

If you have a file with the extension “.jser”, you can view it using the DataBrowser.
Go to the toolbar, select [Plot}→[HPlot canvas]→ [File]→ [Open data file]. The you can plot the objects using the
mouse click. Read input_output.