/// <summary> /// 得到所有文件属性名,未对异常进行处理 /// </summary> private void getFileAttributeNames() { H5GroupId groupId = H5G.open(_fileId, "/"); int attCount = H5A.getNumberOfAttributes(groupId); for (int ii = 0; ii < attCount; ++ii) { String attName = H5A.getNameByIndex(groupId, "/", H5IndexType.NAME, H5IterationOrder.NATIVE, (ulong)ii); if (attName != null) { _fileAttributeNames.Add(attName); } } if (groupId != null) { H5G.close(groupId); } }
public void GetHdfObjInfo(string groupName) { H5GroupId groupId = H5G.open(m_fileId, groupName); H5LIterateCallback myDelegate; myDelegate = Op_Func; ulong linkNumber = 0; int attriNum = H5A.getNumberOfAttributes(groupId); for (int i = 0; i < attriNum; i++) { string attriName = H5A.getNameByIndex(groupId, groupName, H5IndexType.CRT_ORDER, H5IterationOrder.NATIVE, (ulong)i); OnHdfObjInfoFound(attriName, HdfObjectType.Attribute, groupName); } H5L.iterate(groupId, H5IndexType.NAME, H5IterationOrder.NATIVE, ref linkNumber, myDelegate, groupName); H5G.close(groupId); }
/// <summary> /// 得到个顶数据集的所有属性值,未对异常进行处理 /// </summary> /// <param name="datasetName"></param> /// <returns></returns> public Dictionary <String, String> GetDatasetAttributes(String datasetName) { Dictionary <String, String> attributeValues = new Dictionary <String, String>(); if (!String.IsNullOrEmpty(datasetName) && _datasetNames.Contains(datasetName)) { H5DataSetId datasetId = H5D.open(_fileId, datasetName); if (datasetId != null) { int attributeCount = H5A.getNumberOfAttributes(datasetId); for (int ii = 0; ii < attributeCount; ++ii) { String attributeName = H5A.getNameByIndex(datasetId, "/" + datasetName, H5IndexType.NAME, H5IterationOrder.NATIVE, (ulong)ii); attributeValues.Add(attributeName, getAttributeValue(datasetId, attributeName)); } H5D.close(datasetId); } } return(attributeValues); }
private void GetAllFileAttributes() { H5GroupId h5GroupId = H5G.open(_h5FileId, "/"); try { int attCount = H5A.getNumberOfAttributes(h5GroupId); for (int i = 0; i < attCount; i++) { string attName = H5A.getNameByIndex(h5GroupId, "/", H5IndexType.NAME, H5IterationOrder.NATIVE, (ulong)i); if (attName != null) { _allFileAttributes.Add(attName); } } } finally { if (h5GroupId != null) { H5G.close(h5GroupId); } } }
public Dictionary <string, string> GetAttributes(string datasetName) { if (string.IsNullOrEmpty(datasetName) || !_datasetNames.Contains(datasetName)) { return(null); } H5DataSetId datasetId = null; H5GroupId groupId = null; H5DataTypeId typeId = null; H5DataSpaceId spaceId = null; //H5PropertyListId psId = null; try { int groupIndex = datasetName.LastIndexOf('/'); if (groupIndex == -1) { datasetId = H5D.open(_h5FileId, datasetName); } else { string groupName = datasetName.Substring(0, groupIndex + 1); string dsName = datasetName.Substring(groupIndex + 1); groupId = H5G.open(_h5FileId, groupName); datasetId = H5D.open(groupId, dsName); } if (datasetId == null) { return(null); } Dictionary <string, string> attValues = new Dictionary <string, string>(); typeId = H5D.getType(datasetId); H5T.H5TClass type = H5T.getClass(typeId); int tSize = H5T.getSize(typeId); spaceId = H5D.getSpace(datasetId); long[] dims = H5S.getSimpleExtentDims(spaceId); long storageSize = H5D.getStorageSize(datasetId); attValues.Add("DataSetName", datasetName); attValues.Add("DataType", type.ToString()); attValues.Add("DataTypeSize", tSize.ToString() + "Byte"); attValues.Add("Dims", String.Join("*", dims)); attValues.Add("StorageSize", storageSize.ToString() + "Byte"); int attrCount = H5A.getNumberOfAttributes(datasetId); for (int i = 0; i < attrCount; i++) { string attName = H5A.getNameByIndex(datasetId, "/" + datasetName, H5IndexType.NAME, H5IterationOrder.NATIVE, (ulong)i); attValues.Add(attName, ReadAttributeValue(datasetId, attName)); } return(attValues); } finally { if (spaceId != null) { H5S.close(spaceId); } if (typeId != null) { H5T.close(typeId); } if (datasetId != null) { H5D.close(datasetId); } if (groupId != null) { H5G.close(groupId); } } }