Skip to content

Commit

Permalink
refactor(rust): Allow polars to pass cargo check on windows (#18498)
Browse files Browse the repository at this point in the history
  • Loading branch information
squnit authored Sep 2, 2024
1 parent 8c3f6b9 commit c03e760
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.iml
*.so
*.pyd
*.ipynb
.ENV
.env
Expand Down
13 changes: 10 additions & 3 deletions crates/polars-io/src/mmap.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#[cfg(target_family = "unix")]
use std::collections::btree_map::Entry;
#[cfg(target_family = "unix")]
use std::collections::BTreeMap;
use std::fs::File;
use std::io::{BufReader, Cursor, Read, Seek};
use std::sync::{Arc, Mutex};
use std::sync::Arc;
#[cfg(target_family = "unix")]
use std::sync::Mutex;

use memmap::Mmap;
#[cfg(target_family = "unix")]
use once_cell::sync::Lazy;
use polars_core::config::verbose;
use polars_error::{polars_bail, PolarsResult};
#[cfg(target_family = "unix")]
use polars_error::polars_bail;
use polars_error::PolarsResult;
use polars_utils::mmap::MemSlice;

// Keep track of memory mapped files so we don't write to them while reading
Expand Down Expand Up @@ -60,7 +67,7 @@ impl Drop for MMapSemaphore {
}
}

pub fn ensure_not_mapped(file: &File) -> PolarsResult<()> {
pub fn ensure_not_mapped(#[allow(unused)] file: &File) -> PolarsResult<()> {
#[cfg(target_family = "unix")]
{
use std::os::unix::fs::MetadataExt;
Expand Down
4 changes: 3 additions & 1 deletion crates/polars-python/src/file.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::borrow::Cow;
use std::fs::{self, File};
#[cfg(target_family = "unix")]
use std::fs;
use std::fs::File;
use std::io;
use std::io::{Cursor, ErrorKind, Read, Seek, SeekFrom, Write};
#[cfg(target_family = "unix")]
Expand Down
4 changes: 2 additions & 2 deletions crates/polars-utils/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ pub fn prefetch_l2(slice: &[u8]) {
}

/// `madvise()` with `MADV_SEQUENTIAL` on unix systems. This is a no-op on non-unix systems.
pub fn madvise_sequential(slice: &[u8]) {
pub fn madvise_sequential(#[allow(unused)] slice: &[u8]) {
#[cfg(target_family = "unix")]
madvise(slice, libc::MADV_SEQUENTIAL);
}

/// `madvise()` with `MADV_WILLNEED` on unix systems. This is a no-op on non-unix systems.
pub fn madvise_willneed(slice: &[u8]) {
pub fn madvise_willneed(#[allow(unused)] slice: &[u8]) {
#[cfg(target_family = "unix")]
madvise(slice, libc::MADV_WILLNEED);
}
Expand Down

0 comments on commit c03e760

Please sign in to comment.