From 6dd3b56460b17329ec0b34414330158be320b212 Mon Sep 17 00:00:00 2001 From: Mark Kittisopikul Date: Tue, 31 May 2022 14:05:55 -0400 Subject: [PATCH] Add dset_no_attrs_hint support, h5f coverage up to v1.12 (#944) * add dset_no_attrs_hint support, h5f coverage * no_attrs_hint requires 1.10.5 * Only run h5f_get_dset_no_attrs_hint tests for 1.10.5+ * Add test for h5f_get_dset_no_attrs_hint * Fix h5f_get_dset_no_attrs_hint helper * Document no_attrs_hint property of dcpl * Update test/fileio.jl --- docs/src/api_bindings.md | 60 +++++++ gen/api_defs.jl | 34 +++- src/api/functions.jl | 334 ++++++++++++++++++++++++++++++++++++++- src/api/helpers.jl | 15 ++ src/api/types.jl | 41 ++++- src/api_midlevel.jl | 2 +- src/properties.jl | 20 ++- test/fileio.jl | 33 ++++ test/properties.jl | 13 +- 9 files changed, 540 insertions(+), 12 deletions(-) diff --git a/docs/src/api_bindings.md b/docs/src/api_bindings.md index 5eb14afd2..600de918e 100644 --- a/docs/src/api_bindings.md +++ b/docs/src/api_bindings.md @@ -169,37 +169,97 @@ h5e_walk --- ## [[`H5F`](https://portal.hdfgroup.org/display/HDF5/Files) — File Interface](@id H5F) +- [`h5f_clear_elink_file_cache`](@ref h5f_clear_elink_file_cache) - [`h5f_close`](@ref h5f_close) - [`h5f_create`](@ref h5f_create) +- [`h5f_delete`](@ref h5f_delete) - [`h5f_flush`](@ref h5f_flush) +- [`h5f_format_convert`](@ref h5f_format_convert) - [`h5f_get_access_plist`](@ref h5f_get_access_plist) - [`h5f_get_create_plist`](@ref h5f_get_create_plist) +- [`h5f_get_dset_no_attrs_hint`](@ref h5f_get_dset_no_attrs_hint) +- [`h5f_get_eoa`](@ref h5f_get_eoa) +- [`h5f_get_file_image`](@ref h5f_get_file_image) +- [`h5f_get_fileno`](@ref h5f_get_fileno) +- [`h5f_get_filesize`](@ref h5f_get_filesize) - [`h5f_get_free_sections`](@ref h5f_get_free_sections) - [`h5f_get_freespace`](@ref h5f_get_freespace) +- [`h5f_get_info`](@ref h5f_get_info) - [`h5f_get_intent`](@ref h5f_get_intent) +- [`h5f_get_mdc_config`](@ref h5f_get_mdc_config) +- [`h5f_get_mdc_hit_rate`](@ref h5f_get_mdc_hit_rate) +- [`h5f_get_mdc_image_info`](@ref h5f_get_mdc_image_info) +- [`h5f_get_mdc_logging_status`](@ref h5f_get_mdc_logging_status) +- [`h5f_get_mdc_size`](@ref h5f_get_mdc_size) +- [`h5f_get_metadata_read_retry_info`](@ref h5f_get_metadata_read_retry_info) +- [`h5f_get_mpi_atomicity`](@ref h5f_get_mpi_atomicity) - [`h5f_get_name`](@ref h5f_get_name) - [`h5f_get_obj_count`](@ref h5f_get_obj_count) - [`h5f_get_obj_ids`](@ref h5f_get_obj_ids) +- [`h5f_get_page_buffering_stats`](@ref h5f_get_page_buffering_stats) - [`h5f_get_vfd_handle`](@ref h5f_get_vfd_handle) +- [`h5f_increment_filesize`](@ref h5f_increment_filesize) +- [`h5f_is_accessible`](@ref h5f_is_accessible) - [`h5f_is_hdf5`](@ref h5f_is_hdf5) +- [`h5f_mount`](@ref h5f_mount) - [`h5f_open`](@ref h5f_open) +- [`h5f_reopen`](@ref h5f_reopen) +- [`h5f_reset_mdc_hit_rate_stats`](@ref h5f_reset_mdc_hit_rate_stats) +- [`h5f_reset_page_buffering_stats`](@ref h5f_reset_page_buffering_stats) +- [`h5f_set_dset_no_attrs_hint`](@ref h5f_set_dset_no_attrs_hint) +- [`h5f_set_libver_bounds`](@ref h5f_set_libver_bounds) +- [`h5f_set_mdc_config`](@ref h5f_set_mdc_config) +- [`h5f_set_mpi_atomicity`](@ref h5f_set_mpi_atomicity) +- [`h5f_start_mdc_logging`](@ref h5f_start_mdc_logging) - [`h5f_start_swmr_write`](@ref h5f_start_swmr_write) +- [`h5f_stop_mdc_logging`](@ref h5f_stop_mdc_logging) +- [`h5f_unmount`](@ref h5f_unmount) ```@docs +h5f_clear_elink_file_cache h5f_close h5f_create +h5f_delete h5f_flush +h5f_format_convert h5f_get_access_plist h5f_get_create_plist +h5f_get_dset_no_attrs_hint +h5f_get_eoa +h5f_get_file_image +h5f_get_fileno +h5f_get_filesize h5f_get_free_sections h5f_get_freespace +h5f_get_info h5f_get_intent +h5f_get_mdc_config +h5f_get_mdc_hit_rate +h5f_get_mdc_image_info +h5f_get_mdc_logging_status +h5f_get_mdc_size +h5f_get_metadata_read_retry_info +h5f_get_mpi_atomicity h5f_get_name h5f_get_obj_count h5f_get_obj_ids +h5f_get_page_buffering_stats h5f_get_vfd_handle +h5f_increment_filesize +h5f_is_accessible h5f_is_hdf5 +h5f_mount h5f_open +h5f_reopen +h5f_reset_mdc_hit_rate_stats +h5f_reset_page_buffering_stats +h5f_set_dset_no_attrs_hint +h5f_set_libver_bounds +h5f_set_mdc_config +h5f_set_mpi_atomicity +h5f_start_mdc_logging h5f_start_swmr_write +h5f_stop_mdc_logging +h5f_unmount ``` --- diff --git a/gen/api_defs.jl b/gen/api_defs.jl index 9e55be035..f94c839f6 100644 --- a/gen/api_defs.jl +++ b/gen/api_defs.jl @@ -102,21 +102,51 @@ ### File Interface ### +@bind h5f_clear_elink_file_cache(file_id::hid_t)::herr_t "Error in h5f_clear_elink_file_cache (not annotated)" @bind h5f_close(file_id::hid_t)::herr_t "Error closing file" @bind h5f_create(pathname::Ptr{UInt8}, flags::Cuint, fcpl_id::hid_t, fapl_id::hid_t)::hid_t "Error creating file $pathname" +@bind h5f_delete(filename::Ptr{Cchar}, fapl_id::hid_t)::herr_t "Error in h5f_delete (not annotated)" @bind h5f_flush(object_id::hid_t, scope::Cint)::herr_t "Error flushing object to file" +@bind h5f_format_convert(fid::hid_t)::herr_t "Error in h5f_format_convert (not annotated)" @bind h5f_get_access_plist(file_id::hid_t)::hid_t "Error getting file access property list" @bind h5f_get_create_plist(file_id::hid_t)::hid_t "Error getting file create property list" +@bind h5f_get_dset_no_attrs_hint(file_id::hid_t, minimize::Ptr{hbool_t})::herr_t "Error getting dataset no attributes hint" +@bind h5f_get_eoa(file_id::hid_t, eoa::Ptr{haddr_t})::herr_t "Error in h5f_get_eoa (not annotated)" +@bind h5f_get_file_image(file_id::hid_t, buf_ptr::Ptr{Cvoid}, buf_len::Csize_t)::Cssize_t "Error in h5f_get_file_image (not annotated)" +@bind h5f_get_fileno(file_id::hid_t, fileno::Ptr{Culong})::herr_t "Error in h5f_get_fileno (not annotated)" +@bind h5f_get_filesize(file_id::hid_t, size::Ptr{hsize_t})::herr_t "Error in h5f_get_filesize (not annotated)" @bind h5f_get_free_sections(file_id::hid_t, type::H5F_mem_t, nsects::Csize_t, sect_info::Ptr{H5F_sect_info_t})::Cssize_t "Error in h5f_get_free_sections (not annotated)" @bind h5f_get_freespace(file_id::hid_t)::hssize_t "Error in h5f_get_freespace (not annotated)" @bind h5f_get_intent(file_id::hid_t, intent::Ptr{Cuint})::herr_t "Error getting file intent" +@bind h5f_get_info2(obj_id::hid_t, file_info::Ptr{H5F_info2_t})::herr_t "Error in h5f_get_info2 (not annotated)" +@bind h5f_get_mdc_config(file_id::hid_t, config_ptr::Ptr{H5AC_cache_config_t})::herr_t "Error in h5f_get_mdc_config (not annotated)" +@bind h5f_get_mdc_hit_rate(file_id::hid_t, hit_rate_ptr::Ptr{Cdouble})::herr_t "Error in h5f_get_mdc_hit_rate (not annotated)" +@bind h5f_get_mdc_image_info(file_id::hid_t, image_addr::Ptr{haddr_t}, image_size::Ptr{hsize_t})::herr_t "Error in h5f_get_mdc_image_info (not annotated)" +@bind h5f_get_mdc_logging_status(file_id::hid_t, is_enabled::Ptr{hbool_t}, is_currently_logging::Ptr{hbool_t})::herr_t "Error in h5f_get_mdc_logging_status (not annotated)" +@bind h5f_get_mdc_size(file_id::hid_t, max_size_ptr::Ptr{Csize_t}, min_clean_size_ptr::Ptr{Csize_t}, cur_size_ptr::Ptr{Csize_t}, cur_num_entries_ptr::Ptr{Cint})::herr_t "Error in h5f_get_mdc_size (not annotated)" +@bind h5f_get_metadata_read_retry_info(file_id::hid_t, info::Ptr{H5F_retry_info_t})::herr_t "Error in h5f_get_metadata_read_retry_info (not annotated)" +@bind h5f_get_mpi_atomicity(file_id::hid_t, flag::Ptr{hbool_t})::herr_t "Error in h5f_get_mpi_atomicity (not annotated)" @bind h5f_get_name(obj_id::hid_t, buf::Ptr{UInt8}, buf_size::Csize_t)::Cssize_t "Error getting file name" @bind h5f_get_obj_count(file_id::hid_t, types::Cuint)::Cssize_t "Error getting object count" @bind h5f_get_obj_ids(file_id::hid_t, types::Cuint, max_objs::Csize_t, obj_id_list::Ptr{hid_t})::Cssize_t "Error getting objects" +@bind h5f_get_page_buffering_stats(file_id::hid_t, accesses::Ptr{Cuint}, hits::Ptr{Cuint}, misses::Ptr{Cuint}, evictions::Ptr{Cuint}, bypasses::Ptr{Cuint})::herr_t "Error in h5f_get_page_buffering_stats (not annotated)" @bind h5f_get_vfd_handle(file_id::hid_t, fapl_id::hid_t, file_handle::Ref{Ptr{Cvoid}})::herr_t "Error getting VFD handle" +@bind h5f_increment_filesize(file_id::hid_t, increment::hsize_t)::herr_t "Error in h5f_increment_filesize (not annotated)" +@bind h5f_is_accessible(container_name::Ptr{Cchar}, fapl_id::hid_t)::htri_t "Error in h5f_is_accessible (not annotated)" @bind h5f_is_hdf5(pathname::Cstring)::htri_t "Unable to access file $pathname" +@bind h5f_mount(loc::hid_t, name::Ptr{Cchar}, child::hid_t, plist::hid_t)::herr_t "Error in h5f_mount (not annotated)" @bind h5f_open(pathname::Cstring, flags::Cuint, fapl_id::hid_t)::hid_t "Error opening file $pathname" +@bind h5f_reopen(file_id::hid_t)::hid_t "Error in h5f_reopen (not annotated)" +@bind h5f_reset_mdc_hit_rate_stats(file_id::hid_t)::herr_t "Error in h5f_reset_mdc_hit_rate_stats (not annotated)" +@bind h5f_reset_page_buffering_stats(file_id::hid_t)::herr_t "Error in h5f_reset_page_buffering_stats (not annotated)" +@bind h5f_set_dset_no_attrs_hint(file_id::hid_t, minimize::hbool_t)::herr_t "Error in setting dataset no attributes hint" +@bind h5f_set_libver_bounds(file_id::hid_t, low::H5F_libver_t, high::H5F_libver_t)::herr_t "Error in h5f_set_libver_bounds (not annotated)" +@bind h5f_set_mdc_config(file_id::hid_t, config_ptr::Ptr{H5AC_cache_config_t})::herr_t "Error in h5f_set_mdc_config (not annotated)" +@bind h5f_set_mpi_atomicity(file_id::hid_t, flag::hbool_t)::herr_t "Error in h5f_set_mpi_atomicity (not annotated)" +@bind h5f_start_mdc_logging(file_id::hid_t)::herr_t "Error in h5f_start_mdc_logging (not annotated)" @bind h5f_start_swmr_write(id::hid_t)::herr_t "Error starting SWMR write" +@bind h5f_stop_mdc_logging(file_id::hid_t)::herr_t "Error in h5f_stop_mdc_logging (not annotated)" +@bind h5f_unmount(loc::hid_t, name::Ptr{Cchar})::herr_t "Error in h5f_unmount (not annotated)" ### ### Group Interface @@ -194,7 +224,7 @@ @bind h5p_get_data_transform(plist_id::hid_t, expression::Ptr{Cchar}, size::Csize_t)::Cssize_t "Error in h5p_get_data_transform (not annotated)" @bind h5p_get_driver(plist_id::hid_t)::hid_t "Error getting driver identifier" @bind h5p_get_driver_info(plist_id::hid_t)::Ptr{Cvoid} "Error getting driver info" -@bind h5p_get_dset_no_attrs_hint(dcpl_id::hid_t, minimize::Ptr{hbool_t})::herr_t "Error in h5p_get_dset_no_attrs_hint (not annotated)" +@bind h5p_get_dset_no_attrs_hint(dcpl_id::hid_t, minimize::Ptr{hbool_t})::herr_t "Error in getting dataset no attributes hint property" @bind h5p_get_dxpl_mpio(dxpl_id::hid_t, xfer_mode::Ptr{Cint})::herr_t "Error getting MPIO transfer mode" @bind h5p_get_edc_check(plist_id::hid_t)::H5Z_EDC_t "Error in h5p_get_edc_check (not annotated)" @bind h5p_get_elink_acc_flags(lapl_id::hid_t, flags::Ptr{Cuint})::herr_t "Error in h5p_get_elink_acc_flags (not annotated)" @@ -278,7 +308,7 @@ @bind h5p_set_data_transform(plist_id::hid_t, expression::Ptr{Cchar})::herr_t "Error in h5p_set_data_transform (not annotated)" @bind h5p_set_driver(plist_id::hid_t, driver_id::hid_t, driver_info::Ptr{Cvoid})::herr_t "Error in h5p_set_driver (not annotated)" @bind h5p_set_deflate(plist_id::hid_t, setting::Cuint)::herr_t "Error setting compression method and level (deflate)" -@bind h5p_set_dset_no_attrs_hint(dcpl_id::hid_t, minimize::hbool_t)::herr_t "Error in h5p_set_dset_no_attrs_hint (not annotated)" +@bind h5p_set_dset_no_attrs_hint(dcpl_id::hid_t, minimize::hbool_t)::herr_t "Error in setting dataset no attributes hint property" @bind h5p_set_dxpl_mpio(dxpl_id::hid_t, xfer_mode::Cint)::herr_t "Error setting MPIO transfer mode" @bind h5p_set_edc_check(plist_id::hid_t, check::H5Z_EDC_t)::herr_t "Error in h5p_set_edc_check (not annotated)" @bind h5p_set_est_link_info(plist_id::hid_t, est_num_entries::Cuint, est_name_len::Cuint)::herr_t "Error in h5p_set_est_link_info (not annotated)" diff --git a/src/api/functions.jl b/src/api/functions.jl index d0b995326..9e2101489 100644 --- a/src/api/functions.jl +++ b/src/api/functions.jl @@ -685,6 +685,17 @@ function h5e_walk(stack_id, direction, op, op_data) return nothing end +""" + h5f_clear_elink_file_cache(file_id::hid_t) + +See `libhdf5` documentation for [`H5Fclear_elink_file_cache`](https://portal.hdfgroup.org/display/HDF5/H5F_CLEAR_ELINK_FILE_CACHE). +""" +function h5f_clear_elink_file_cache(file_id) + var"#status#" = ccall((:H5Fclear_elink_file_cache, libhdf5), herr_t, (hid_t,), file_id) + var"#status#" < 0 && @h5error("Error in h5f_clear_elink_file_cache (not annotated)") + return nothing +end + """ h5f_close(file_id::hid_t) @@ -707,6 +718,17 @@ function h5f_create(pathname, flags, fcpl_id, fapl_id) return var"#status#" end +""" + h5f_delete(filename::Ptr{Cchar}, fapl_id::hid_t) + +See `libhdf5` documentation for [`H5Fdelete`](https://portal.hdfgroup.org/display/HDF5/H5F_DELETE). +""" +function h5f_delete(filename, fapl_id) + var"#status#" = ccall((:H5Fdelete, libhdf5), herr_t, (Ptr{Cchar}, hid_t), filename, fapl_id) + var"#status#" < 0 && @h5error("Error in h5f_delete (not annotated)") + return nothing +end + """ h5f_flush(object_id::hid_t, scope::Cint) @@ -718,6 +740,17 @@ function h5f_flush(object_id, scope) return nothing end +""" + h5f_format_convert(fid::hid_t) + +See `libhdf5` documentation for [`H5Fformat_convert`](https://portal.hdfgroup.org/display/HDF5/H5F_FORMAT_CONVERT). +""" +function h5f_format_convert(fid) + var"#status#" = ccall((:H5Fformat_convert, libhdf5), herr_t, (hid_t,), fid) + var"#status#" < 0 && @h5error("Error in h5f_format_convert (not annotated)") + return nothing +end + """ h5f_get_access_plist(file_id::hid_t) -> hid_t @@ -740,6 +773,61 @@ function h5f_get_create_plist(file_id) return var"#status#" end +""" + h5f_get_dset_no_attrs_hint(file_id::hid_t, minimize::Ptr{hbool_t}) + +See `libhdf5` documentation for [`H5Fget_dset_no_attrs_hint`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_DSET_NO_ATTRS_HINT). +""" +function h5f_get_dset_no_attrs_hint(file_id, minimize) + var"#status#" = ccall((:H5Fget_dset_no_attrs_hint, libhdf5), herr_t, (hid_t, Ptr{hbool_t}), file_id, minimize) + var"#status#" < 0 && @h5error("Error getting dataset no attributes hint") + return nothing +end + +""" + h5f_get_eoa(file_id::hid_t, eoa::Ptr{haddr_t}) + +See `libhdf5` documentation for [`H5Fget_eoa`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_EOA). +""" +function h5f_get_eoa(file_id, eoa) + var"#status#" = ccall((:H5Fget_eoa, libhdf5), herr_t, (hid_t, Ptr{haddr_t}), file_id, eoa) + var"#status#" < 0 && @h5error("Error in h5f_get_eoa (not annotated)") + return nothing +end + +""" + h5f_get_file_image(file_id::hid_t, buf_ptr::Ptr{Cvoid}, buf_len::Csize_t) -> Cssize_t + +See `libhdf5` documentation for [`H5Fget_file_image`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_FILE_IMAGE). +""" +function h5f_get_file_image(file_id, buf_ptr, buf_len) + var"#status#" = ccall((:H5Fget_file_image, libhdf5), Cssize_t, (hid_t, Ptr{Cvoid}, Csize_t), file_id, buf_ptr, buf_len) + var"#status#" < 0 && @h5error("Error in h5f_get_file_image (not annotated)") + return var"#status#" +end + +""" + h5f_get_fileno(file_id::hid_t, fileno::Ptr{Culong}) + +See `libhdf5` documentation for [`H5Fget_fileno`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_FILENO). +""" +function h5f_get_fileno(file_id, fileno) + var"#status#" = ccall((:H5Fget_fileno, libhdf5), herr_t, (hid_t, Ptr{Culong}), file_id, fileno) + var"#status#" < 0 && @h5error("Error in h5f_get_fileno (not annotated)") + return nothing +end + +""" + h5f_get_filesize(file_id::hid_t, size::Ptr{hsize_t}) + +See `libhdf5` documentation for [`H5Fget_filesize`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_FILESIZE). +""" +function h5f_get_filesize(file_id, size) + var"#status#" = ccall((:H5Fget_filesize, libhdf5), herr_t, (hid_t, Ptr{hsize_t}), file_id, size) + var"#status#" < 0 && @h5error("Error in h5f_get_filesize (not annotated)") + return nothing +end + """ h5f_get_free_sections(file_id::hid_t, type::H5F_mem_t, nsects::Csize_t, sect_info::Ptr{H5F_sect_info_t}) -> Cssize_t @@ -773,6 +861,94 @@ function h5f_get_intent(file_id, intent) return nothing end +""" + h5f_get_info(obj_id::hid_t, file_info::Ptr{H5F_info2_t}) + +See `libhdf5` documentation for [`H5Fget_info2`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_INFO2). +""" +function h5f_get_info(obj_id, file_info) + var"#status#" = ccall((:H5Fget_info2, libhdf5), herr_t, (hid_t, Ptr{H5F_info2_t}), obj_id, file_info) + var"#status#" < 0 && @h5error("Error in h5f_get_info2 (not annotated)") + return nothing +end + +""" + h5f_get_mdc_config(file_id::hid_t, config_ptr::Ptr{H5AC_cache_config_t}) + +See `libhdf5` documentation for [`H5Fget_mdc_config`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_MDC_CONFIG). +""" +function h5f_get_mdc_config(file_id, config_ptr) + var"#status#" = ccall((:H5Fget_mdc_config, libhdf5), herr_t, (hid_t, Ptr{H5AC_cache_config_t}), file_id, config_ptr) + var"#status#" < 0 && @h5error("Error in h5f_get_mdc_config (not annotated)") + return nothing +end + +""" + h5f_get_mdc_hit_rate(file_id::hid_t, hit_rate_ptr::Ptr{Cdouble}) + +See `libhdf5` documentation for [`H5Fget_mdc_hit_rate`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_MDC_HIT_RATE). +""" +function h5f_get_mdc_hit_rate(file_id, hit_rate_ptr) + var"#status#" = ccall((:H5Fget_mdc_hit_rate, libhdf5), herr_t, (hid_t, Ptr{Cdouble}), file_id, hit_rate_ptr) + var"#status#" < 0 && @h5error("Error in h5f_get_mdc_hit_rate (not annotated)") + return nothing +end + +""" + h5f_get_mdc_image_info(file_id::hid_t, image_addr::Ptr{haddr_t}, image_size::Ptr{hsize_t}) + +See `libhdf5` documentation for [`H5Fget_mdc_image_info`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_MDC_IMAGE_INFO). +""" +function h5f_get_mdc_image_info(file_id, image_addr, image_size) + var"#status#" = ccall((:H5Fget_mdc_image_info, libhdf5), herr_t, (hid_t, Ptr{haddr_t}, Ptr{hsize_t}), file_id, image_addr, image_size) + var"#status#" < 0 && @h5error("Error in h5f_get_mdc_image_info (not annotated)") + return nothing +end + +""" + h5f_get_mdc_logging_status(file_id::hid_t, is_enabled::Ptr{hbool_t}, is_currently_logging::Ptr{hbool_t}) + +See `libhdf5` documentation for [`H5Fget_mdc_logging_status`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_MDC_LOGGING_STATUS). +""" +function h5f_get_mdc_logging_status(file_id, is_enabled, is_currently_logging) + var"#status#" = ccall((:H5Fget_mdc_logging_status, libhdf5), herr_t, (hid_t, Ptr{hbool_t}, Ptr{hbool_t}), file_id, is_enabled, is_currently_logging) + var"#status#" < 0 && @h5error("Error in h5f_get_mdc_logging_status (not annotated)") + return nothing +end + +""" + h5f_get_mdc_size(file_id::hid_t, max_size_ptr::Ptr{Csize_t}, min_clean_size_ptr::Ptr{Csize_t}, cur_size_ptr::Ptr{Csize_t}, cur_num_entries_ptr::Ptr{Cint}) + +See `libhdf5` documentation for [`H5Fget_mdc_size`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_MDC_SIZE). +""" +function h5f_get_mdc_size(file_id, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) + var"#status#" = ccall((:H5Fget_mdc_size, libhdf5), herr_t, (hid_t, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Csize_t}, Ptr{Cint}), file_id, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) + var"#status#" < 0 && @h5error("Error in h5f_get_mdc_size (not annotated)") + return nothing +end + +""" + h5f_get_metadata_read_retry_info(file_id::hid_t, info::Ptr{H5F_retry_info_t}) + +See `libhdf5` documentation for [`H5Fget_metadata_read_retry_info`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_METADATA_READ_RETRY_INFO). +""" +function h5f_get_metadata_read_retry_info(file_id, info) + var"#status#" = ccall((:H5Fget_metadata_read_retry_info, libhdf5), herr_t, (hid_t, Ptr{H5F_retry_info_t}), file_id, info) + var"#status#" < 0 && @h5error("Error in h5f_get_metadata_read_retry_info (not annotated)") + return nothing +end + +""" + h5f_get_mpi_atomicity(file_id::hid_t, flag::Ptr{hbool_t}) + +See `libhdf5` documentation for [`H5Fget_mpi_atomicity`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_MPI_ATOMICITY). +""" +function h5f_get_mpi_atomicity(file_id, flag) + var"#status#" = ccall((:H5Fget_mpi_atomicity, libhdf5), herr_t, (hid_t, Ptr{hbool_t}), file_id, flag) + var"#status#" < 0 && @h5error("Error in h5f_get_mpi_atomicity (not annotated)") + return nothing +end + """ h5f_get_name(obj_id::hid_t, buf::Ptr{UInt8}, buf_size::Csize_t) -> Cssize_t @@ -806,6 +982,17 @@ function h5f_get_obj_ids(file_id, types, max_objs, obj_id_list) return var"#status#" end +""" + h5f_get_page_buffering_stats(file_id::hid_t, accesses::Ptr{Cuint}, hits::Ptr{Cuint}, misses::Ptr{Cuint}, evictions::Ptr{Cuint}, bypasses::Ptr{Cuint}) + +See `libhdf5` documentation for [`H5Fget_page_buffering_stats`](https://portal.hdfgroup.org/display/HDF5/H5F_GET_PAGE_BUFFERING_STATS). +""" +function h5f_get_page_buffering_stats(file_id, accesses, hits, misses, evictions, bypasses) + var"#status#" = ccall((:H5Fget_page_buffering_stats, libhdf5), herr_t, (hid_t, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}, Ptr{Cuint}), file_id, accesses, hits, misses, evictions, bypasses) + var"#status#" < 0 && @h5error("Error in h5f_get_page_buffering_stats (not annotated)") + return nothing +end + """ h5f_get_vfd_handle(file_id::hid_t, fapl_id::hid_t, file_handle::Ref{Ptr{Cvoid}}) @@ -817,6 +1004,28 @@ function h5f_get_vfd_handle(file_id, fapl_id, file_handle) return nothing end +""" + h5f_increment_filesize(file_id::hid_t, increment::hsize_t) + +See `libhdf5` documentation for [`H5Fincrement_filesize`](https://portal.hdfgroup.org/display/HDF5/H5F_INCREMENT_FILESIZE). +""" +function h5f_increment_filesize(file_id, increment) + var"#status#" = ccall((:H5Fincrement_filesize, libhdf5), herr_t, (hid_t, hsize_t), file_id, increment) + var"#status#" < 0 && @h5error("Error in h5f_increment_filesize (not annotated)") + return nothing +end + +""" + h5f_is_accessible(container_name::Ptr{Cchar}, fapl_id::hid_t) -> Bool + +See `libhdf5` documentation for [`H5Fis_accessible`](https://portal.hdfgroup.org/display/HDF5/H5F_IS_ACCESSIBLE). +""" +function h5f_is_accessible(container_name, fapl_id) + var"#status#" = ccall((:H5Fis_accessible, libhdf5), htri_t, (Ptr{Cchar}, hid_t), container_name, fapl_id) + var"#status#" < 0 && @h5error("Error in h5f_is_accessible (not annotated)") + return var"#status#" > 0 +end + """ h5f_is_hdf5(pathname::Cstring) -> Bool @@ -828,6 +1037,17 @@ function h5f_is_hdf5(pathname) return var"#status#" > 0 end +""" + h5f_mount(loc::hid_t, name::Ptr{Cchar}, child::hid_t, plist::hid_t) + +See `libhdf5` documentation for [`H5Fmount`](https://portal.hdfgroup.org/display/HDF5/H5F_MOUNT). +""" +function h5f_mount(loc, name, child, plist) + var"#status#" = ccall((:H5Fmount, libhdf5), herr_t, (hid_t, Ptr{Cchar}, hid_t, hid_t), loc, name, child, plist) + var"#status#" < 0 && @h5error("Error in h5f_mount (not annotated)") + return nothing +end + """ h5f_open(pathname::Cstring, flags::Cuint, fapl_id::hid_t) -> hid_t @@ -839,6 +1059,94 @@ function h5f_open(pathname, flags, fapl_id) return var"#status#" end +""" + h5f_reopen(file_id::hid_t) -> hid_t + +See `libhdf5` documentation for [`H5Freopen`](https://portal.hdfgroup.org/display/HDF5/H5F_REOPEN). +""" +function h5f_reopen(file_id) + var"#status#" = ccall((:H5Freopen, libhdf5), hid_t, (hid_t,), file_id) + var"#status#" < 0 && @h5error("Error in h5f_reopen (not annotated)") + return var"#status#" +end + +""" + h5f_reset_mdc_hit_rate_stats(file_id::hid_t) + +See `libhdf5` documentation for [`H5Freset_mdc_hit_rate_stats`](https://portal.hdfgroup.org/display/HDF5/H5F_RESET_MDC_HIT_RATE_STATS). +""" +function h5f_reset_mdc_hit_rate_stats(file_id) + var"#status#" = ccall((:H5Freset_mdc_hit_rate_stats, libhdf5), herr_t, (hid_t,), file_id) + var"#status#" < 0 && @h5error("Error in h5f_reset_mdc_hit_rate_stats (not annotated)") + return nothing +end + +""" + h5f_reset_page_buffering_stats(file_id::hid_t) + +See `libhdf5` documentation for [`H5Freset_page_buffering_stats`](https://portal.hdfgroup.org/display/HDF5/H5F_RESET_PAGE_BUFFERING_STATS). +""" +function h5f_reset_page_buffering_stats(file_id) + var"#status#" = ccall((:H5Freset_page_buffering_stats, libhdf5), herr_t, (hid_t,), file_id) + var"#status#" < 0 && @h5error("Error in h5f_reset_page_buffering_stats (not annotated)") + return nothing +end + +""" + h5f_set_dset_no_attrs_hint(file_id::hid_t, minimize::hbool_t) + +See `libhdf5` documentation for [`H5Fset_dset_no_attrs_hint`](https://portal.hdfgroup.org/display/HDF5/H5F_SET_DSET_NO_ATTRS_HINT). +""" +function h5f_set_dset_no_attrs_hint(file_id, minimize) + var"#status#" = ccall((:H5Fset_dset_no_attrs_hint, libhdf5), herr_t, (hid_t, hbool_t), file_id, minimize) + var"#status#" < 0 && @h5error("Error in setting dataset no attributes hint") + return nothing +end + +""" + h5f_set_libver_bounds(file_id::hid_t, low::H5F_libver_t, high::H5F_libver_t) + +See `libhdf5` documentation for [`H5Fset_libver_bounds`](https://portal.hdfgroup.org/display/HDF5/H5F_SET_LIBVER_BOUNDS). +""" +function h5f_set_libver_bounds(file_id, low, high) + var"#status#" = ccall((:H5Fset_libver_bounds, libhdf5), herr_t, (hid_t, H5F_libver_t, H5F_libver_t), file_id, low, high) + var"#status#" < 0 && @h5error("Error in h5f_set_libver_bounds (not annotated)") + return nothing +end + +""" + h5f_set_mdc_config(file_id::hid_t, config_ptr::Ptr{H5AC_cache_config_t}) + +See `libhdf5` documentation for [`H5Fset_mdc_config`](https://portal.hdfgroup.org/display/HDF5/H5F_SET_MDC_CONFIG). +""" +function h5f_set_mdc_config(file_id, config_ptr) + var"#status#" = ccall((:H5Fset_mdc_config, libhdf5), herr_t, (hid_t, Ptr{H5AC_cache_config_t}), file_id, config_ptr) + var"#status#" < 0 && @h5error("Error in h5f_set_mdc_config (not annotated)") + return nothing +end + +""" + h5f_set_mpi_atomicity(file_id::hid_t, flag::hbool_t) + +See `libhdf5` documentation for [`H5Fset_mpi_atomicity`](https://portal.hdfgroup.org/display/HDF5/H5F_SET_MPI_ATOMICITY). +""" +function h5f_set_mpi_atomicity(file_id, flag) + var"#status#" = ccall((:H5Fset_mpi_atomicity, libhdf5), herr_t, (hid_t, hbool_t), file_id, flag) + var"#status#" < 0 && @h5error("Error in h5f_set_mpi_atomicity (not annotated)") + return nothing +end + +""" + h5f_start_mdc_logging(file_id::hid_t) + +See `libhdf5` documentation for [`H5Fstart_mdc_logging`](https://portal.hdfgroup.org/display/HDF5/H5F_START_MDC_LOGGING). +""" +function h5f_start_mdc_logging(file_id) + var"#status#" = ccall((:H5Fstart_mdc_logging, libhdf5), herr_t, (hid_t,), file_id) + var"#status#" < 0 && @h5error("Error in h5f_start_mdc_logging (not annotated)") + return nothing +end + """ h5f_start_swmr_write(id::hid_t) @@ -850,6 +1158,28 @@ function h5f_start_swmr_write(id) return nothing end +""" + h5f_stop_mdc_logging(file_id::hid_t) + +See `libhdf5` documentation for [`H5Fstop_mdc_logging`](https://portal.hdfgroup.org/display/HDF5/H5F_STOP_MDC_LOGGING). +""" +function h5f_stop_mdc_logging(file_id) + var"#status#" = ccall((:H5Fstop_mdc_logging, libhdf5), herr_t, (hid_t,), file_id) + var"#status#" < 0 && @h5error("Error in h5f_stop_mdc_logging (not annotated)") + return nothing +end + +""" + h5f_unmount(loc::hid_t, name::Ptr{Cchar}) + +See `libhdf5` documentation for [`H5Funmount`](https://portal.hdfgroup.org/display/HDF5/H5F_UNMOUNT). +""" +function h5f_unmount(loc, name) + var"#status#" = ccall((:H5Funmount, libhdf5), herr_t, (hid_t, Ptr{Cchar}), loc, name) + var"#status#" < 0 && @h5error("Error in h5f_unmount (not annotated)") + return nothing +end + """ h5g_close(group_id::hid_t) @@ -1400,7 +1730,7 @@ See `libhdf5` documentation for [`H5Pget_dset_no_attrs_hint`](https://portal.hdf """ function h5p_get_dset_no_attrs_hint(dcpl_id, minimize) var"#status#" = ccall((:H5Pget_dset_no_attrs_hint, libhdf5), herr_t, (hid_t, Ptr{hbool_t}), dcpl_id, minimize) - var"#status#" < 0 && @h5error("Error in h5p_get_dset_no_attrs_hint (not annotated)") + var"#status#" < 0 && @h5error("Error in getting dataset no attributes hint property") return nothing end @@ -2302,7 +2632,7 @@ See `libhdf5` documentation for [`H5Pset_dset_no_attrs_hint`](https://portal.hdf """ function h5p_set_dset_no_attrs_hint(dcpl_id, minimize) var"#status#" = ccall((:H5Pset_dset_no_attrs_hint, libhdf5), herr_t, (hid_t, hbool_t), dcpl_id, minimize) - var"#status#" < 0 && @h5error("Error in h5p_set_dset_no_attrs_hint (not annotated)") + var"#status#" < 0 && @h5error("Error in setting dataset no attributes hint property") return nothing end diff --git a/src/api/helpers.jl b/src/api/helpers.jl index f0410a886..61d2d4ee4 100644 --- a/src/api/helpers.jl +++ b/src/api/helpers.jl @@ -21,6 +21,15 @@ function h5_is_library_threadsafe() return is_ts[] > 0 end +### +### HDF5 File Interface +### +function h5f_get_dset_no_attrs_hint(file_id)::Bool + minimize = Ref{hbool_t}(false) + h5f_get_dset_no_attrs_hint(file_id, minimize) + return minimize[] +end + ### ### Attribute Interface ### @@ -497,6 +506,12 @@ function h5p_get_link_creation_order(p) return link[] end +function h5p_get_dset_no_attrs_hint(dcpl)::hbool_t + minimize = Ref{hbool_t}(false) + h5p_get_dset_no_attrs_hint(dcpl, minimize) + return minimize[] > 0 +end + ### ### Plugin Interface ### diff --git a/src/api/types.jl b/src/api/types.jl index 2feeb8903..770f9ec76 100644 --- a/src/api/types.jl +++ b/src/api/types.jl @@ -212,10 +212,14 @@ const H5F_ACC_SWMR_WRITE = 0x0020 const H5F_ACC_SWMR_READ = 0x0040 # Library versions -const H5F_LIBVER_EARLIEST = 0 -const H5F_LIBVER_V18 = 1 -const H5F_LIBVER_V110 = 2 -const H5F_LIBVER_V112 = 3 +@enum H5F_libver_t::Int32 begin + H5F_LIBVER_ERROR = -1 + H5F_LIBVER_EARLIEST = 0 + H5F_LIBVER_V18 = 1 + H5F_LIBVER_V110 = 2 + H5F_LIBVER_V112 = 3 + H5F_LIBVER_NBOUNDS = 4 +end # H5F_LIBVER_LATEST defined in helpers.jl # object types @@ -601,3 +605,32 @@ end H5D_FILL_VALUE_DEFAULT = 1 H5D_FILL_VALUE_USER_DEFINED = 2 end + +struct H5F_info2_super + version::Cuint + super_size::hsize_t + super_ext_size::hsize_t +end + +struct H5F_info2_free + version::Cuint + meta_size::hsize_t + tot_space::hsize_t +end + +struct H5F_info2_sohm + version::Cuint + hdr_size::hsize_t + msgs_info::H5_ih_info_t +end + +struct H5F_info2_t + super::H5F_info2_super + free::H5F_info2_free + sohm::H5F_info2_sohm +end + +struct H5F_retry_info_t + nbins::Cuint + retries::NTuple{21, Ptr{UInt32}} +end diff --git a/src/api_midlevel.jl b/src/api_midlevel.jl index 88a7bd85d..0bb0bd007 100644 --- a/src/api_midlevel.jl +++ b/src/api_midlevel.jl @@ -198,4 +198,4 @@ function set_fill_value!(plist_id, value) ref_value = Ref(value) API.h5p_set_fill_value(plist_id, datatype(value), ref_value) return plist_id -end \ No newline at end of file +end diff --git a/src/properties.jl b/src/properties.jl index 3a19fafee..354b00b1d 100644 --- a/src/properties.jl +++ b/src/properties.jl @@ -412,6 +412,11 @@ Properties used when creating a new `Dataset`. Inherits from See $(h5doc("H5P_SET_LAYOUT")). +- `no_attrs_hint`: Minimize the space for dataset metadata by hinting that no + attributes will be added if set to `true`. Attributes can still be added but + may exist elsewhere within the file. + See $(h5doc("H5P_SET_DSET_NO_ATTRS_HINT")). + The following options are shortcuts for the various filters, and are set-only. They will be appended to the filter pipeline in the order in which they appear @@ -477,6 +482,7 @@ class_propertynames(::Type{DatasetCreateProperties}) = ( :external, :filters, :layout, + :no_attrs_hint, # convenience :blosc, :deflate, @@ -496,6 +502,11 @@ function class_getproperty(::Type{DatasetCreateProperties}, p::Properties, name: name === :external ? API.h5p_get_external(p) : name === :filters ? get_filters(p) : name === :layout ? get_layout(p) : + name === :no_attrs_hint ? + @static(API.h5_get_libversion() < v"1.10.5" ? + false : + API.h5p_get_dset_no_attrs_hint(p) + ) : # deprecated name === :filter ? (depwarn("`filter` property name is deprecated, use `filters` instead",:class_getproperty); get_filters(p)) : class_getproperty(superclass(DatasetCreateProperties), p, name) @@ -508,6 +519,11 @@ function class_setproperty!(::Type{DatasetCreateProperties}, p::Properties, name name === :external ? API.h5p_set_external(p, val...) : name === :filters ? set_filters!(p, val) : name === :layout ? set_layout!(p, val) : + name === :no_attrs_hint ? + @static(API.h5_get_libversion() < v"1.10.5" ? + error("no_attrs_hint is only valid for HDF5 library versions 1.10.5 or greater") : + API.h5p_set_dset_no_attrs_hint(p, val) + ) : # set-only for convenience name === :blosc ? set_blosc!(p, val) : name === :deflate ? set_deflate!(p, val) : @@ -620,6 +636,7 @@ Properties used when accessing files. # getter/setter for libver_bounds libver_bound_to_enum(val::Integer) = val +libver_bound_to_enum(val::API.H5F_libver_t) = val function libver_bound_to_enum(val::VersionNumber) val >= v"1.12" ? API.H5F_LIBVER_V112 : val >= v"1.10" ? API.H5F_LIBVER_V110 : @@ -631,13 +648,14 @@ function libver_bound_to_enum(val::Symbol) val == :latest ? libver_bound_to_enum(libversion) : throw(ArgumentError("Invalid libver_bound $val.")) end -function libver_bound_from_enum(enum) +function libver_bound_from_enum(enum::API.H5F_libver_t) enum == API.H5F_LIBVER_EARLIEST ? :earliest : enum == API.H5F_LIBVER_V18 ? v"1.8" : enum == API.H5F_LIBVER_V110 ? v"1.10" : enum == API.H5F_LIBVER_V112 ? v"1.12" : error("Unknown libver_bound value $enum") end +libver_bound_from_enum(enum) = libver_bound_from_enum(API.H5F_libver_t(enum)) function get_libver_bounds(p::Properties) low, high = API.h5p_get_libver_bounds(p) return libver_bound_from_enum(low), libver_bound_from_enum(high) diff --git a/test/fileio.jl b/test/fileio.jl index be1861a6b..d3753aa7d 100644 --- a/test/fileio.jl +++ b/test/fileio.jl @@ -60,4 +60,37 @@ let fn = tempname() * ".h5" @test all(keys(dat) .== ["b", "a", "G/z", "G/f"]) end +end # @testset track_order + +@static if HDF5.API.h5_get_libversion() >= v"1.10.5" + +@testset "h5f_get_dset_no_attrs_hint" begin + fn = tempname() + threshold = 300 + h5open( + fn, "w"; + libver_bounds = :latest, + meta_block_size = threshold + ) do f + HDF5.API.h5f_set_dset_no_attrs_hint(f, true) + @test HDF5.API.h5f_get_dset_no_attrs_hint(f) + f["test"] = 0x1 + # We expect that with the hint, the offset will actually be 300 + @test HDF5.API.h5d_get_offset(f["test"]) == threshold + end + @test filesize(fn) == threshold + 1 + h5open( + fn, "w"; + libver_bounds = :latest, + meta_block_size = threshold + ) do f + HDF5.API.h5f_set_dset_no_attrs_hint(f, false) + @test !HDF5.API.h5f_get_dset_no_attrs_hint(f) + f["test"] = 0x1 + # We expect that with the hint, the offset will be greater than 300 + @test HDF5.API.h5d_get_offset(f["test"]) > threshold + end + @test filesize(fn) > threshold + 1 end + +end # @static if HDF5.API.h5_get_libversion() >= v"1.10.5" diff --git a/test/properties.jl b/test/properties.jl index 9907fb750..bead49338 100644 --- a/test/properties.jl +++ b/test/properties.jl @@ -16,12 +16,18 @@ h5open(fn, "w"; ) do hfile # generic g = create_group(hfile, "group") - d = create_dataset(g, "dataset", datatype(Int), dataspace((500,500)), + if HDF5.API.h5_get_libversion() >= v"1.10.5" + kwargs = (:no_attrs_hint => true,) + else + kwargs = () + end + d = create_dataset(g, "dataset", datatype(Int), dataspace((500,50)); alloc_time = HDF5.API.H5D_ALLOC_TIME_EARLY, chunk = (5, 10), fill_value = 1, fill_time = :never, - obj_track_times = false) + obj_track_times = false, + kwargs...) attributes(d)["metadata"] = "test" flush(hfile) @@ -66,6 +72,9 @@ h5open(fn, "w"; @test !dcpl.obj_track_times @test dcpl.fill_time == :never @test dcpl.fill_value == 1.0 + if HDF5.API.h5_get_libversion() >= v"1.10.5" + @test dcpl.no_attrs_hint == true + end @test acpl.char_encoding == :utf8