Skip to content

Vlen string attributes - #28

Merged
BenBrock merged 2 commits into
mainfrom
vlen-string-attributes
Jul 29, 2026
Merged

Vlen string attributes#28
BenBrock merged 2 commits into
mainfrom
vlen-string-attributes

Conversation

@BenBrock

Copy link
Copy Markdown
Contributor

No description provided.

BenBrock and others added 2 commits July 29, 2026 02:41
bsp_read_attribute_allocator sized its buffer with H5Tget_size(), which for
a variable-length string type returns the size of a pointer rather than the
length of the string, and H5Aread writes a pointer into that buffer.  Branch
on H5Tis_variable_str() so both layouts are read correctly.

The fixed-size path is unchanged, so files written by earlier versions of
Binsparse continue to be read.  This lands ahead of the corresponding writer
change so that no revision writes attributes it cannot read back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The binsparse JSON attribute was written with a fixed-size string type.
h5py surfaces that as a numpy.bytes_ of dtype |S<n> rather than as a str,
so callers have to know to decode it.  Write it as a variable-length UTF-8
string instead, which is what h5py itself produces and what Binsparse
already uses for string datasets.

The resulting datatype compares equal under H5Tequal to one written by
h5py, and h5py now returns a str.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@BenBrock
BenBrock merged commit db90573 into main Jul 29, 2026
3 checks passed
@BenBrock
BenBrock deleted the vlen-string-attributes branch July 29, 2026 04:20
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.

1 participant