Skip to content

Commit

Permalink
Compound subsetting through H5Tconvert and field selection
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Jan 25, 2024
1 parent c8e0237 commit 9979a64
Show file tree
Hide file tree
Showing 3 changed files with 511 additions and 32 deletions.
40 changes: 40 additions & 0 deletions src/rest_vol.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,33 @@ extern RV_type_info *RV_type_info_array_g[];
* *
**************************/

/* Values for the optimization of compound data reading and writing. They indicate
* whether the fields of the source and destination are subset of each other
*/
typedef enum {
H5T_SUBSET_BADVALUE = -1, /* Invalid value */
H5T_SUBSET_FALSE = 0, /* Source and destination aren't subset of each other */
H5T_SUBSET_SRC, /* Source is the subset of dest and no conversion is needed */
H5T_SUBSET_DST, /* Dest is the subset of source and no conversion is needed */
H5T_SUBSET_CAP /* Must be the last value */
} RV_subset_t;

/* Information about members of a compound type for subsetting */
typedef struct RV_compound_info_t {
RV_subset_t subset_info; /* Subset relationship between src and dst */

int nmembers; /* Number of offset/length pairs in the subset */
int nalloc; /* Number of offset/length pairs allocated */
size_t full_type_size; /* Size of compound type with all fields */

size_t *src_offsets; /* Offsets of fields within source datatype */
size_t *lengths; /* Lengths of members (in both datatypes) */

size_t subset_buf_size;
void *subset_buf;
void *subset_ptr; /* Pointer for writing into the subset buffer */
} RV_compound_info_t;

/*
* A struct which is used to return a link's name or the size of
* a link's name when calling H5Lget_name_by_idx.
Expand Down Expand Up @@ -604,6 +631,9 @@ typedef struct dataset_transfer_info {
void *tconv_buf;
void *bkg_buf;

/* Fields for writing to subsets of compound types */
RV_compound_info_t compound_info;

transfer_type_t transfer_type;

union {
Expand Down Expand Up @@ -764,6 +794,13 @@ herr_t RV_convert_datatype_to_JSON(hid_t type_id, char **type_body, size_t *type
/* Helper function to escape control characters for JSON strings */
herr_t RV_JSON_escape_string(const char *in, char *out, size_t *out_size);

/* Determine if a read from file to mem dtype is a compound subset read */
herr_t RV_get_compound_subset_info(hid_t src_type_id, hid_t dst_type_id, RV_subset_t *subset_info);

/* Helper to get information about members in dst that are included in src compound */
herr_t RV_get_compound_subset_members(hid_t src_type_id, hid_t dst_type_id,
RV_compound_info_t *compound_info);

#define SERVER_VERSION_MATCHES_OR_EXCEEDS(version, major_needed, minor_needed, patch_needed) \
(version.major > major_needed) || (version.major == major_needed && version.minor > minor_needed) || \
(version.major == major_needed && version.minor == minor_needed && version.patch >= patch_needed)
Expand All @@ -777,6 +814,9 @@ herr_t RV_JSON_escape_string(const char *in, char *out, size_t *out_size);
#define SERVER_VERSION_SUPPORTS_FIXED_LENGTH_UTF8(version) \
(SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 5))

#define SERVER_VERSION_SUPPORTS_MEMBER_SELECTION(version) \
(SERVER_VERSION_MATCHES_OR_EXCEEDS(version, 0, 8, 6))

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 9979a64

Please sign in to comment.