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

Add option to track order of attributes and fields #82

Merged
merged 4 commits into from
Aug 28, 2024

Conversation

bmaranville
Copy link
Member

Enable "track order" mode of hdf5 for attributes of Dataset, and (fields and attributes) of Group. When track_order == true for a Group, both fields and attributes keep their insertion order on read. For a Dataset, the attributes keep their insertion order when the flag is set.

Note that the flag is not inherited, i.e. if an h5wasm.Group object is created with track_order = true, its sub-groups and contained Dataset objects will not have the flag enabled by default. The flag is added to the File constructor just to track order of immediate children of the root group.

Changes three signatures in the h5wasm API:

  • h5wasm.File(filename: string, mode: ACCESS_MODESTRING = "r", track_order: boolean = false)
  • h5wasm.Group.create_group(name: string, track_order: boolean = false)
  • h5wasm.Group.create_dataset(args: {
      name: string,
      data: GuessableDataTypes,
      shape?: number[] | null,
      dtype?: string | null,
      maxshape?: (number | null)[] | null,
      chunks?: number[] | null,
      compression?: (number | 'gzip'),
      compression_opts?: number | number[],
      track_order?: boolean,
    })
    

Also adds one method to the Module API:

  • open(filename: string, mode: number, track_order: boolean): bigint;

and modifies the signatures of three existing methods in the Module API:

  • create_dataset
  • create_group
  • create_vlen_str_dataset

@bmaranville
Copy link
Member Author

There is currently no way to determine if track_order has been set for an existing Group or Dataset in an HDF5 file - is that an important feature to add? It could be added to the metadata object (changing its interface) or it could be a separate on-demand query.

@bmaranville
Copy link
Member Author

It seems like checking if order tracking is enabled in the creation property list is not an immediate need - I will merge this as-is shortly and make a new release.

Copy link
Collaborator

@axelboc axelboc left a comment

Choose a reason for hiding this comment

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

Module.open() is going to be super useful, thanks!

src/hdf5_util.cc Outdated
@@ -27,6 +27,31 @@ EM_JS(void, throw_error, (const char *string_error), {
// // pass
// }

int64_t open(const std::string& filename_string, unsigned int h5_mode, bool track_order = false)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could H5F_ACC_RDONLY be the default for h5_mode?

Copy link
Member Author

Choose a reason for hiding this comment

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

sure!

@bmaranville bmaranville merged commit e8acf24 into main Aug 28, 2024
1 check passed
@bmaranville bmaranville deleted the rebase-track-order branch August 28, 2024 16:10
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.

2 participants