Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creates access to remaining H5O_info_t struct fields, Closes #2347 #2358

Merged
merged 4 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
66 changes: 64 additions & 2 deletions h5py/h5o.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,55 @@ cdef class _OHdr(_ObjInfoBase):
property nmesgs:
def __get__(self):
return self.istr[0].hdr.nmesgs
property nchunks:
def __get__(self):
return self.istr[0].hdr.nchunks
property flags:
def __get__(self):
return self.istr[0].hdr.flags

def __init__(self):
self.space = _OHdrSpace()
self.mesg = _OHdrMesg()

def _hash(self):
return hash((self.version, self.nmesgs, self.space, self.mesg))
return hash((self.version, self.nmesgs, self.nchunks, self.flags, self.space, self.mesg))

cdef class _MetaSizeObj(_ObjInfoBase):

property index_size:
def __get__(self):
return self.istr[0].meta_size.obj.index_size
property heap_size:
def __get__(self):
return self.istr[0].meta_size.obj.heap_size

def _hash(self):
return hash((self.index_size, self.heap_size))

cdef class _MetaSizeAttr(_ObjInfoBase):

property index_size:
def __get__(self):
return self.istr[0].meta_size.attr.index_size
property heap_size:
def __get__(self):
return self.istr[0].meta_size.attr.heap_size

def _hash(self):
return hash((self.index_size, self.heap_size))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two classes can be condensed into one - we'll need two instances, but the corresponding C structs are of the same type (H5_ih_info_t).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tried to make them one but was struggling with the Cython code to access attr vs obj field from self.istr[0].meta_size.

Its all very new to me. I'll take another crack.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I got it working. It built and I was able to access the structs in ipython.

In [1]: import h5py

In [2]: h5py.__file__
Out[2]: '/home/delen/miniconda3/envs/h5py_dev/lib/python3.10/site-packages/h5py/__init__.py'

In [3]: from h5py.h5o import get_info

In [4]: h5 = h5py.File("./h5py/h5py/tests/data_files/vlen_string_dset.h5")

In [5]: get_info(h5['DS1'].id).meta_size.obj.index_size
Out[5]: 0

In [6]: get_info(h5['DS1'].id).meta_size.attr.index_size
Out[6]: 0

In [7]: get_info(h5['DS1'].id).meta_size.attr.heap_size
Out[7]: 0

In [8]: get_info(h5['DS1'].id).meta_size.obj.heap_size
Out[8]: 0


cdef class _OMetaSize(_ObjInfoBase):

cdef public _MetaSizeObj obj
cdef public _MetaSizeAttr attr

def __init__(self):
self.obj = _MetaSizeObj()
self.attr = _MetaSizeAttr()

def _hash(self):
return hash((self.obj, self.attr))

cdef class _ObjInfo(_ObjInfoBase):

Expand All @@ -106,9 +148,24 @@ cdef class _ObjInfo(_ObjInfoBase):
property rc:
def __get__(self):
return self.istr[0].rc
property atime:
def __get__(self):
return self.istr[0].atime
property mtime:
def __get__(self):
return self.istr[0].mtime
property ctime:
def __get__(self):
return self.istr[0].ctime
property btime:
def __get__(self):
return self.istr[0].btime
property num_attrs:
def __get__(self):
return self.istr[0].num_attrs

def _hash(self):
return hash((self.fileno, self.addr, self.type, self.rc))
return hash((self.fileno, self.addr, self.type, self.rc, self.atime, self.mtime, self.ctime, self.btime, self.num_attrs))

cdef class ObjInfo(_ObjInfo):

Expand All @@ -118,14 +175,19 @@ cdef class ObjInfo(_ObjInfo):

cdef H5O_info_t infostruct
cdef public _OHdr hdr
cdef public _OMetaSize meta_size

def __init__(self):
self.hdr = _OHdr()
self.meta_size = _OMetaSize()

self.istr = &self.infostruct
self.hdr.istr = &self.infostruct
self.hdr.space.istr = &self.infostruct
self.hdr.mesg.istr = &self.infostruct
self.meta_size.istr = &self.infostruct
self.meta_size.obj.istr = &self.infostruct
self.meta_size.attr.istr = &self.infostruct

def __copy__(self):
cdef ObjInfo newcopy
Expand Down