mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
Refactor JNI translate functions to a recursive switch on datatype (#2232)
This commit is contained in:
+159
-25
@@ -1415,7 +1415,7 @@ public class TestH5A {
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5AVLwr: ", attr_int_id >= 0);
|
||||
|
||||
H5.H5Awrite(attr_int_id, atype_int_id, vl_int_data);
|
||||
H5.H5AwriteVL(attr_int_id, atype_int_id, vl_int_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (attr_int_id > 0)
|
||||
@@ -1472,7 +1472,7 @@ public class TestH5A {
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5AVLwr: ", attr_dbl_id >= 0);
|
||||
|
||||
H5.H5Awrite(attr_dbl_id, atype_dbl_id, vl_dbl_data);
|
||||
H5.H5AwriteVL(attr_dbl_id, atype_dbl_id, vl_dbl_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (attr_dbl_id > 0)
|
||||
@@ -1501,9 +1501,8 @@ public class TestH5A {
|
||||
|
||||
H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL);
|
||||
|
||||
for (int j = 0; j < dims.length; j++) {
|
||||
for (int j = 0; j < dims.length; j++)
|
||||
lsize *= dims[j];
|
||||
}
|
||||
|
||||
// Read Integer data
|
||||
ArrayList[] vl_readbuf = new ArrayList[4];
|
||||
@@ -1511,7 +1510,7 @@ public class TestH5A {
|
||||
vl_readbuf[j] = new ArrayList<Integer>();
|
||||
|
||||
try {
|
||||
H5.H5Aread(attr_int_id, atype_int_id, vl_readbuf);
|
||||
H5.H5AreadVL(attr_int_id, atype_int_id, vl_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -1531,7 +1530,7 @@ public class TestH5A {
|
||||
vl_readbuf[j] = new ArrayList<Double>();
|
||||
|
||||
try {
|
||||
H5.H5Aread(attr_dbl_id, atype_dbl_id, vl_readbuf);
|
||||
H5.H5AreadVL(attr_dbl_id, atype_dbl_id, vl_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -1628,6 +1627,12 @@ public class TestH5A {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
if (atype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(atype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5AVLwrVL: " + err);
|
||||
}
|
||||
@@ -1639,7 +1644,7 @@ public class TestH5A {
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5AVLwrVL: ", attr_int_id >= 0);
|
||||
|
||||
H5.H5Awrite(attr_int_id, base_atype_int_id, base_vl_int_data);
|
||||
H5.H5AwriteVL(attr_int_id, base_atype_int_id, base_vl_int_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (attr_int_id > 0)
|
||||
@@ -1677,32 +1682,47 @@ public class TestH5A {
|
||||
base_vl_readbuf[j] = new ArrayList<ArrayList<Integer>>();
|
||||
|
||||
try {
|
||||
H5.H5Aread(attr_int_id, base_atype_int_id, base_vl_readbuf);
|
||||
H5.H5AreadVL(attr_int_id, base_atype_int_id, base_vl_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
ArrayList vl_readbuf = (ArrayList)base_vl_readbuf[0];
|
||||
assertTrue("vl_readbuf exists", vl_readbuf != null);
|
||||
assertTrue("vl_readbuf has size " + vl_readbuf.size(), vl_readbuf.size() > 0);
|
||||
ArrayList vl_readbuf_int = (ArrayList)vl_readbuf.get(0);
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(0),
|
||||
ArrayList<ArrayList<Integer>> vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[0];
|
||||
assertTrue("vl_readbuf 0 exists", vl_readbuf != null);
|
||||
ArrayList<Integer> vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(0));
|
||||
/*
|
||||
* System.out.println(); System.out.println("vl_readbuf: " + vl_readbuf);
|
||||
* System.out.println("vl_readbuf_int: " + vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testHADVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[0].get(0).equals(vl_readbuf_int.get(0)));
|
||||
|
||||
vl_readbuf = (ArrayList)base_vl_readbuf[1];
|
||||
vl_readbuf_int = (ArrayList)vl_readbuf.get(1);
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[1].get(0).equals(vl_readbuf_int.get(0)));
|
||||
vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[1];
|
||||
vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(1));
|
||||
/*
|
||||
* System.out.println("vl_readbuf: " + vl_readbuf); System.out.println("vl_readbuf_int: " +
|
||||
* vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(1),
|
||||
vl_int_data[1].get(1).equals(vl_readbuf_int.get(1)));
|
||||
|
||||
vl_readbuf = (ArrayList)base_vl_readbuf[2];
|
||||
vl_readbuf_int = (ArrayList)vl_readbuf.get(2);
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[2].get(0).equals(vl_readbuf_int.get(0)));
|
||||
vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[2];
|
||||
vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(2));
|
||||
/*
|
||||
* System.out.println("vl_readbuf: " + vl_readbuf); System.out.println("vl_readbuf_int: " +
|
||||
* vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(2),
|
||||
vl_int_data[2].get(2).equals(vl_readbuf_int.get(2)));
|
||||
|
||||
vl_readbuf = (ArrayList)base_vl_readbuf[3];
|
||||
vl_readbuf_int = (ArrayList)vl_readbuf.get(3);
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[3].get(0).equals(vl_readbuf_int.get(0)));
|
||||
vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[3];
|
||||
vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(3));
|
||||
/*
|
||||
* System.out.println("vl_readbuf: " + vl_readbuf); System.out.println("vl_readbuf_int: " +
|
||||
* vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5AVLwrVL:" + vl_readbuf_int.get(3),
|
||||
vl_int_data[3].get(3).equals(vl_readbuf_int.get(3)));
|
||||
}
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
@@ -1729,4 +1749,118 @@ public class TestH5A {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testH5AArraywr()
|
||||
{
|
||||
String att_int_name = "ArrayIntdata";
|
||||
long att_int_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long atype_int_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long aspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {4};
|
||||
long lsize = 1;
|
||||
|
||||
ArrayList[] arr_int_data = new ArrayList[4];
|
||||
try {
|
||||
// Write Integer data
|
||||
arr_int_data[0] = new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4));
|
||||
arr_int_data[1] = new ArrayList<Integer>(Arrays.asList(2, 3, 4, 5));
|
||||
arr_int_data[2] = new ArrayList<Integer>(Arrays.asList(4, 5, 6, 7));
|
||||
arr_int_data[3] = new ArrayList<Integer>(Arrays.asList(7, 8, 9, 10));
|
||||
Class dataClass = arr_int_data.getClass();
|
||||
assertTrue("testH5AArraywr.getClass: " + dataClass, dataClass.isArray());
|
||||
|
||||
try {
|
||||
atype_int_id = H5.H5Tarray_create(HDF5Constants.H5T_STD_U32LE, 1, dims);
|
||||
assertTrue("testH5AArraywr.H5Tarray_create: ", atype_int_id >= 0);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (atype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(atype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5AArraywr: " + err);
|
||||
}
|
||||
|
||||
try {
|
||||
aspace_id = H5.H5Screate_simple(1, dims, null);
|
||||
assertTrue(aspace_id > 0);
|
||||
att_int_id = H5.H5Acreate(H5did, att_int_name, atype_int_id, aspace_id,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5AVLwr: ", att_int_id >= 0);
|
||||
|
||||
H5.H5AwriteVL(att_int_id, atype_int_id, arr_int_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (att_int_id > 0)
|
||||
try {
|
||||
H5.H5Aclose(att_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
if (atype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(atype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5AVLwr: " + err);
|
||||
}
|
||||
finally {
|
||||
if (aspace_id > 0)
|
||||
try {
|
||||
H5.H5Sclose(aspace_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL);
|
||||
|
||||
for (int j = 0; j < dims.length; j++)
|
||||
lsize *= dims[j];
|
||||
|
||||
// Read Integer data
|
||||
ArrayList[] arr_readbuf = new ArrayList[4];
|
||||
for (int j = 0; j < lsize; j++)
|
||||
arr_readbuf[j] = new ArrayList<Integer>();
|
||||
|
||||
try {
|
||||
H5.H5AreadVL(att_int_id, atype_int_id, arr_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
assertTrue("testH5AVLwr:" + arr_readbuf[0].get(0),
|
||||
arr_int_data[0].get(0).equals(arr_readbuf[0].get(0)));
|
||||
assertTrue("testH5AVLwr:" + arr_readbuf[1].get(0),
|
||||
arr_int_data[1].get(0).equals(arr_readbuf[1].get(0)));
|
||||
assertTrue("testH5AVLwr:" + arr_readbuf[2].get(0),
|
||||
arr_int_data[2].get(0).equals(arr_readbuf[2].get(0)));
|
||||
assertTrue("testH5AVLwr:" + arr_readbuf[3].get(0),
|
||||
arr_int_data[3].get(0).equals(arr_readbuf[3].get(0)));
|
||||
}
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5AArraywr: " + err);
|
||||
}
|
||||
finally {
|
||||
if (att_int_id > 0)
|
||||
try {
|
||||
H5.H5Aclose(att_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
if (atype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(atype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+162
-29
@@ -31,6 +31,7 @@ import hdf.hdf5lib.exceptions.HDF5LibraryException;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TestName;
|
||||
@@ -964,7 +965,7 @@ public class TestH5D {
|
||||
assertTrue("H5Dvlen_get_buf_size " + vl_size + " == " + str_data_bytes, vl_size == str_data_bytes);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testH5Dvlen_read_default_buffer() throws Throwable
|
||||
{
|
||||
String[] str_data = {"Parting", "is such", "sweet", "sorrow.", "Testing", "one", "two", "three.",
|
||||
@@ -1064,8 +1065,8 @@ public class TestH5D {
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5DVLwr: ", dset_int_id >= 0);
|
||||
|
||||
H5.H5Dwrite(dset_int_id, dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_int_data);
|
||||
H5.H5DwriteVL(dset_int_id, dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_int_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (dset_int_id > 0)
|
||||
@@ -1123,8 +1124,8 @@ public class TestH5D {
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5DVLwr: ", dset_dbl_id >= 0);
|
||||
|
||||
H5.H5Dwrite(dset_dbl_id, dtype_dbl_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_dbl_data);
|
||||
H5.H5DwriteVL(dset_dbl_id, dtype_dbl_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_dbl_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (dset_dbl_id > 0)
|
||||
@@ -1162,8 +1163,8 @@ public class TestH5D {
|
||||
vl_readbuf[j] = new ArrayList<Integer>();
|
||||
|
||||
try {
|
||||
H5.H5Dread(dset_int_id, dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_readbuf);
|
||||
H5.H5DreadVL(dset_int_id, dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -1183,8 +1184,8 @@ public class TestH5D {
|
||||
vl_readbuf[j] = new ArrayList<Double>();
|
||||
|
||||
try {
|
||||
H5.H5Dread(dset_dbl_id, dtype_dbl_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_readbuf);
|
||||
H5.H5DreadVL(dset_dbl_id, dtype_dbl_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, vl_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
@@ -1299,8 +1300,8 @@ public class TestH5D {
|
||||
HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5DVLwrVL: ", dset_int_id >= 0);
|
||||
|
||||
H5.H5Dwrite(dset_int_id, base_dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, base_vl_int_data);
|
||||
H5.H5DwriteVL(dset_int_id, base_dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, base_vl_int_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (dset_int_id > 0)
|
||||
@@ -1338,33 +1339,48 @@ public class TestH5D {
|
||||
base_vl_readbuf[j] = new ArrayList<ArrayList<Integer>>();
|
||||
|
||||
try {
|
||||
H5.H5Dread(dset_int_id, base_dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, base_vl_readbuf);
|
||||
H5.H5DreadVL(dset_int_id, base_dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, base_vl_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
ArrayList vl_readbuf = (ArrayList)base_vl_readbuf[0];
|
||||
assertTrue("vl_readbuf exists", vl_readbuf != null);
|
||||
assertTrue("vl_readbuf has size " + vl_readbuf.size(), vl_readbuf.size() > 0);
|
||||
ArrayList vl_readbuf_int = (ArrayList)vl_readbuf.get(0);
|
||||
ArrayList<ArrayList<Integer>> vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[0];
|
||||
assertTrue("vl_readbuf 0 exists", vl_readbuf != null);
|
||||
ArrayList<Integer> vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(0));
|
||||
/*
|
||||
* System.out.println(); System.out.println("vl_readbuf: " + vl_readbuf);
|
||||
* System.out.println("vl_readbuf_int: " + vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[0].get(0).equals(vl_readbuf_int.get(0)));
|
||||
|
||||
vl_readbuf = (ArrayList)base_vl_readbuf[1];
|
||||
vl_readbuf_int = (ArrayList)vl_readbuf.get(1);
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[1].get(0).equals(vl_readbuf_int.get(0)));
|
||||
vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[1];
|
||||
vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(1));
|
||||
/*
|
||||
* System.out.println("vl_readbuf: " + vl_readbuf); System.out.println("vl_readbuf_int: " +
|
||||
* vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(1),
|
||||
vl_int_data[1].get(1).equals(vl_readbuf_int.get(1)));
|
||||
|
||||
vl_readbuf = (ArrayList)base_vl_readbuf[2];
|
||||
vl_readbuf_int = (ArrayList)vl_readbuf.get(2);
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[2].get(0).equals(vl_readbuf_int.get(0)));
|
||||
vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[2];
|
||||
vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(2));
|
||||
/*
|
||||
* System.out.println("vl_readbuf: " + vl_readbuf); System.out.println("vl_readbuf_int: " +
|
||||
* vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(2),
|
||||
vl_int_data[2].get(2).equals(vl_readbuf_int.get(2)));
|
||||
|
||||
vl_readbuf = (ArrayList)base_vl_readbuf[3];
|
||||
vl_readbuf_int = (ArrayList)vl_readbuf.get(3);
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(0),
|
||||
vl_int_data[3].get(0).equals(vl_readbuf_int.get(0)));
|
||||
vl_readbuf = (ArrayList<ArrayList<Integer>>)base_vl_readbuf[3];
|
||||
vl_readbuf_int = (ArrayList<Integer>)(vl_readbuf.get(3));
|
||||
/*
|
||||
* System.out.println("vl_readbuf: " + vl_readbuf); System.out.println("vl_readbuf_int: " +
|
||||
* vl_readbuf_int);
|
||||
*/
|
||||
assertTrue("testH5DVLwrVL:" + vl_readbuf_int.get(3),
|
||||
vl_int_data[3].get(3).equals(vl_readbuf_int.get(3)));
|
||||
}
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
@@ -1391,4 +1407,121 @@ public class TestH5D {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testH5DArraywr()
|
||||
{
|
||||
String dset_int_name = "ArrayIntdata";
|
||||
long dset_int_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dtype_int_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long dspace_id = HDF5Constants.H5I_INVALID_HID;
|
||||
long[] dims = {4};
|
||||
long lsize = 1;
|
||||
|
||||
ArrayList[] arr_int_data = new ArrayList[4];
|
||||
try {
|
||||
// Write Integer data
|
||||
arr_int_data[0] = new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4));
|
||||
arr_int_data[1] = new ArrayList<Integer>(Arrays.asList(2, 3, 4, 5));
|
||||
arr_int_data[2] = new ArrayList<Integer>(Arrays.asList(4, 5, 6, 7));
|
||||
arr_int_data[3] = new ArrayList<Integer>(Arrays.asList(7, 8, 9, 10));
|
||||
Class dataClass = arr_int_data.getClass();
|
||||
assertTrue("testH5DArraywr.getClass: " + dataClass, dataClass.isArray());
|
||||
|
||||
try {
|
||||
dtype_int_id = H5.H5Tarray_create(HDF5Constants.H5T_STD_U32LE, 1, dims);
|
||||
assertTrue("testH5DArraywr.H5Tarray_create: ", dtype_int_id >= 0);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (dtype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(dtype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5DArraywr: " + err);
|
||||
}
|
||||
|
||||
try {
|
||||
dspace_id = H5.H5Screate_simple(1, dims, null);
|
||||
assertTrue(dspace_id > 0);
|
||||
dset_int_id =
|
||||
H5.H5Dcreate(H5fid, dset_int_name, dtype_int_id, dspace_id, HDF5Constants.H5P_DEFAULT,
|
||||
HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT);
|
||||
assertTrue("testH5DVLwr: ", dset_int_id >= 0);
|
||||
|
||||
H5.H5DwriteVL(dset_int_id, dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, arr_int_data);
|
||||
}
|
||||
catch (Exception err) {
|
||||
if (dset_int_id > 0)
|
||||
try {
|
||||
H5.H5Dclose(dset_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
if (dtype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(dtype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5DVLwr: " + err);
|
||||
}
|
||||
finally {
|
||||
if (dspace_id > 0)
|
||||
try {
|
||||
H5.H5Sclose(dspace_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL);
|
||||
|
||||
for (int j = 0; j < dims.length; j++)
|
||||
lsize *= dims[j];
|
||||
|
||||
// Read Integer data
|
||||
ArrayList[] arr_readbuf = new ArrayList[4];
|
||||
for (int j = 0; j < lsize; j++)
|
||||
arr_readbuf[j] = new ArrayList<Integer>();
|
||||
|
||||
try {
|
||||
H5.H5DreadVL(dset_int_id, dtype_int_id, HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL,
|
||||
HDF5Constants.H5P_DEFAULT, arr_readbuf);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
assertTrue("testH5DVLwr:" + arr_readbuf[0].get(0),
|
||||
arr_int_data[0].get(0).equals(arr_readbuf[0].get(0)));
|
||||
assertTrue("testH5DVLwr:" + arr_readbuf[1].get(0),
|
||||
arr_int_data[1].get(0).equals(arr_readbuf[1].get(0)));
|
||||
assertTrue("testH5DVLwr:" + arr_readbuf[2].get(0),
|
||||
arr_int_data[2].get(0).equals(arr_readbuf[2].get(0)));
|
||||
assertTrue("testH5DVLwr:" + arr_readbuf[3].get(0),
|
||||
arr_int_data[3].get(0).equals(arr_readbuf[3].get(0)));
|
||||
}
|
||||
catch (Throwable err) {
|
||||
err.printStackTrace();
|
||||
fail("H5.testH5DArraywr: " + err);
|
||||
}
|
||||
finally {
|
||||
if (dset_int_id > 0)
|
||||
try {
|
||||
H5.H5Dclose(dset_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
if (dtype_int_id > 0)
|
||||
try {
|
||||
H5.H5Tclose(dtype_int_id);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ JUnit version 4.11
|
||||
.testH5Adelete_by_idx_order
|
||||
.testH5Arename_by_name
|
||||
.testH5Acreate2_invalidobject
|
||||
.testH5AArraywr
|
||||
.testH5Acreate2
|
||||
.testH5Aiterate_by_name
|
||||
.testH5Adelete_by_idx_null
|
||||
@@ -32,5 +33,5 @@ JUnit version 4.11
|
||||
|
||||
Time: XXXX
|
||||
|
||||
OK (30 tests)
|
||||
OK (31 tests)
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
JUnit version 4.11
|
||||
.testH5DVLwrVL
|
||||
.testH5Dget_storage_size
|
||||
.testH5DArraywr
|
||||
.testH5Diterate_write
|
||||
.testH5Dcreate
|
||||
.testH5Dget_offset
|
||||
@@ -19,7 +20,6 @@ JUnit version 4.11
|
||||
.testH5Dvlen_write_read
|
||||
.testH5Dget_space
|
||||
.testH5Dget_type_closed
|
||||
.testH5Dvlen_read_default_buffer
|
||||
|
||||
Time: XXXX
|
||||
|
||||
|
||||
Reference in New Issue
Block a user