public static ulong[] PrepareAttributeValueSet <T>(long attributeId, ref T[] valueSet, bool isReference) { long dataspaceId = -1; ulong[] dimensionSet; ulong[] dimensionLimitSet; dimensionSet = new ulong[] { 0 }; dimensionLimitSet = new ulong[] { 0 }; try { dataspaceId = H5A.get_space(attributeId); H5S.get_simple_extent_dims(dataspaceId, null, dimensionLimitSet); // merge data if (dimensionLimitSet[0] == H5S.UNLIMITED) { T[] valueSet_File = IOHelper.Read <T>(attributeId, DataContainerType.Attribute); if (isReference) { if (valueSet_File.Count() == 0 || !Enumerable.SequenceEqual(valueSet_File, valueSet.Skip(Math.Max(0, valueSet.Count() - valueSet_File.Count())))) { valueSet = valueSet.Concat(valueSet_File).ToArray(); } } else { if (valueSet.Count() == 0 || !Enumerable.SequenceEqual(valueSet, valueSet_File.Skip(Math.Max(0, valueSet_File.Count() - valueSet.Count())))) { valueSet = valueSet_File.Concat(valueSet).ToArray(); } } } } finally { if (H5I.is_valid(dataspaceId) > 0) { H5S.close(dataspaceId); } } return(dimensionLimitSet); }
public static T[] ReadDataset <T>(long locationId, string datasetPath, ulong start = 0, ulong block = 0) { long datasetId = -1; long dataspaceId = -1; T[] result; try { datasetId = H5D.open(locationId, datasetPath); if (H5I.is_valid(datasetId) <= 0) { throw new Exception(ErrorMessage.IOHelper_CouldNotOpenDataset); } if (start == 0 && block == 0) { result = IOHelper.Read <T>(datasetId, DataContainerType.Dataset); } else { dataspaceId = H5D.get_space(datasetId); if (H5S.select_hyperslab(dataspaceId, H5S.seloper_t.SET, new ulong[] { start }, new ulong[] { 1 }, new ulong[] { block }, new ulong[] { 1 }) < 0) { throw new Exception(ErrorMessage.IOHelper_CouldNotSelectHyperslab); } result = IOHelper.Read <T>(datasetId, DataContainerType.Dataset, dataspaceId); } } finally { if (H5I.is_valid(dataspaceId) > 0) { H5S.close(dataspaceId); } if (H5I.is_valid(datasetId) > 0) { H5D.close(datasetId); } } return(result); }