Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(rust!): rename memmap -> memory_map as like Python #15642

Merged
merged 1 commit into from
Apr 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/polars-arrow/src/mmap/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn read_message(
fn get_buffers_nodes(batch: RecordBatchRef) -> PolarsResult<(VecDeque<IpcBuffer>, VecDeque<Node>)> {
let compression = batch.compression().map_err(to_compute_err)?;
if compression.is_some() {
polars_bail!(ComputeError: "mmap can only be done on uncompressed IPC files")
polars_bail!(ComputeError: "memory_map can only be done on uncompressed IPC files")
}

let buffers = batch
Expand Down
14 changes: 7 additions & 7 deletions crates/polars-io/src/ipc/ipc_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ pub struct IpcReader<R: MmapBytesReader> {
pub(super) projection: Option<Vec<usize>>,
pub(crate) columns: Option<Vec<String>>,
pub(super) row_index: Option<RowIndex>,
memmap: bool,
memory_map: bool,
metadata: Option<read::FileMetadata>,
schema: Option<ArrowSchemaRef>,
}

fn check_mmap_err(err: PolarsError) -> PolarsResult<()> {
if let PolarsError::ComputeError(s) = &err {
if s.as_ref() == "mmap can only be done on uncompressed IPC files" {
if s.as_ref() == "memory_map can only be done on uncompressed IPC files" {
eprintln!(
"Could not mmap compressed IPC file, defaulting to normal read. \
"Could not memory_map compressed IPC file, defaulting to normal read. \
Toggle off 'memory_map' to silence this warning."
);
return Ok(());
Expand Down Expand Up @@ -131,7 +131,7 @@ impl<R: MmapBytesReader> IpcReader<R> {

/// Set if the file is to be memory_mapped. Only works with uncompressed files.
pub fn memory_mapped(mut self, toggle: bool) -> Self {
self.memmap = toggle;
self.memory_map = toggle;
self
}

Expand All @@ -142,7 +142,7 @@ impl<R: MmapBytesReader> IpcReader<R> {
predicate: Option<Arc<dyn PhysicalIoExpr>>,
verbose: bool,
) -> PolarsResult<DataFrame> {
if self.memmap && self.reader.to_file().is_some() {
if self.memory_map && self.reader.to_file().is_some() {
if verbose {
eprintln!("memory map ipc file")
}
Expand Down Expand Up @@ -191,7 +191,7 @@ impl<R: MmapBytesReader> SerReader<R> for IpcReader<R> {
columns: None,
projection: None,
row_index: None,
memmap: true,
memory_map: true,
metadata: None,
schema: None,
}
Expand All @@ -203,7 +203,7 @@ impl<R: MmapBytesReader> SerReader<R> for IpcReader<R> {
}

fn finish(mut self) -> PolarsResult<DataFrame> {
if self.memmap && self.reader.to_file().is_some() {
if self.memory_map && self.reader.to_file().is_some() {
match self.finish_memmapped(None) {
Ok(df) => return Ok(df),
Err(err) => check_mmap_err(err)?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl IpcExec {
)
.with_row_index(self.file_options.row_index.clone())
.with_projection(projection.clone())
.memory_mapped(self.options.memmap)
.memory_mapped(self.options.memory_map)
.finish()?;

row_counter
Expand Down
6 changes: 3 additions & 3 deletions crates/polars-lazy/src/scan/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct ScanArgsIpc {
pub cache: bool,
pub rechunk: bool,
pub row_index: Option<RowIndex>,
pub memmap: bool,
pub memory_map: bool,
pub cloud_options: Option<CloudOptions>,
}

Expand All @@ -23,7 +23,7 @@ impl Default for ScanArgsIpc {
cache: true,
rechunk: false,
row_index: None,
memmap: true,
memory_map: true,
cloud_options: Default::default(),
}
}
Expand Down Expand Up @@ -67,7 +67,7 @@ impl LazyFileListReader for LazyIpcReader {
};

let options = IpcScanOptions {
memmap: args.memmap,
memory_map: args.memory_map,
};

let mut lf: LazyFrame = LogicalPlanBuilder::scan_ipc(
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/tests/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ fn test_ipc_globbing() -> PolarsResult<()> {
cache: true,
rechunk: false,
row_index: None,
memmap: true,
memory_map: true,
cloud_options: None,
},
)?
Expand Down
2 changes: 1 addition & 1 deletion crates/polars-plan/src/logical_plan/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub struct JsonWriterOptions {
#[derive(Clone, Debug, PartialEq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct IpcScanOptions {
pub memmap: bool,
pub memory_map: bool,
}

#[derive(Clone, Debug, PartialEq, Eq, Default, Hash)]
Expand Down
2 changes: 1 addition & 1 deletion py-polars/src/lazyframe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl PyLazyFrame {
cache,
rechunk,
row_index,
memmap: memory_map,
memory_map,
#[cfg(feature = "cloud")]
cloud_options,
};
Expand Down
Loading