HDFView and HDF Java Products

24
October 15-17, 2008 HDF and HDF-EOS Workshop XII 1 HDF-Java Products Peter Cao The HDF Group HDF and HDF-EOS Workshop XII October 15, 2008

description

This tutorial will introduce the three levels of the HDF-Java products: the HDF-Java wrapper (or Java Native Interfaces to the standard HDF libraries), the HDF-Java object package, and the HDFView. The Java wrapper provides standard Java APIs that allow applications to call the C HDF libraries from Java. The HDF-Java object package implements HDF data objects, e.g. Groups and Datasets, in an object-oriented form and makes it easy for applications to use the libraries. The HDFView is a visual tool for browsing and editing HDF4 and HDF5 files.

Transcript of HDFView and HDF Java Products

Page 1: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 1

HDF-Java Products

Peter Cao

The HDF Group

HDF and HDF-EOS Workshop XII

October 15, 2008

Page 2: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 2

What are the HDF-Java products?

HDF-Java

HDF

JavaWrapper

ObjectPackage

Viewer Editor

Page 3: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 3

Java Wrapper

HDF

Page 4: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 4

Java Wrapper

HDF

Pure JavaLibrary

HDF

Java Native Interface

a programming framework that allows Java code to call and be called by applications and libraries written in other languages

Page 5: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 5

Pure Java Library

• Pros: True platform independence Direct access to file (no data

conversion between C and Java)

HDF

Pure JavaLibrary

• Cons: Substantial amount of work to

implement Hard to maintain (new features or

format changes)

Page 6: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 6

HDF JNI

• Pros: Easy to implement Easy to maintain

HDF

HDF

Java Native Interface

• Cons: Requires data conversion between C

and Java HDF JNI is platform dependent

Page 7: HDFView and HDF Java Products

Java Wrapper

October 15-17, 2008 HDF and HDF-EOS Workshop XII 7

HDF Java Native Interface

HDFLibrary.javaH5.java

libjhdf.so (or dll)

libjhdf5.so (or dll)

HDF4 library

HDF5 library

Page 8: HDFView and HDF Java Products

Java Wrapper: C versus Java

October 15-17, 2008 HDF and HDF-EOS Workshop XII 8

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

Page 9: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 9

Object Package

HDF-Java

HDF

JavaWrapper

ObjectPackage

Viewer Editor

Page 10: HDFView and HDF Java Products

Java Wrapper: simple dataset read

October 15-17, 2008 HDF and HDF-EOS Workshop XII 10

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 long[rank]; maxDims = new long[rank]; 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);

Page 11: HDFView and HDF Java Products

Object Package: the easy way

October 15-17, 2008 HDF and HDF-EOS Workshop XII 11

theData = Dataset.read();

Page 12: HDFView and HDF Java Products

Object Package: main purposes

October 15-17, 2008 HDF and HDF-EOS Workshop XII 12

• Simplifies access to HDF files• Separates applications from libraries

Modular design Client server model

• Makes testing and maintenance easy

Page 13: HDFView and HDF Java Products

Object Package: levels of objects

October 15-17, 2008 HDF and HDF-EOS Workshop XII 13

Common Objectsncsa.hdf.object

jhdfobj.jar

HDF4ncsa.hdf.object.h4

jhdf4obj.jar

HDF5ncsa.hdf.object.h5

jhdf5obj.jar

Abstract classesAbstract classes

ImplementationImplementation

Page 14: HDFView and HDF Java Products

Object Package: abstract classes

October 15-17, 2008 HDF and HDF-EOS Workshop XII 14

HObjectHObject

CompoundDSCompoundDSScalarDSScalarDS

DatasetDatasetGroupGroup

FileFormatFileFormat

Page 15: HDFView and HDF Java Products

Object Package: HDF4 implementation

October 15-17, 2008 HDF and HDF-EOS Workshop XII 15

H4GroupH4Group H4GRImageH4GRImageH4SDSH4SDS H4VdataH4Vdata

GroupGroup ScalarDSScalarDS CompounDSCompounDS

FileFormatFileFormat

H4FileH4File

Page 16: HDFView and HDF Java Products

Object Package: HDF5 implementation

October 15-17, 2008 HDF and HDF-EOS Workshop XII 16

H5GroupH5Group H5ScalarDSH5ScalarDS H5CompoundDSH5CompoundDS

GroupGroup ScalarDSScalarDS CompounDSCompounDS

FileFormatFileFormat

H5FileH5File

Page 17: HDFView and HDF Java Products

Object Package: file create

October 15-17, 2008 HDF and HDF-EOS Workshop XII 17

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(FileFormat.FILE_TYPE_HDF5);

fileFormat.createFile(fname, FileFormat.FILE_CREATE);

}}

Page 18: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 18

HDFView

HDF-Java

HDF

JavaWrapper

ObjectPackage

Viewer Editor

Page 19: HDFView and HDF Java Products

HDFView: basic components

October 15-17, 2008 HDF and HDF-EOS Workshop XII 19

Page 20: HDFView and HDF Java Products

HDFView: GUI components

October 15-17, 2008 HDF and HDF-EOS Workshop XII 20

HDFView(GUI)TreeView MetaDataView

TableView ImageView TextView

UserImp

UserImpUserImpUserImp

UserImp

Page 21: HDFView and HDF Java Products

HDFView: all together

October 15-17, 2008 HDF and HDF-EOS Workshop XII 21

Page 22: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 22

What are the HDF-Java products?

HDF-Java

HDF

JavaWrapper

ObjectPackage

Viewer Editor

Page 23: HDFView and HDF Java Products

October 15-17, 2008 HDF and HDF-EOS Workshop XII 23

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.

Thank You!

Page 24: HDFView and HDF Java Products

Questions/comments?

October 15-17, 2008 HDF and HDF-EOS Workshop XII 24