public void H5Rget_obj_typeTest2() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); Assert.IsTrue( H5G.close(H5G.create(m_v2_test_file, path, m_lcpl_utf8)) >= 0); byte[] refer = new byte[H5R.OBJ_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v2_test_file, name, H5R.type_t.OBJECT, -1) >= 0); H5O.type_t obj_type = H5O.type_t.UNKNOWN; Assert.IsTrue( H5R.get_obj_type(m_v2_test_file, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject(), ref obj_type) >= 0); hnd.Free(); Assert.IsTrue(obj_type == H5O.type_t.GROUP); }
public void H5RcreateTest4() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); hsize_t[] dims = new hsize_t[] { 10, 20 }; hid_t space = H5S.create_simple(2, dims, null); Assert.IsTrue(space >= 0); hid_t dset = H5D.create(m_v2_test_file, name, H5T.STD_I32LE, space, m_lcpl_utf8); Assert.IsTrue(dset >= 0); hsize_t[] start = { 5, 10 }; hsize_t[] count = { 1, 1 }; hsize_t[] block = { 2, 4 }; Assert.IsTrue( H5S.select_hyperslab(space, H5S.seloper_t.SET, start, null, count, block) >= 0); byte[] refer = new byte[H5R.DSET_REG_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v2_test_file, name, H5R.type_t.DATASET_REGION, space) >= 0); ssize_t size = H5R.get_name(m_v2_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject(), (byte[])null, IntPtr.Zero); Assert.IsTrue(size.ToInt32() == name.Length); byte[] buf = new byte[size.ToInt32() + 1]; size = H5R.get_name(m_v2_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject(), buf, new IntPtr(buf.Length)); Assert.IsTrue(size.ToInt32() == name.Length); // we need to account for the leading "/", which was not included // in path for (int i = 0; i < name.Length; ++i) { Assert.IsTrue(name[i] == buf[i + 1]); } hid_t sel = H5R.get_region(dset, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject()); Assert.IsTrue(sel >= 0); hnd.Free(); Assert.IsTrue(H5S.extent_equal(space, sel) > 0); Assert.IsTrue(H5S.get_select_hyper_nblocks(space) == H5S.get_select_hyper_nblocks(sel)); Assert.IsTrue(H5S.close(sel) >= 0); Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(H5S.close(space) >= 0); }
public void H5RdereferenceTest4() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); hsize_t[] dims = new hsize_t[] { 10, 20 }; hid_t space = H5S.create_simple(2, dims, null); Assert.IsTrue(space >= 0); hid_t dset = H5D.create(m_v2_test_file, name, H5T.STD_I32LE, space, m_lcpl_utf8); H5O.info_t info = new H5O.info_t(); Assert.IsTrue(H5O.get_info(dset, ref info) >= 0); haddr_t address = info.addr; Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(dset >= 0); hsize_t[] start = { 5, 10 }; hsize_t[] count = { 1, 1 }; hsize_t[] block = { 2, 4 }; Assert.IsTrue( H5S.select_hyperslab(space, H5S.seloper_t.SET, start, null, count, block) >= 0); byte[] refer = new byte[H5R.DSET_REG_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v2_test_file, name, H5R.type_t.DATASET_REGION, space) >= 0); #if HDF5_VER1_10 dset = H5R.dereference(m_v2_test_file, H5P.DEFAULT, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject()); #else dset = H5R.dereference(m_v2_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject()); #endif Assert.IsTrue(dset >= 0); hnd.Free(); Assert.IsTrue(H5O.get_info(dset, ref info) >= 0); Assert.IsTrue(address == info.addr); Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(H5S.close(space) >= 0); }
public void H5Rget_obj_typeTest3() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); hsize_t[] dims = new hsize_t[] { 10, 20 }; hid_t space = H5S.create_simple(2, dims, null); Assert.IsTrue(space >= 0); hid_t dset = H5D.create(m_v0_test_file, name, H5T.STD_I32LE, space, m_lcpl_utf8); Assert.IsTrue(dset >= 0); hsize_t[] start = { 5, 10 }; hsize_t[] count = { 1, 1 }; hsize_t[] block = { 2, 4 }; Assert.IsTrue( H5S.select_hyperslab(space, H5S.seloper_t.SET, start, null, count, block) >= 0); byte[] refer = new byte[H5R.DSET_REG_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v0_test_file, name, H5R.type_t.DATASET_REGION, space) >= 0); H5O.type_t obj_type = H5O.type_t.UNKNOWN; Assert.IsTrue( H5R.get_obj_type(m_v0_test_file, H5R.type_t.DATASET_REGION, hnd.AddrOfPinnedObject(), ref obj_type) >= 0); hnd.Free(); Assert.IsTrue(obj_type == H5O.type_t.DATASET); Assert.IsTrue(H5D.close(dset) >= 0); Assert.IsTrue(H5S.close(space) >= 0); }
public void H5RdereferenceTest2() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte[path.Length + 1]; Array.Copy(path, name, path.Length); hid_t gid = H5G.create(m_v2_test_file, path, m_lcpl_utf8); Assert.IsTrue(gid >= 0); H5O.info_t info = new H5O.info_t(); Assert.IsTrue(H5O.get_info(gid, ref info) >= 0); haddr_t address = info.addr; Assert.IsTrue(H5G.close(gid) >= 0); byte[] refer = new byte[H5R.OBJ_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v2_test_file, name, H5R.type_t.OBJECT, -1) >= 0); #if HDF5_VER1_10 gid = H5R.dereference(m_v2_test_file, H5P.DEFAULT, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject()); #else gid = H5R.dereference(m_v2_test_file, H5P.DEFAULT, hnd.AddrOfPinnedObject()); #endif Assert.IsTrue(gid >= 0); hnd.Free(); Assert.IsTrue(H5O.get_info(gid, ref info) >= 0); Assert.IsTrue(address == info.addr); Assert.IsTrue(H5G.close(gid) >= 0); }
public void H5Rget_nameTest1() { byte[] path = Encoding.UTF8.GetBytes(String.Join("/", m_utf8strings)); // make room for the trailling \0 byte[] name = new byte [path.Length + 1]; Array.Copy(path, name, path.Length); Assert.IsTrue( H5G.close(H5G.create(m_v0_test_file, path, m_lcpl_utf8)) >= 0); byte[] refer = new byte [H5R.OBJ_REF_BUF_SIZE]; GCHandle hnd = GCHandle.Alloc(refer, GCHandleType.Pinned); Assert.IsTrue( H5R.create(hnd.AddrOfPinnedObject(), m_v0_test_file, name, H5R.type_t.OBJECT, -1) >= 0); ssize_t size = H5R.get_name(m_v0_test_file, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject(), (byte[])null, IntPtr.Zero); Assert.IsTrue(size.ToInt32() == name.Length); // size does not include the trailling \0 byte[] buf = new byte[size.ToInt32() + 1]; size = H5R.get_name(m_v0_test_file, H5R.type_t.OBJECT, hnd.AddrOfPinnedObject(), buf, new IntPtr(buf.Length)); Assert.IsTrue(size.ToInt32() == name.Length); hnd.Free(); // we need to account for the leading "/", which was not included // in path for (int i = 0; i < name.Length; ++i) { Assert.IsTrue(name[i] == buf[i + 1]); } }
public static unsafe void AddObjectReference(long fileId, ContainerType container) { long res; TestUtils.AddNumerical(fileId, ContainerType.Dataset); var length = (ulong)TestData.NumericalData.Count; var data = new ulong[length]; fixed(ulong *ptr = data) { var referenceGroupId = H5G.open(fileId, "numerical"); for (ulong i = 0; i < length; i++) { res = H5R.create(new IntPtr(ptr + i), referenceGroupId, $"D{i + 1}", H5R.type_t.OBJECT, -1); } TestUtils.Add(container, fileId, "reference", "object_reference", H5T.STD_REF_OBJ, new IntPtr(ptr).ToPointer(), length); res = H5G.close(referenceGroupId); } }
public static unsafe void AddRegionReference(long fileId, ContainerType container) { long res; TestUtils.AddSmall(fileId, ContainerType.Dataset); var length = 1UL; var data = new ulong[length]; fixed(ulong *ptr = data) { var referenceGroupId = H5G.open(fileId, "small"); var spaceId = H5S.create_simple(1, new ulong[] { length }, null); var coordinates = new ulong[] { 2, 4, 6, 8 }; res = H5S.select_elements(spaceId, H5S.seloper_t.SET, new IntPtr(4), coordinates); res = H5R.create(new IntPtr(ptr), referenceGroupId, "small", H5R.type_t.DATASET_REGION, spaceId); TestUtils.Add(container, fileId, "reference", "region_reference", H5T.STD_REF_DSETREG, new IntPtr(ptr).ToPointer(), length); res = H5S.close(spaceId); res = H5G.close(referenceGroupId); } }
public H5Group(FileFormat theFile, string name, string path, Group parent, IntPtr oid) : base(theFile, name, path, parent, oid) { nMembersInFile = -1; obj_info = new H5O.info_t(); if (theFile != null) { // throw new Exception("??"); // retrieve the object ID try { IntPtr ptr = new IntPtr(); var reference = H5R.create(ptr, theFile.getFID(), this.getFullName(), H5R.type_t.OBJECT, -1); //todo: address = ptr; //this.oid = new long[1]; //this.oid[0] = HDFNativeData.byteToLong(ref_buf, 0); } catch (Exception ex) { Hdf5Utils.LogError?.Invoke("ERROR: " + ex); } } }