Skip to content

Extend and revisit iteration implementation - #235

Open
CramBL wants to merge 4 commits into
metno:mainfrom
CramBL:export-iteration-order
Open

Extend and revisit iteration implementation #235
CramBL wants to merge 4 commits into
metno:mainfrom
CramBL:export-iteration-order

Conversation

@CramBL

@CramBL CramBL commented Sep 7, 2026

Copy link
Copy Markdown

Resolves #228
Resolves #230

It's quite a mouthful, I realize that, but there were some problems with the existing implementation, mostly just several limitations and assumptions, please see commit messages for more information. I recommend reviewing the commits in order.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for H5Pset_link_creation_order and H5Pget_link_creation_order Export IterationOrder and TraversalOrder for Group::iter_visit

1 participant