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
Showing only changes of commit d2b25f154f - Show all commits
+13
View File
@@ -198,6 +198,14 @@ pub fn read_exact_at(
.saturating_add(len),
available: len_usize(file),
};
// In-memory fast path: one dynamic call, then plain slicing.
if let Some(all) = file.as_contiguous() {
return usize::try_from(offset)
.ok()
.and_then(|start| all.get(start..start.checked_add(len)?))
.map(Cow::Borrowed)
.ok_or_else(eof);
}
match offset.checked_add(len as u64) {
Some(end) if end <= file.len() => {}
_ => return Err(eof()),
@@ -271,6 +279,11 @@ pub fn read_upto(
offset: u64,
max: usize,
) -> Result<Cow<'_, [u8]>, FormatError> {
if let Some(all) = file.as_contiguous() {
let start = usize::try_from(offset).map_or(all.len(), |o| o.min(all.len()));
let end = start.saturating_add(max).min(all.len());
return Ok(Cow::Borrowed(&all[start..end]));
}
let avail = file.len().saturating_sub(offset);
let len = usize::try_from(avail).map_or(max, |a| a.min(max));
let bytes = file.read_at(offset, len)?;