Merge branch 'fix/p0-writer-meta' into fix/phase0-correctness
This commit is contained in:
@@ -478,7 +478,12 @@ impl<'f> Dataset<'f> {
|
||||
// sparse) dataset — select from a fill-aware full read instead. (The
|
||||
// selection reader currently decodes the full dataset too, so this
|
||||
// costs nothing extra.)
|
||||
let fill = clawhdf5_format::fill_value::dataset_fill_value(&self.header.messages)?;
|
||||
let fill = clawhdf5_format::fill_value::dataset_fill_value_in(
|
||||
self.file.data.as_bytes(),
|
||||
&self.header.messages,
|
||||
self.file.offset_size(),
|
||||
self.file.length_size(),
|
||||
)?;
|
||||
let fill_matters = !clawhdf5_format::fill_value::has_storage(&dl)
|
||||
|| (matches!(dl, DataLayout::Chunked { .. })
|
||||
&& !clawhdf5_format::fill_value::is_default(fill.as_deref()));
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
//! Datasets whose Fill Value message is shared through the file's SOHM heap
|
||||
//! (fixture written by HDF5 2.0, see `gen_shared_fill.py`). Their unwritten
|
||||
//! storage must read as the fill value (-7), not as zeros.
|
||||
|
||||
use clawhdf5::File;
|
||||
use clawhdf5_format::selection::Selection;
|
||||
|
||||
const FIXTURE: &[u8] = include_bytes!("../../clawhdf5-format/tests/fixtures/shared_fill_value.h5");
|
||||
|
||||
#[test]
|
||||
fn shared_fill_value_applies_to_unwritten_storage() {
|
||||
let file = File::from_bytes(FIXTURE.to_vec()).unwrap();
|
||||
// `_a` keeps its fill value in its own header, `_b` references the SOHM
|
||||
// heap; both must read the same.
|
||||
for name in ["sohm_a", "sohm_b"] {
|
||||
assert_eq!(
|
||||
file.dataset(name).unwrap().read_i32().unwrap(),
|
||||
[0, 1, 2, 3, -7, -7, -7, -7],
|
||||
"{name}"
|
||||
);
|
||||
}
|
||||
for name in ["unwritten_a", "unwritten_b"] {
|
||||
assert_eq!(
|
||||
file.dataset(name).unwrap().read_i32().unwrap(),
|
||||
[-7, -7, -7],
|
||||
"{name}"
|
||||
);
|
||||
}
|
||||
|
||||
// The selection path decides on its own whether the fill value matters.
|
||||
let slab = Selection::Hyperslab {
|
||||
start: vec![2],
|
||||
stride: vec![1],
|
||||
count: vec![4],
|
||||
block: vec![1],
|
||||
};
|
||||
let raw = file
|
||||
.dataset("sohm_b")
|
||||
.unwrap()
|
||||
.read_selection(&slab)
|
||||
.unwrap();
|
||||
let values: Vec<i32> = raw
|
||||
.as_chunks::<4>()
|
||||
.0
|
||||
.iter()
|
||||
.map(|b| i32::from_le_bytes(*b))
|
||||
.collect();
|
||||
assert_eq!(values, [2, 3, -7, -7]);
|
||||
}
|
||||
Reference in New Issue
Block a user