Add Group::info exposing H5Gget_info - #239
Open
CramBL wants to merge 11 commits into
Open
Conversation
Both enums were private to hl::group, so iter_visit could only be called with Default::default() for the order arguments. The previously private TraversalOrder is renamed to IndexType with variants Name and CreationOrder, matching H5_index_t.
index_type now comes before iteration_order, as in H5Literate2. Until IndexType and IterationOrder were exported the order arguments could only be passed as Default::default(), so the reorder breaks no caller. The closure takes the link name and LinkInfo and returns Result<()>. Its error is returned from iter_visit instead of being reported as a stop with a partial result. The group argument is dropped since H5Literate always passes back the group being iterated, and the accumulator argument is dropped since the closure can capture its own state. find_link takes a closure returning Result<Option<B>> and stops at the first Some, returning the value. Together with the error this maps onto the continue, stop and fail returns of the C callback. iter_visit_from takes a LinkCursor and returns the cursor of the next link together with the value, so a stopped iteration can be resumed. The cursor carries the index type and iteration order it counts along, so it cannot be reused with a different traversal. A cursor at or past the last link yields None instead of the HDF5 out of bounds error. A panic in the closure is resumed after H5Literate returns instead of being reported as an HDF5 error.
The bitflags allowed INDEXED without TRACKED, a combination HDF5 rejects when the property list is built, so the invalid state was only caught at runtime. The enum with Untracked, Tracked and Indexed cannot express it, and matches LinkCreationOrder.
FileCreate and DatasetCreate already expose both. A group tracking attribute creation order is what h5py's track_order=True and netCDF-4 produce, and it is required for iterating attributes by creation order.
H5Aiterate2 has the same shape as H5Literate: an index type, an iteration order, an in/out position and a callback that continues, stops or fails. IndexType, IterationOrder and the cursor move to hl::iteration together with the callback driver, so attribute iteration can reuse them instead of a second copy of the unsafe code. LinkCursor is renamed IterationCursor since it no longer counts only links.
Location::iter_attrs, find_attr and iter_attrs_from mirror the link iteration on Group, over H5Aiterate2 with the shared callback driver. The callback receives an AttrInfo built from H5A_info_t. attr_names is now the name order case of iter_attrs.
attr_by_index opens an attribute by its position along an index type and order over H5Aopen_by_idx. attr_info returns the AttrInfo of a named attribute over H5Aget_info_by_name.
The tracked group also tracks attribute creation order, and the example lists its attributes in that order, opens one by position and looks up the info of another by name. The example is renamed creation_order since it no longer covers only links.
GroupInfo carries the storage type, the number of links, the creation order counter and the mounted flag. max_corder is the way to see that unlinking leaves the creation order counter alone, and storage_type shows when a group has moved from compact to dense storage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Builds on top of #235, #236, & #238
Resolves #233