SlideShare a Scribd company logo
1 of 21
Download to read offline
HDF-EOS Java Application
Programming Interfaces
Genong (Eugene) Yu, Ph.D.
Research associate

Liping Di, Ph.D.
Professor & Director of CSISS
{gyu, ldi}@gmu.edu

November 28-30, 2006

HDF and HDF-EOS Workshop X,
Upper Marlboro, MD
Outline
• Why Java API interfaces?
• Java API interfaces
– Variable consideration

•
•
•
•

Java Object wrap-up
Performance consideration
Applications
Problem
– Memory management
Demand
• Distribution systems over the Web
– Java-based server
• Apache Tomcat

• Manipulation of data for the Web
application
– Re-projection service
– Classification service
– Re-format service
Bridging Java Program and C/C++ library
The Problem
HDF-EOS
HDF-EOS

HDF-EOS
HDF-EOS

HDF-EOS
HDF-EOS

HDF JNI API

• HDF-EOS library – in C/C++ library
• All functions to manipulate grid and
point are written in C
• Primer for HDF-EOS is for C
• HDF JNI libraries are available
• Possible approach

Java Reader

• Rewrite the program in Java

WEB APPLICATION

• Pros: better for Java environment
The Solution
HDF-EOS
HDF-EOS

HDF-EOS
HDF-EOS

HDF-EOS
HDF-EOS

HDF-EOS / HDF JNI API

Java Reader
WEB APPLICATION

• Cons: enormous work and need
to keep track of revision
• Call the library directly through JNI
• Pros: manageable work and
efficient re-use
• Cons: memory management,
debugging
How JNI works (1)
• Java interface
– public static native int GDopen(String filename, int
access) throws HDFEOSException;
– Load library
• System.loadLibrary("jhdfeos4");

• Compile the above code
– javac HDFEOSLibrary.java

• Create header File
– javah -jni edu
How JNI works (2)
• Create the library in C/C++
– Template
• JNIEXPORT void JNICALL Java_ClassName_MethodName
(JNIEnv *env, jobject obj) {
• //Implement Native Method Here
• }

– Example
• JNIEXPORT jint JNICALL
Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_SWdupregion
• (JNIEnv *env, jclass class, jint oldregionID)
• {
•
int32 regionID;
•
regionID=SWdupregion((int32)oldregionID);
•
return (jint)regionID;
• }
Tasks to enable the JNI
• To access a C library from a Java
program, four tasks must be completed:
– Declare appropriate “native” methods in Java
classes
– Write “interface” code for each native method
to implement the JNI C or C++ standard
– compile the JNI “interface” (C or C++) to
create a JNI library
– deploy the Java classes and the JNI library on
the system
Mapping types (1)
• Interchangeable types
Native type
(C/C++)

Java Language Description
Type

HDF/HDFEOS

bool

jboolean

Unsigned 8 bits

intn, uint8

byte

jbyte

Signed 8 bits

int8

char

jchar

Unsigned 16 bits uint16

short

jshort

Signed 16 bits

int16

long

jint

Signed 32 bits

int32

long long

jlong

Signed 64 bits

int64

Float

jfloat

Float 32 bits

float32

Double

jdouble

Float 64 bits

float64
Mapping types (2)
•

String
–

Wrong
• JNIEXPORT jint JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_SWcreate
• (JNIEnv *env, jclass class, jint file_id, jstring swath_name)
• {
• return SWcreate( (int32)file_id, (char *) swath_name);
• }

–

Correct
• JNIEXPORT jint JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_SWcreate
• (JNIEnv *env, jclass class, jint file_id, jstring swath_name)
• {
• char *s_filename;
• int32 swath_id;
• s_filename = (char *) (*env)->GetStringUTFChars( env, swath_name, 0);
• swath_id = SWcreate( (int32)file_id, (char *)s_filename );
• (*env)->ReleaseStringUTFChars(env, swath_name, s_filename );
• return (jint)swath_id;
• }
Mapping types (3)
•

Array
–

–

Wrong
• JNIEXPORT jboolean JNICALL
Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_GDorigininfo
• (JNIEnv *env, jclass class, jint gridID, jintArray origincode)
• {
•
int32 status;
•
status= GDorigininfo((int32)gridID,(int32 *)origincode);
•
if (status==-1) return JNI_FALSE;
•
else return JNI_TRUE;
• }
Correct
•
•
•
•
•
•
•
•
•
•
•

JNIEXPORT jboolean JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_GDorigininfo
(JNIEnv *env, jclass class, jint gridID, jintArray origincode)
{
int32 *i_origincode;
int32 status;
i_origincode=(int32 *)(*env)->GetIntArrayElements(env,origincode,0);
status=GDorigininfo((int32)gridID,i_origincode);
(*env)->ReleaseIntArrayElements(env,origincode,(jint *)i_origincode,0);
if (status==-1) return JNI_FALSE;
else return JNI_TRUE;
}
Mapping types (4)
• Pointer
– In C
• intn SWattrinfo(int32 swathID, char *attrname, int32
* numbertype, int32 *count);

– In Java
• public static native boolean SWattrinfo(int swathID,
String attrname, int[] numbertype, int[] count) throws
HDFEOSException;
The HDF-EOS library
• Interface level
– One class to hold all “native” methods
– One C “interface” library – e.g. jhdfeos4 (dll,
so)
– One-to-one
Hierarchy of objects
dataset
GeoDataset
RasterDataset

HESwathDataset

HEGridDataset

To be implemented

HEGrid
HEGridField

HEGridFieldBand2d

VectorDataset

HEPointDataset
To be implemented
Thread safe vs. efficiency
• Model 1: Access & close
• Model 2: Open – access – close
HEGridDataset

HEGridDataset

HEGrid

HEGrid2

HEGridField

HEGridField2

HEGridFieldBand2d

HEGridFieldBand2d2

Model 1

Model 2
Applications (1)
• Web services
– Conversion
http://laits.gmu.edu:18080/DataMining/HDFEOS2ARFF?WSDL
– Conversion
http://laits.gmu.edu:18080/DataMining/ARFF2HDFEOS2?WSDL
– Training
http://laits.gmu.edu:18080/DataMining/LogisticRegressionTrainer
?WSDL
– Classification
http://laits.gmu.edu:18080/DataMining/LogisticRegressionClassif
ier?WSDL
– Regression
http://laits.gmu.edu:18080/DataMining/LogisticRegressor?WSDL

• Test pages
http://laits.gmu.edu:18080/DataMiningClientWeb/
Applications (2)
Limitations to the JNI approach
• Limitations
– JNI is not an easy API;
– Invocation: only applications and signed applets can invoke the
JNI;
– Portability: No
• compile different set of libraries and dynamically load

– Memory management: no garbage collection
• Careful to manage memory and exception in C
• Timely re-start Tomcat server (not a good solution)

– Debugging difficulty: error checking is a MUST or it has the
potential
• to crash the server
• to left dead thread
• to cause memory leak
Conclusions
• The library is available at
– http://laits.gmu.edu/~gyu/HDFEOS/
Future work
• Continue on updating the interface
• Work on HDF5-EOS
• Refine the object with considerations of
performance and usability
References
• JNI specification
http://java.sun.com/j2se/1.5.0/docs/guide/j
ni/spec/jniTOC.html
• Java Native Interface: Programmer’s
Guide and Specification
http://java.sun.com/docs/books/jni/
Acknowledgements
• The work was supported partially with grants from the
NASA Earth Science Data and Information System
Project (ESDISP) (NCC5-645, PI: Dr. Liping Di), NASA
Earth Science Technology Office (ESTO) (NAG-13409,
PI: Dr. Liping Di), NASA REASoN program
(NNG04GE61A, PI: Dr. Liping Di), and National
Geospatial-intelligence Agency (NGA) University
Research Initiative (NURI) (HM1582-04-1-2021, PI: Dr.
Liping Di).
• Thanks to Dr. Peisheng Zhao, Dr. Aijun Chen, Dr. Yuqi
Bai, Mr. Yaxing Wei, and other colleagues at Center for
Spatial Information Science and System, George Mason
University, for their inputs and contributions.

More Related Content

Similar to HDF-EOS Java Application Programming Interfaces

Arabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionArabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionJasonRafeMiller
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20Phil Wilkins
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovSvetlin Nakov
 
Enhancing Domain Specific Language Implementations Through Ontology
Enhancing Domain Specific Language Implementations Through OntologyEnhancing Domain Specific Language Implementations Through Ontology
Enhancing Domain Specific Language Implementations Through OntologyChunhua Liao
 
Alive and Well with Java 8
Alive and Well with Java 8Alive and Well with Java 8
Alive and Well with Java 8Adam Pelsoczi
 
Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...Ari Jolma
 
Building collaborative workflows for scientific data
Building collaborative workflows for scientific dataBuilding collaborative workflows for scientific data
Building collaborative workflows for scientific dataBruno Vieira
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the CloudJim Driscoll
 
Java jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mJava jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mSteve Elliott
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 
State of GeoServer 2.10
State of GeoServer 2.10State of GeoServer 2.10
State of GeoServer 2.10Jody Garnett
 
Golang workshop - Mindbowser
Golang workshop - MindbowserGolang workshop - Mindbowser
Golang workshop - MindbowserMindbowser Inc
 
HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)Kevin Gill
 
Hadoop 101 for bioinformaticians
Hadoop 101 for bioinformaticiansHadoop 101 for bioinformaticians
Hadoop 101 for bioinformaticiansattilacsordas
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docxhoney725342
 
Porting VisualWorks code to Pharo
Porting VisualWorks code to PharoPorting VisualWorks code to Pharo
Porting VisualWorks code to PharoESUG
 

Similar to HDF-EOS Java Application Programming Interfaces (20)

Arabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, IntroductionArabidopsis Information Portal, Developer Workshop 2014, Introduction
Arabidopsis Information Portal, Developer Workshop 2014, Introduction
 
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
gRPC, GraphQL, REST - Which API Tech to use - API Conference Berlin oct 20
 
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin NakovJava 7 - New Features - by Mihail Stoynov and Svetlin Nakov
Java 7 - New Features - by Mihail Stoynov and Svetlin Nakov
 
Enhancing Domain Specific Language Implementations Through Ontology
Enhancing Domain Specific Language Implementations Through OntologyEnhancing Domain Specific Language Implementations Through Ontology
Enhancing Domain Specific Language Implementations Through Ontology
 
Android networking-2
Android networking-2Android networking-2
Android networking-2
 
Grails 101
Grails 101Grails 101
Grails 101
 
NetCDF and HDF5
NetCDF and HDF5NetCDF and HDF5
NetCDF and HDF5
 
Alive and Well with Java 8
Alive and Well with Java 8Alive and Well with Java 8
Alive and Well with Java 8
 
Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...Geospatial web services using little-known GDAL features and modern Perl midd...
Geospatial web services using little-known GDAL features and modern Perl midd...
 
Building collaborative workflows for scientific data
Building collaborative workflows for scientific dataBuilding collaborative workflows for scientific data
Building collaborative workflows for scientific data
 
Groovy In the Cloud
Groovy In the CloudGroovy In the Cloud
Groovy In the Cloud
 
Java jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mJava jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3m
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
State of GeoServer 2.10
State of GeoServer 2.10State of GeoServer 2.10
State of GeoServer 2.10
 
Golang workshop - Mindbowser
Golang workshop - MindbowserGolang workshop - Mindbowser
Golang workshop - Mindbowser
 
HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)HTML5 - The Python Angle (PyCon Ireland 2010)
HTML5 - The Python Angle (PyCon Ireland 2010)
 
Hadoop 101 for bioinformaticians
Hadoop 101 for bioinformaticiansHadoop 101 for bioinformaticians
Hadoop 101 for bioinformaticians
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docx
 
01 java intro
01 java intro01 java intro
01 java intro
 
Porting VisualWorks code to Pharo
Porting VisualWorks code to PharoPorting VisualWorks code to Pharo
Porting VisualWorks code to Pharo
 

More from The HDF-EOS Tools and Information Center

STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...The HDF-EOS Tools and Information Center
 

More from The HDF-EOS Tools and Information Center (20)

Cloud-Optimized HDF5 Files
Cloud-Optimized HDF5 FilesCloud-Optimized HDF5 Files
Cloud-Optimized HDF5 Files
 
Accessing HDF5 data in the cloud with HSDS
Accessing HDF5 data in the cloud with HSDSAccessing HDF5 data in the cloud with HSDS
Accessing HDF5 data in the cloud with HSDS
 
The State of HDF
The State of HDFThe State of HDF
The State of HDF
 
Highly Scalable Data Service (HSDS) Performance Features
Highly Scalable Data Service (HSDS) Performance FeaturesHighly Scalable Data Service (HSDS) Performance Features
Highly Scalable Data Service (HSDS) Performance Features
 
Creating Cloud-Optimized HDF5 Files
Creating Cloud-Optimized HDF5 FilesCreating Cloud-Optimized HDF5 Files
Creating Cloud-Optimized HDF5 Files
 
HDF5 OPeNDAP Handler Updates, and Performance Discussion
HDF5 OPeNDAP Handler Updates, and Performance DiscussionHDF5 OPeNDAP Handler Updates, and Performance Discussion
HDF5 OPeNDAP Handler Updates, and Performance Discussion
 
Hyrax: Serving Data from S3
Hyrax: Serving Data from S3Hyrax: Serving Data from S3
Hyrax: Serving Data from S3
 
Accessing Cloud Data and Services Using EDL, Pydap, MATLAB
Accessing Cloud Data and Services Using EDL, Pydap, MATLABAccessing Cloud Data and Services Using EDL, Pydap, MATLAB
Accessing Cloud Data and Services Using EDL, Pydap, MATLAB
 
HDF - Current status and Future Directions
HDF - Current status and Future DirectionsHDF - Current status and Future Directions
HDF - Current status and Future Directions
 
HDFEOS.org User Analsys, Updates, and Future
HDFEOS.org User Analsys, Updates, and FutureHDFEOS.org User Analsys, Updates, and Future
HDFEOS.org User Analsys, Updates, and Future
 
HDF - Current status and Future Directions
HDF - Current status and Future Directions HDF - Current status and Future Directions
HDF - Current status and Future Directions
 
H5Coro: The Cloud-Optimized Read-Only Library
H5Coro: The Cloud-Optimized Read-Only LibraryH5Coro: The Cloud-Optimized Read-Only Library
H5Coro: The Cloud-Optimized Read-Only Library
 
MATLAB Modernization on HDF5 1.10
MATLAB Modernization on HDF5 1.10MATLAB Modernization on HDF5 1.10
MATLAB Modernization on HDF5 1.10
 
HDF for the Cloud - Serverless HDF
HDF for the Cloud - Serverless HDFHDF for the Cloud - Serverless HDF
HDF for the Cloud - Serverless HDF
 
HDF5 <-> Zarr
HDF5 <-> ZarrHDF5 <-> Zarr
HDF5 <-> Zarr
 
HDF for the Cloud - New HDF Server Features
HDF for the Cloud - New HDF Server FeaturesHDF for the Cloud - New HDF Server Features
HDF for the Cloud - New HDF Server Features
 
Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3
Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3
Apache Drill and Unidata THREDDS Data Server for NASA HDF-EOS on S3
 
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
STARE-PODS: A Versatile Data Store Leveraging the HDF Virtual Object Layer fo...
 
HDF5 and Ecosystem: What Is New?
HDF5 and Ecosystem: What Is New?HDF5 and Ecosystem: What Is New?
HDF5 and Ecosystem: What Is New?
 
HDF5 Roadmap 2019-2020
HDF5 Roadmap 2019-2020HDF5 Roadmap 2019-2020
HDF5 Roadmap 2019-2020
 

Recently uploaded

Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...FIDO Alliance
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...FIDO Alliance
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty SecureFemke de Vroome
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsUXDXConf
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfFIDO Alliance
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationZilliz
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKUXDXConf
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxJennifer Lim
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024TopCSSGallery
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024Stephanie Beckett
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsStefano
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka DoktorováCzechDreamin
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 

Recently uploaded (20)

Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
ECS 2024 Teams Premium - Pretty Secure
ECS 2024   Teams Premium - Pretty SecureECS 2024   Teams Premium - Pretty Secure
ECS 2024 Teams Premium - Pretty Secure
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Strategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering TeamsStrategic AI Integration in Engineering Teams
Strategic AI Integration in Engineering Teams
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdfWhere to Learn More About FDO _ Richard at FIDO Alliance.pdf
Where to Learn More About FDO _ Richard at FIDO Alliance.pdf
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
Introduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG EvaluationIntroduction to Open Source RAG and RAG Evaluation
Introduction to Open Source RAG and RAG Evaluation
 
Connecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAKConnecting the Dots in Product Design at KAYAK
Connecting the Dots in Product Design at KAYAK
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024Top 10 Symfony Development Companies 2024
Top 10 Symfony Development Companies 2024
 
What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024What's New in Teams Calling, Meetings and Devices April 2024
What's New in Teams Calling, Meetings and Devices April 2024
 
PLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. StartupsPLAI - Acceleration Program for Generative A.I. Startups
PLAI - Acceleration Program for Generative A.I. Startups
 
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová10 Differences between Sales Cloud and CPQ, Blanka Doktorová
10 Differences between Sales Cloud and CPQ, Blanka Doktorová
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 

HDF-EOS Java Application Programming Interfaces

  • 1. HDF-EOS Java Application Programming Interfaces Genong (Eugene) Yu, Ph.D. Research associate Liping Di, Ph.D. Professor & Director of CSISS {gyu, ldi}@gmu.edu November 28-30, 2006 HDF and HDF-EOS Workshop X, Upper Marlboro, MD
  • 2. Outline • Why Java API interfaces? • Java API interfaces – Variable consideration • • • • Java Object wrap-up Performance consideration Applications Problem – Memory management
  • 3. Demand • Distribution systems over the Web – Java-based server • Apache Tomcat • Manipulation of data for the Web application – Re-projection service – Classification service – Re-format service
  • 4. Bridging Java Program and C/C++ library The Problem HDF-EOS HDF-EOS HDF-EOS HDF-EOS HDF-EOS HDF-EOS HDF JNI API • HDF-EOS library – in C/C++ library • All functions to manipulate grid and point are written in C • Primer for HDF-EOS is for C • HDF JNI libraries are available • Possible approach Java Reader • Rewrite the program in Java WEB APPLICATION • Pros: better for Java environment The Solution HDF-EOS HDF-EOS HDF-EOS HDF-EOS HDF-EOS HDF-EOS HDF-EOS / HDF JNI API Java Reader WEB APPLICATION • Cons: enormous work and need to keep track of revision • Call the library directly through JNI • Pros: manageable work and efficient re-use • Cons: memory management, debugging
  • 5. How JNI works (1) • Java interface – public static native int GDopen(String filename, int access) throws HDFEOSException; – Load library • System.loadLibrary("jhdfeos4"); • Compile the above code – javac HDFEOSLibrary.java • Create header File – javah -jni edu
  • 6. How JNI works (2) • Create the library in C/C++ – Template • JNIEXPORT void JNICALL Java_ClassName_MethodName (JNIEnv *env, jobject obj) { • //Implement Native Method Here • } – Example • JNIEXPORT jint JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_SWdupregion • (JNIEnv *env, jclass class, jint oldregionID) • { • int32 regionID; • regionID=SWdupregion((int32)oldregionID); • return (jint)regionID; • }
  • 7. Tasks to enable the JNI • To access a C library from a Java program, four tasks must be completed: – Declare appropriate “native” methods in Java classes – Write “interface” code for each native method to implement the JNI C or C++ standard – compile the JNI “interface” (C or C++) to create a JNI library – deploy the Java classes and the JNI library on the system
  • 8. Mapping types (1) • Interchangeable types Native type (C/C++) Java Language Description Type HDF/HDFEOS bool jboolean Unsigned 8 bits intn, uint8 byte jbyte Signed 8 bits int8 char jchar Unsigned 16 bits uint16 short jshort Signed 16 bits int16 long jint Signed 32 bits int32 long long jlong Signed 64 bits int64 Float jfloat Float 32 bits float32 Double jdouble Float 64 bits float64
  • 9. Mapping types (2) • String – Wrong • JNIEXPORT jint JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_SWcreate • (JNIEnv *env, jclass class, jint file_id, jstring swath_name) • { • return SWcreate( (int32)file_id, (char *) swath_name); • } – Correct • JNIEXPORT jint JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_SWcreate • (JNIEnv *env, jclass class, jint file_id, jstring swath_name) • { • char *s_filename; • int32 swath_id; • s_filename = (char *) (*env)->GetStringUTFChars( env, swath_name, 0); • swath_id = SWcreate( (int32)file_id, (char *)s_filename ); • (*env)->ReleaseStringUTFChars(env, swath_name, s_filename ); • return (jint)swath_id; • }
  • 10. Mapping types (3) • Array – – Wrong • JNIEXPORT jboolean JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_GDorigininfo • (JNIEnv *env, jclass class, jint gridID, jintArray origincode) • { • int32 status; • status= GDorigininfo((int32)gridID,(int32 *)origincode); • if (status==-1) return JNI_FALSE; • else return JNI_TRUE; • } Correct • • • • • • • • • • • JNIEXPORT jboolean JNICALL Java_edu_gmu_laits_hdfeos_HDFEOSLibrary_GDorigininfo (JNIEnv *env, jclass class, jint gridID, jintArray origincode) { int32 *i_origincode; int32 status; i_origincode=(int32 *)(*env)->GetIntArrayElements(env,origincode,0); status=GDorigininfo((int32)gridID,i_origincode); (*env)->ReleaseIntArrayElements(env,origincode,(jint *)i_origincode,0); if (status==-1) return JNI_FALSE; else return JNI_TRUE; }
  • 11. Mapping types (4) • Pointer – In C • intn SWattrinfo(int32 swathID, char *attrname, int32 * numbertype, int32 *count); – In Java • public static native boolean SWattrinfo(int swathID, String attrname, int[] numbertype, int[] count) throws HDFEOSException;
  • 12. The HDF-EOS library • Interface level – One class to hold all “native” methods – One C “interface” library – e.g. jhdfeos4 (dll, so) – One-to-one
  • 13. Hierarchy of objects dataset GeoDataset RasterDataset HESwathDataset HEGridDataset To be implemented HEGrid HEGridField HEGridFieldBand2d VectorDataset HEPointDataset To be implemented
  • 14. Thread safe vs. efficiency • Model 1: Access & close • Model 2: Open – access – close HEGridDataset HEGridDataset HEGrid HEGrid2 HEGridField HEGridField2 HEGridFieldBand2d HEGridFieldBand2d2 Model 1 Model 2
  • 15. Applications (1) • Web services – Conversion http://laits.gmu.edu:18080/DataMining/HDFEOS2ARFF?WSDL – Conversion http://laits.gmu.edu:18080/DataMining/ARFF2HDFEOS2?WSDL – Training http://laits.gmu.edu:18080/DataMining/LogisticRegressionTrainer ?WSDL – Classification http://laits.gmu.edu:18080/DataMining/LogisticRegressionClassif ier?WSDL – Regression http://laits.gmu.edu:18080/DataMining/LogisticRegressor?WSDL • Test pages http://laits.gmu.edu:18080/DataMiningClientWeb/
  • 17. Limitations to the JNI approach • Limitations – JNI is not an easy API; – Invocation: only applications and signed applets can invoke the JNI; – Portability: No • compile different set of libraries and dynamically load – Memory management: no garbage collection • Careful to manage memory and exception in C • Timely re-start Tomcat server (not a good solution) – Debugging difficulty: error checking is a MUST or it has the potential • to crash the server • to left dead thread • to cause memory leak
  • 18. Conclusions • The library is available at – http://laits.gmu.edu/~gyu/HDFEOS/
  • 19. Future work • Continue on updating the interface • Work on HDF5-EOS • Refine the object with considerations of performance and usability
  • 20. References • JNI specification http://java.sun.com/j2se/1.5.0/docs/guide/j ni/spec/jniTOC.html • Java Native Interface: Programmer’s Guide and Specification http://java.sun.com/docs/books/jni/
  • 21. Acknowledgements • The work was supported partially with grants from the NASA Earth Science Data and Information System Project (ESDISP) (NCC5-645, PI: Dr. Liping Di), NASA Earth Science Technology Office (ESTO) (NAG-13409, PI: Dr. Liping Di), NASA REASoN program (NNG04GE61A, PI: Dr. Liping Di), and National Geospatial-intelligence Agency (NGA) University Research Initiative (NURI) (HM1582-04-1-2021, PI: Dr. Liping Di). • Thanks to Dr. Peisheng Zhao, Dr. Aijun Chen, Dr. Yuqi Bai, Mr. Yaxing Wei, and other colleagues at Center for Spatial Information Science and System, George Mason University, for their inputs and contributions.