Range reads M0/M1 (indexed lookups, Storage trait), ZFP, in-place editing #17

Merged
osobh merged 52 commits from feat/p3-range-zfp-edit into main 2026-09-26 20:42:22 +00:00
2 changed files with 17 additions and 10 deletions
Showing only changes of commit 24f0c71939 - Show all commits
+15 -8
View File
@@ -111,17 +111,24 @@ pub fn dataset_fill_value(messages: &[HeaderMessage]) -> Result<Option<Vec<u8>>,
/// fill value message to where it lives: another object header, or the /// fill value message to where it lives: another object header, or the
/// file's shared-message (SOHM) heap, as libhdf5 writes it when the file has /// file's shared-message (SOHM) heap, as libhdf5 writes it when the file has
/// a SOHM index for fill values. /// a SOHM index for fill values.
/// pub fn dataset_fill_value_in(
/// `file_data` is any [`Storage`](crate::storage::Storage): the file as a file_data: &[u8],
/// `&[u8]`, or a backend that serves it by range. (The trait is not messages: &[HeaderMessage],
/// imported here: its `len` would shadow the slice method in this module.) offset_size: u8,
pub fn dataset_fill_value_in<S: crate::storage::Storage + ?Sized>( length_size: u8,
file_data: &S, ) -> Result<Option<Vec<u8>>, FormatError> {
dataset_fill_value_from_storage(&file_data, messages, offset_size, length_size)
}
/// [`dataset_fill_value_in`] with the file behind any
/// [`Storage`](crate::storage::Storage). (The trait is not imported here:
/// its `len` would shadow the slice method in this module.)
pub fn dataset_fill_value_from_storage(
file: &dyn crate::storage::Storage,
messages: &[HeaderMessage], messages: &[HeaderMessage],
offset_size: u8, offset_size: u8,
length_size: u8, length_size: u8,
) -> Result<Option<Vec<u8>>, FormatError> { ) -> Result<Option<Vec<u8>>, FormatError> {
let file: &dyn crate::storage::Storage = &file_data;
fill_value_from(messages, |msg| { fill_value_from(messages, |msg| {
crate::shared_message::message_data_with_sohm_in(file, msg, offset_size, length_size) crate::shared_message::message_data_with_sohm_in(file, msg, offset_size, length_size)
.map(|data| data.into_owned()) .map(|data| data.into_owned())
@@ -472,7 +479,7 @@ mod tests {
.count(); .count();
let want = dataset_fill_value_in(file, &h.messages, os, ls); let want = dataset_fill_value_in(file, &h.messages, os, ls);
assert_eq!(want, Ok(Some((-7i32).to_le_bytes().to_vec()))); assert_eq!(want, Ok(Some((-7i32).to_le_bytes().to_vec())));
let got = dataset_fill_value_in(&storage, &h.messages, os, ls); let got = dataset_fill_value_from_storage(&storage, &h.messages, os, ls);
assert_eq!(got, want, "{}", child.name); assert_eq!(got, want, "{}", child.name);
} }
assert!(shared >= 2); assert!(shared >= 2);
@@ -44,7 +44,7 @@ use clawhdf5_format::error::FormatError;
use clawhdf5_format::extensible_array::{ use clawhdf5_format::extensible_array::{
ExtensibleArrayHeader, read_extensible_array_chunks, read_extensible_array_chunks_in, ExtensibleArrayHeader, read_extensible_array_chunks, read_extensible_array_chunks_in,
}; };
use clawhdf5_format::fill_value::dataset_fill_value_in; use clawhdf5_format::fill_value::{dataset_fill_value_from_storage, dataset_fill_value_in};
use clawhdf5_format::fixed_array::{ use clawhdf5_format::fixed_array::{
FixedArrayHeader, read_fixed_array_chunks, read_fixed_array_chunks_in, FixedArrayHeader, read_fixed_array_chunks, read_fixed_array_chunks_in,
}; };
@@ -189,7 +189,7 @@ impl Walk<'_> {
self.same( self.same(
"fill value", "fill value",
&want, &want,
&dataset_fill_value_in(self.storage, &header.messages, os, ls), &dataset_fill_value_from_storage(self.st(), &header.messages, os, ls),
); );
for msg in &header.messages { for msg in &header.messages {