Expand description
Memory-mapped array wrapper with COW semantics and zero-copy views Memory-Mapped Array Wrapper for SciRS2
Provides a generic MmapArray<T> that wraps a memory-mapped file-backed array
with support for read-only, read-write, and copy-on-write (COW) semantics.
§Features
- Zero-copy views into memory-mapped regions
- COW semantics for safe mutation without affecting the underlying file
- Typed access with proper alignment checking
- Integration with ndarray for scientific computing
§Example
use scirs2_core::memory_efficient::mmap_array::{MmapArray, MmapMode};
use std::path::Path;
// Create from existing data
let data = vec![1.0f64, 2.0, 3.0, 4.0];
let path = Path::new("/tmp/test_array.dat");
let arr = MmapArray::<f64>::from_slice(&data, path, MmapMode::ReadWrite)
.expect("Failed to create mmap array");
// Access as a slice (zero-copy)
let slice = arr.as_slice().expect("Failed to get slice");
assert_eq!(slice.len(), 4);Structs§
- Mmap
Array - A generic memory-mapped array backed by a file.
- Mmap
Array Builder - Builder for creating MmapArray instances with configuration options.
- Mmap
Chunk Iter - Iterator over chunks of an MmapArray.
Enums§
- Mmap
Mode - Mode for memory-mapped array access