Skip to content

Commit

Permalink
use mmap2
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Sep 22, 2023
1 parent aa6b9fa commit 4426437
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ keywords = ["metrics", "async", "tracing"]
default = ["runtime_thread"]
gzip = ["flate2"]
lz4 = ["lz4_flex"]
mmap = ["memmap"]
mmap = ["memmap2"]
runtime_thread = []

[dependencies]
Expand All @@ -35,4 +35,4 @@ parking_lot = "0.12"
zip = { version = "0.6", optional = true }
lz4_flex = { version = "0.11", optional = true }
flate2 = { version = "1.0", optional = true}
memmap = { version ="0.7.0", optional = true}
memmap2 = {version = "0.7.1", optional = true}
8 changes: 4 additions & 4 deletions src/plugin/file_mmap.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::consts::LogSize;
use crate::error::LogError;
use crate::plugin::file_split::SplitFile;
use memmap::{MmapMut, MmapOptions};
use memmap2::{MmapMut, MmapOptions};
use std::cell::{RefCell, UnsafeCell};
use std::fs::{File, OpenOptions};
use std::io::{SeekFrom, Write};
Expand All @@ -21,7 +21,7 @@ impl MmapFile {
let log_file_path = log_file_path.replace("\\", "/");
if let Some(right) = log_file_path.rfind("/") {
let path = &log_file_path[0..right];
let _= std::fs::create_dir_all(path);
let _ = std::fs::create_dir_all(path);
}
let file = OpenOptions::new()
.write(true)
Expand Down Expand Up @@ -136,7 +136,7 @@ impl SplitFile for MmapFile {
file.set_len(self.size.get_len() as u64)?;
let mmap = unsafe {
MmapOptions::new()
.map(&file)
.map(&*file)
.map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::InvalidInput,
Expand All @@ -151,7 +151,7 @@ impl SplitFile for MmapFile {
}

fn flush(&self) {
let _= self.bytes.borrow_mut().flush();
let _ = self.bytes.borrow_mut().flush();
}

fn len(&self) -> usize {
Expand Down

0 comments on commit 4426437

Please sign in to comment.