diff --git a/src/main/rust/src/implementations/libraries.rs b/src/main/rust/src/implementations/libraries.rs index f33b3e7..eef6256 100644 --- a/src/main/rust/src/implementations/libraries.rs +++ b/src/main/rust/src/implementations/libraries.rs @@ -2,6 +2,7 @@ use crate::models::station_measurements::StationMeasurements; use crate::utils::{hash, parse}; use memmap2::MmapOptions; use rustc_hash::{FxBuildHasher, FxHashMap as HashMap}; +use std::slice::from_raw_parts; use std::sync::mpsc; use std::time::Instant; use std::{fs::File, thread}; @@ -13,6 +14,7 @@ pub fn run() { const FILE_PATH: &str = "../../../measurements.txt"; let file = File::open(FILE_PATH).expect("File measurements.txt not found"); let mmap = unsafe { MmapOptions::new().map(&file).unwrap() }; + let mmap_ptr = mmap.as_ptr(); let file_length = mmap.len(); let hasher = FxBuildHasher; let mut stations: HashMap = @@ -39,7 +41,7 @@ pub fn run() { for i in 0..cores { let tx = tx.clone(); let (start, end) = *bounds.get(i).unwrap(); - let mmap_slice = &mmap[start..end]; + let mmap_slice = unsafe { from_raw_parts(mmap_ptr.add(start), end - start) }; s.spawn(move || { let mut t_stations: HashMap = HashMap::with_capacity_and_hasher(DEFAULT_HASHMAP_LENGTH, hasher);