# HDF5 variable-length string storage
Original code and observations: CC0-1.0. Third-party libraries and sources keep their licenses.
Evidence type: controlled synthetic library experiment, not a new compression algorithm.

## Reproduce
Use Python 3.12 and install requirements.txt in an isolated environment:
```sh
python3 -m venv .venv
.venv/bin/pip install --only-binary=:all: -r requirements.txt
.venv/bin/python test_hdf5_vlen_storage.py
.venv/bin/python hdf5_vlen_storage.py --output observations.json --csv observations.csv
```
The published build uses h5py 3.15.0, HDF5 1.14.6, NumPy 2.3.3 and zlib 1.3 on Linux x86_64.
Pinned Python packages do not pin every wheel's HDF5/zlib or platform build: inspect environment in the output.
The runner holds each file in BytesIO, closes it, and freshly reopens its bytes. No fixture files are retained.
Only the requested JSON and CSV outputs are written. Output paths are replaced when explicitly provided.

## Design
1,024 records per fixture; maximum length 64 or 1,024 bytes; cyclic lengths maximum/4, maximum/2, maximum.
Contents: ASCII A repetitions or deterministic SHA-256 hexadecimal blocks of index:block, truncated to length.
No sampled population, entropy estimate or random seed.
Layouts: variable-length ASCII strings; fixed-width byte strings at the maximum;
or a uint8 payload plus little-endian uint64 offsets, including a terminal offset.
String and offset chunks: 64 elements (last offset chunk can be partially populated).
Payload chunks: 8,192 bytes. Every layout has gzip level 6 and uncompressed controls.
All use v110/v110 file-format bounds and no tracked dataset timestamps.
24 combinations x 3 repetitions = 72 closed-file/readback cases.

## Measurements and validation
payloadBytes sums input byte lengths. It excludes padding, terminators and offsets.
rawStorageBytes sums get_storage_size over all datasets; chunkStorageSum independently sums get_chunk_info sizes.
fileBytes is the closed BytesIO image length, not filesystem allocated blocks.
outsideRawStorageBytes = fileBytes - rawStorageBytes: includes heap, metadata, alignment and other file space.
numpyNbytesSum is the sum of Dataset.nbytes; object arrays do not include pointed-to strings in this number.
Per-dataset shape, chunks, NumPy itemsize, HDF5 type size, filter masks, compression and chunk count are recorded.
All masks must be zero and effective compression must match the requested option.
Round-trip checks compare every record's bytes and length. Digests include an 8-byte little-endian length
before each record, so different partitions of the same concatenated bytes are distinct.
fileSha256 identifies this build's file image; no claim that it is stable across library versions.
sourceSha256 identifies the exact runner. CSV flattens observation fields except nested datasets.
generatedAt records actual measurement time in UTC.
Negative tests reject over-width string conversion, embedded NUL, malformed offsets and invalid fixture parameters.

## Interpretation
For 611,328 repeated text bytes, gzip VLEN raw storage is 2,881 bytes while the file is 658,974 bytes.
The same-length hash-text control has identical VLEN sizes but different file and payload hashes.
Fixed-width and offsets results differ with content and padding; neither is a universal recommendation.
The uncompressed controls expose representation overhead. Repeats are reproducibility checks, not independent
performance samples, and no inferential confidence intervals are appropriate.
This does not measure speed, random-access cost, peak memory, encryption, checksums, corruption or crash durability.
Fixed-width changes need byte-length validation; offsets layouts need boundary validation and coherent
multi-dataset updates. See sources.json for primary contracts.

## Integration
Companion to /datasets/hdf5-chunk-cache-reads/ and the variable-length section of the existing COM analysis.
The original cache dataset, row count, columns and JSON contract are unchanged.
