memmap un/shuffle skel

rust
Avril 3 years ago
parent 24475646a1
commit bd11a53947
Signed by: flanchan
GPG Key ID: 284488987C31F630

@ -31,6 +31,16 @@ version = "0.2.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
[[package]]
name = "memmap"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "ppv-lite86"
version = "0.2.10"
@ -83,6 +93,7 @@ version = "0.1.0"
dependencies = [
"cfg-if",
"lazy_static",
"memmap",
"rand",
"rand_chacha",
"smallvec",
@ -99,3 +110,25 @@ name = "wasi"
version = "0.10.2+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6"
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

@ -29,6 +29,7 @@ deferred-drop = []
[dependencies]
cfg-if = "1.0.0"
lazy_static = "1.4.0"
memmap = "0.7.0"
rand = "0.8.3"
smallvec = {version = "1.6.1", features=["union"]}

@ -2,6 +2,9 @@
use super::*;
use std::path::{Path, PathBuf};
use std::io;
use std::fs;
use memmap::MmapMut;
/// What kind of operation are we doing?
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
@ -11,14 +14,33 @@ pub enum ModeKind
Unshuffle
}
fn load_file_ip(file: impl AsRef<Path>) -> io::Result<memmap::MmapMut>
{
let file = fs::OpenOptions::new()
.read(true)
.write(true)
.open(file)?;
Ok(unsafe {
MmapMut::map_mut(&file)?
})
}
pub fn shuffle_file_ip(file: impl AsRef<Path>) -> io::Result<()>
{
todo!()
let mut file = load_file_ip(file)?;
todo!("shuffling");
file.flush()?;
Ok(())
}
pub fn unshuffle_file_ip(file: impl AsRef<Path>) -> io::Result<()>
{
todo!()
let mut file = load_file_ip(file)?;
todo!("unshuffling");
file.flush()?;
Ok(())
}
/// Process these files in place with this mode

Loading…
Cancel
Save