fix: correct libaec constants, HDF5→libaec option mapping, and VDS serialization

Critical fixes from whole-branch code review:
- libaec-sys: fix flag constants to match <libaec.h> exactly
  (PREPROCESS=8, MSB=4, RESTRICTED=16; drop non-existent AEC_ALLOW_K13)
  and add aec_buffer_encode FFI declaration
- filters_szip: fix cd index for bits_per_sample (cd[2] per H5Z_SZIP_PARM_BPP,
  not cd[4]); fix option-mask mapping (NN=0x20, MSB unconditional); add two
  real encode→decode roundtrip tests (no-NN and NN) that exercise libaec end-to-end
- file_writer: fix serialize_vds_mappings to delegate to data_layout_write
  (eliminates the buggy duplicate that always emitted version=1 even for
  external-file mappings); retains trailing Jenkins checksum

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
Omar Sobh
2026-06-30 11:41:41 +00:00
co-authored by Claude Sonnet 4.6
parent e91f7fc539
commit cb0b0e9df2
3 changed files with 105 additions and 53 deletions
+6 -22
View File
@@ -805,30 +805,14 @@ fn serialize_attribute_info(fh_addr: u64, btree_name_addr: u64) -> Vec<u8> {
// ---- VDS helpers ----
/// Serialize VDS mappings into the on-disk format stored in the global heap.
/// Serialize VDS mappings for storage in a global heap object.
///
/// Layout (version 1, same-file references):
/// ```text
/// version(1) · nused(8, LE) · entry[nused]
/// ```
/// Each entry: same-file marker(0x04) · source_dataset\0 · source_sel · virtual_sel
/// Delegates to `data_layout_write::serialize_vds_mappings` (the canonical
/// implementation with full version/external-file handling), then appends a
/// trailing 4-byte Jenkins lookup3 checksum that parsers skip after consuming
/// all `nused` entries.
pub(crate) fn serialize_vds_mappings(mappings: &[VdsMapping]) -> Vec<u8> {
let mut buf = Vec::new();
buf.push(1u8); // block version 1 (same-file marker for "." source_file)
buf.extend_from_slice(&(mappings.len() as u64).to_le_bytes()); // nused
for m in mappings {
if m.source_file == "." {
buf.push(0x04); // same-file marker
} else {
buf.extend_from_slice(m.source_file.as_bytes());
buf.push(0); // null terminator
}
buf.extend_from_slice(m.source_dataset.as_bytes());
buf.push(0); // null terminator
buf.extend_from_slice(&m.source_selection);
buf.extend_from_slice(&m.virtual_selection);
}
// Checksum (4 bytes at end; parsers skip it after reaching nused entries)
let mut buf = crate::data_layout_write::serialize_vds_mappings(mappings, 8);
let cksum = crate::checksum::jenkins_lookup3(&buf);
buf.extend_from_slice(&cksum.to_le_bytes());
buf