Title: HDF-Java Products
1HDF-Java Products
Peter Cao The HDF Group HDF and HDF-EOS Workshop
XII October 15, 2008
2What are the HDF-Java products?
HDF-Java
HDF
Java Wrapper
Object Package
Viewer Editor
3Java Wrapper
HDF
4Java Wrapper
Pure Java Library
HDF
Java Native Interface
a programming framework that allows Java code to
call and be called by applications and libraries
written in other languages
HDF
5Pure Java Library
- Pros
- True platform independence
- Direct access to file (no data conversion between
C and Java)
Pure Java Library
- Cons
- Substantial amount of work to implement
- Hard to maintain (new features or format changes)
HDF
6HDF JNI
- Pros
- Easy to implement
- Easy to maintain
HDF
Java Native Interface
- Cons
- Requires data conversion between C and Java
- HDF JNI is platform dependent
HDF
7Java Wrapper
HDF
Java Native Interface
libjhdf.so (or dll)
libjhdf5.so (or dll)
HDFLibrary.java H5.java
HDF4 library
HDF5 library
8Java Wrapper C versus Java
hid_t H5Fcreate ( const char name, unsigned
flags, hid_t create_id, hid_t access_id
) hid_t H5Fopen ( const char name, unsigned
flags, hid_t access_id ) herr_t H5Fclose
( hid_t file_id )
public static native int H5Fcreate ( String
name, int flags, int create_id, int
access_id) public static native int H5Fopen
( String name, int flags, int
access_id) public static native int H5Fclose
( int file_id)
C
Java
9Object Package
HDF-Java
HDF
Java Wrapper
Object Package
Viewer Editor
10Java Wrapper simple dataset read
int fid, did, sid, tid, rank long
dims, maxDims Object theData fid
H5.H5Fopen( fname, HDF5Constants.H5F_ACC_RDWR,
HDF5Constants.H5P_DEFAULT) did
H5.H5Dopen(fid, dname) sid
H5.H5Dget_space(did) tid
H5.H5Dget_type(did) rank
H5.H5Sget_simple_extent_ndims(sid) dims
new longrank maxDims new longrank
H5.H5Sget_simple_extent_dims(sid, dims,
maxDims) theData allocateArray(tid,
dims) H5.H5Dread( did, tid,
HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
HDF5Constants.H5P_DEFAULT, theData)
H5.H5Sclose(sid) H5.H5Tclose(tid)
H5.H5Dclose(did) H5.H5Fclose(fid)
11Object Package the easy way
theData Dataset.read()
12Object Package main purposes
- Simplifies access to HDF files
- Separates applications from libraries
- Modular design
- Client server model
- Makes testing and maintenance easy
13Object Package levels of objects
Common Objects ncsa.hdf.object jhdfobj.jar
Abstract classes
HDF5 ncsa.hdf.object.h5 jhdf5obj.jar
HDF4 ncsa.hdf.object.h4 jhdf4obj.jar
Implementation
14Object Package abstract classes
FileFormat
HObject
Dataset
Group
ScalarDS
CompoundDS
October 15-17, 2008
HDF and HDF-EOS Workshop XII
14
15Object Package HDF4 implementation
ScalarDS
CompounDS
Group
H4Vdata
H4Group
H4GRImage
H4SDS
H4File
FileFormat
October 15-17, 2008
HDF and HDF-EOS Workshop XII
15
16Object Package HDF5 implementation
ScalarDS
CompounDS
Group
H5Group
H5ScalarDS
H5CompoundDS
H5File
FileFormat
October 15-17, 2008
HDF and HDF-EOS Workshop XII
16
17Object Package file create
import ncsa.hdf.object. public class
H5FileCreate private static String fname
"H5FileCreate.h5" public static void main(
String args ) throws Exception
FileFormat fileFormat FileFormat.getFileFormat(F
ileFormat.FILE_TYPE_HDF5)
fileFormat.createFile(fname, FileFormat.FILE_CREAT
E)
18HDFView
HDF-Java
HDF
Java Wrapper
Object Package
Viewer Editor
19HDFView basic components
20HDFView GUI components
HDFView (GUI)
MetaDataView
TreeView
UserImp
UserImp
TableView
TextView
ImageView
UserImp
UserImp
UserImp
21HDFView all together
22What are the HDF-Java products?
HDF-Java
HDF
Java Wrapper
Object Package
Viewer Editor
23Thank You!
This report is based upon work supported in part
by a Cooperative Agreement with the National
Aeronautics and Space Administration (NASA) under
NASA Awards NNX06AC83A and NNX08AO77A. Any
opinions, findings, and conclusions or
recommendations expressed in this material are
those of the author(s) and do not necessarily
reflect the views of the National Aeronautics and
Space Administration.
24Questions/comments?