summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2019-04-29 22:51:55 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2019-04-29 22:51:55 (GMT)
commit08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e (patch)
tree22cf73b009673a79dcb0bf892e804cc38493e0dd /java
parent92f30fd3d99b5e278de7353b87d73e29e4ecf4b2 (diff)
parent3d904f8141f246f3bca6e58222a6569b7b0e005f (diff)
downloadhdf5-08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e.zip
hdf5-08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e.tar.gz
hdf5-08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e.tar.bz2
Merge remote-tracking branch 'origin/develop' into merge_hyperslab_update_01
Diffstat (limited to 'java')
-rw-r--r--java/src/hdf/hdf5lib/H5.java13
-rw-r--r--java/src/jni/h5fImp.c24
-rw-r--r--java/src/jni/h5fImp.h9
-rw-r--r--java/src/jni/h5sImp.c4
-rw-r--r--java/test/TestH5F.java110
-rw-r--r--java/test/testfiles/JUnit-TestH5F.txt4
6 files changed, 111 insertions, 53 deletions
diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java
index d107ad8..e874732 100644
--- a/java/src/hdf/hdf5lib/H5.java
+++ b/java/src/hdf/hdf5lib/H5.java
@@ -2968,6 +2968,19 @@ public class H5 implements java.io.Serializable {
public synchronized static native int H5Fget_intent(long file_id) throws HDF5LibraryException;
/**
+ * H5Fget_fileno retrieves the "file number" for an open file.
+ *
+ * @param file_id
+ * IN: File identifier for a currently-open HDF5 file
+ *
+ * @return the unique file number for the file.
+ *
+ * @exception HDF5LibraryException
+ * - Error from the HDF-5 Library.
+ **/
+ public synchronized static native long H5Fget_fileno(long file_id) throws HDF5LibraryException;
+
+ /**
* H5Fget_mdc_hit_rate queries the metadata cache of the target file to obtain its hit rate (cache hits / (cache
* hits + cache misses)) since the last time hit rate statistics were reset.
*
diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c
index d145c6a..80567d9 100644
--- a/java/src/jni/h5fImp.c
+++ b/java/src/jni/h5fImp.c
@@ -260,11 +260,11 @@ done:
*/
JNIEXPORT jint JNICALL
Java_hdf_hdf5lib_H5_H5Fget_1intent
- (JNIEnv *env, jclass cls, jlong file_id)
+ (JNIEnv *env, jclass clss, jlong file_id)
{
unsigned intent = 0;
- UNUSED(cls);
+ UNUSED(clss);
if (H5Fget_intent((hid_t)file_id, &intent) < 0)
H5_LIBRARY_ERROR(ENVONLY);
@@ -275,6 +275,26 @@ done:
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Fget_fileno
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5Fget_1fileno
+ (JNIEnv *env, jclass clss, jlong file_id)
+{
+ unsigned long fileno = 0;
+
+ UNUSED(clss);
+
+ if (H5Fget_fileno((hid_t)file_id, &fileno) < 0)
+ H5_LIBRARY_ERROR(ENVONLY);
+
+done:
+ return (jlong)fileno;
+} /* end Java_hdf_hdf5lib_H5_H5Fget_1fileno */
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Fclose
* Signature: (J)I
*/
diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h
index 410a249..fc02c76 100644
--- a/java/src/jni/h5fImp.h
+++ b/java/src/jni/h5fImp.h
@@ -104,6 +104,15 @@ Java_hdf_hdf5lib_H5_H5Fget_1intent
/*
* Class: hdf_hdf5lib_H5
+ * Method: H5Fget_fileno
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL
+Java_hdf_hdf5lib_H5_H5Fget_1fileno
+ (JNIEnv*, jclass, jlong);
+
+/*
+ * Class: hdf_hdf5lib_H5
* Method: H5Fclose
* Signature: (J)I
*/
diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c
index a91dab2..d8110a1 100644
--- a/java/src/jni/h5sImp.c
+++ b/java/src/jni/h5sImp.c
@@ -1141,7 +1141,7 @@ Java_hdf_hdf5lib_H5_H5Sencode
if (obj_id < 0)
H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: invalid object ID");
- if ((status = H5Sencode(obj_id, NULL, &buf_size)) < 0)
+ if ((status = H5Sencode2(obj_id, NULL, &buf_size, H5P_DEFAULT)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (buf_size == 0)
@@ -1150,7 +1150,7 @@ Java_hdf_hdf5lib_H5_H5Sencode
if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size)))
H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer");
- if ((status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size)) < 0)
+ if ((status = H5Sencode2((hid_t) obj_id, bufPtr, &buf_size, H5P_DEFAULT)) < 0)
H5_LIBRARY_ERROR(ENVONLY);
if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize) buf_size)))
diff --git a/java/test/TestH5F.java b/java/test/TestH5F.java
index e4f9a30..869b45c 100644
--- a/java/test/TestH5F.java
+++ b/java/test/TestH5F.java
@@ -14,6 +14,7 @@
package test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -32,6 +33,7 @@ import org.junit.rules.TestName;
public class TestH5F {
@Rule public TestName testname = new TestName();
private static final String H5_FILE = "testF.h5";
+ private static final String H5_FILE2 = "testF2.h5";
private static final int COUNT_OBJ_FILE = 1;
private static final int COUNT_OBJ_DATASET = 0;
@@ -94,28 +96,12 @@ public class TestH5F {
@Test(expected = HDF5LibraryException.class)
public void testH5Fget_create_plist_closed() throws Throwable {
- long fid = -1;
-
if (H5fid > 0) {
try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
- H5fid = -1;
- }
-
- try {
- fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR,
- HDF5Constants.H5P_DEFAULT);
- }
- catch (Throwable err) {
- fail("H5.H5Fopen: " + err);
- }
- try {
- H5.H5Fclose(fid);
- }
- catch (Exception ex) {
}
// it should fail because the file was closed.
- H5.H5Fget_create_plist(fid);
+ H5.H5Fget_create_plist(H5fid);
}
@Test
@@ -134,34 +120,17 @@ public class TestH5F {
@Test(expected = HDF5LibraryException.class)
public void testH5Fget_access_plist_closed() throws Throwable {
- long fid = -1;
-
if (H5fid > 0) {
try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
- H5fid = -1;
- }
-
- try {
- fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR,
- HDF5Constants.H5P_DEFAULT);
- }
- catch (Throwable err) {
- fail("H5.H5Fopen: " + err);
- }
- try {
- H5.H5Fclose(fid);
- }
- catch (Exception ex) {
}
// it should fail because the file was closed.
- H5.H5Fget_access_plist(fid);
+ H5.H5Fget_access_plist(H5fid);
}
@Test
public void testH5Fget_intent_rdwr() {
int intent = 0;
- long fid = -1;
if (H5fid > 0) {
try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
@@ -169,31 +138,24 @@ public class TestH5F {
}
try {
- fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR,
+ H5fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDWR,
HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
fail("H5.H5Fopen: " + err);
}
try {
- intent = H5.H5Fget_intent(fid);
+ intent = H5.H5Fget_intent(H5fid);
}
catch (Throwable err) {
fail("H5.H5Fget_intent: " + err);
}
assertEquals(HDF5Constants.H5F_ACC_RDWR, intent);
-
- try {
- H5.H5Fclose(fid);
- }
- catch (Exception ex) {
- }
}
@Test
public void testH5Fget_intent_rdonly() {
int intent = 0;
- long fid = -1;
if (H5fid > 0) {
try {H5.H5Fclose(H5fid);} catch (Exception ex) {}
@@ -201,24 +163,76 @@ public class TestH5F {
}
try {
- fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDONLY,
+ H5fid = H5.H5Fopen(H5_FILE, HDF5Constants.H5F_ACC_RDONLY,
HDF5Constants.H5P_DEFAULT);
}
catch (Throwable err) {
fail("H5.H5Fopen: " + err);
}
try {
- intent = H5.H5Fget_intent(fid);
+ intent = H5.H5Fget_intent(H5fid);
}
catch (Throwable err) {
fail("H5.H5Fget_intent: " + err);
}
assertEquals(HDF5Constants.H5F_ACC_RDONLY, intent);
+ }
+
+ @Test
+ public void testH5Fget_fileno_same() {
+ long fileno1 = 0;
+ long fileno2 = 0;
+ long fid1 = -1;
+ long fid2 = -1;
try {
- H5.H5Fclose(fid);
+ fid1 = H5.H5Fcreate(H5_FILE2, HDF5Constants.H5F_ACC_TRUNC,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ H5.H5Fflush(fid1, HDF5Constants.H5F_SCOPE_LOCAL);
+ assertTrue("H5Fcreate failed", fid1 > 0);
+ fid2 = H5.H5Fopen(H5_FILE2, HDF5Constants.H5F_ACC_RDWR,
+ HDF5Constants.H5P_DEFAULT);
+ assertTrue("H5Fopen failed", fid2 > 0);
+ fileno1 = H5.H5Fget_fileno(fid1);
+ assertTrue("H5Fget_fileno1="+fileno1, fileno1 > 0);
+ fileno2 = H5.H5Fget_fileno(fid2);
+ assertTrue("H5Fget_fileno2="+fileno2, fileno2 > 0);
+
+ assertEquals("fileno1["+fileno1+"]!=fileno2["+fileno2+"]", fileno1, fileno2);
+ }
+ catch (Throwable err) {
+ fail("testH5Fget_fileno_same: " + err);
+ }
+ finally {
+ H5.H5Fclose(fid1);
+ H5.H5Fclose(fid2);
+ }
+ }
+
+ @Test
+ public void testH5Fget_fileno_diff() {
+ long fileno1 = 0;
+ long fileno2 = 0;
+ long fid2 = -1;
+
+ try {
+ fid2 = H5.H5Fcreate(H5_FILE2, HDF5Constants.H5F_ACC_TRUNC,
+ HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
+ H5.H5Fflush(fid2, HDF5Constants.H5F_SCOPE_LOCAL);
+ assertTrue("H5Fcreate failed", fid2 > 0);
+
+ fileno1 = H5.H5Fget_fileno(H5fid);
+ assertTrue("H5Fget_fileno1="+fileno1, fileno1 > 0);
+ fileno2 = H5.H5Fget_fileno(fid2);
+ assertTrue("H5Fget_fileno2="+fileno2, fileno2 > 0);
+
+ assertNotEquals("fileno1["+fileno1+"]==fileno2["+fileno2+"]", fileno1, fileno2);
+ }
+ catch (Throwable err) {
+ fail("testH5Fget_fileno_diff: " + err);
}
- catch (Exception ex) {
+ finally {
+ H5.H5Fclose(fid2);
}
}
diff --git a/java/test/testfiles/JUnit-TestH5F.txt b/java/test/testfiles/JUnit-TestH5F.txt
index 16a423e..f79ac40 100644
--- a/java/test/testfiles/JUnit-TestH5F.txt
+++ b/java/test/testfiles/JUnit-TestH5F.txt
@@ -1,5 +1,7 @@
JUnit version 4.11
.testH5Fget_access_plist
+.testH5Fget_fileno_diff
+.testH5Fget_fileno_same
.testH5Fget_obj_ids
.testH5Fget_intent_rdwr
.testH5Fget_access_plist_closed
@@ -10,5 +12,5 @@ JUnit version 4.11
Time: XXXX
-OK (8 tests)
+OK (10 tests)