fix: variable-length string attribute reading (Issue #14)#15
Merged
Conversation
Root causes fixed: - V1/V2 attribute message 8-byte alignment (H5O_ALIGN_OLD macro) - IsVariableString() now checks ClassBitField instead of Properties - VLen string format: 4-byte length prefix + Global Heap reference Changes: - internal/core/attribute.go: Added DatatypeVarLen case to ReadValue() - internal/core/datatype.go: Fixed IsVariableString() per HDF5 spec III.A.2.4.d - Updated all documentation examples to use attr.ReadValue() Files created by h5py now work correctly. Closes #14
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
Fixes #14 - Users couldn't read attributes from HDF5 files created by h5py.
Root causes identified and fixed:
V1/V2 Attribute Alignment: Name, datatype, and dataspace fields must be padded to 8-byte boundaries (per
H5O_ALIGN_OLDmacro in C library)IsVariableString() Detection: Was checking
Properties[0] & 0x0F == DatatypeString, but per HDF5 Format Spec III.A.2.4.d, variable-length string type is indicated byClassBitField & 0x0F == 1VLen String Data Format: Variable-length strings include a 4-byte length prefix before the Global Heap reference, making the total size
4 + offsetSize + 4bytesChanges:
internal/core/attribute.go- AddedDatatypeVarLencase toReadValue(), fixed 8-byte alignmentinternal/core/datatype.go- FixedIsVariableString()to checkClassBitFieldcorrectlyinternal/core/attribute_test.go- Added unit tests for vlen string attributesattr.ReadValue()APITest Results
Test plan
IsVariableString()detectionReadValue()error cases