Skip to main content

Module mmap_array

Module mmap_array 

Source
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§

MmapArray
A generic memory-mapped array backed by a file.
MmapArrayBuilder
Builder for creating MmapArray instances with configuration options.
MmapChunkIter
Iterator over chunks of an MmapArray.

Enums§

MmapMode
Mode for memory-mapped array access