From 81002ca9e46d4e9a7304fa1f99f7bd5204d42c4a Mon Sep 17 00:00:00 2001 From: eitsupi <50911393+eitsupi@users.noreply.github.com> Date: Sun, 14 Apr 2024 16:53:37 +0900 Subject: [PATCH] refactor(rust!): rename `memmap` -> `memory_map` as like Python (#15642) --- crates/polars-arrow/src/mmap/mod.rs | 2 +- crates/polars-io/src/ipc/ipc_file.rs | 14 +++++++------- .../src/physical_plan/executors/scan/ipc.rs | 2 +- crates/polars-lazy/src/scan/ipc.rs | 6 +++--- crates/polars-lazy/src/tests/io.rs | 2 +- crates/polars-plan/src/logical_plan/options.rs | 2 +- py-polars/src/lazyframe/mod.rs | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/polars-arrow/src/mmap/mod.rs b/crates/polars-arrow/src/mmap/mod.rs index 72388f703425..11b308d46694 100644 --- a/crates/polars-arrow/src/mmap/mod.rs +++ b/crates/polars-arrow/src/mmap/mod.rs @@ -52,7 +52,7 @@ fn read_message( fn get_buffers_nodes(batch: RecordBatchRef) -> PolarsResult<(VecDeque, VecDeque)> { 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 diff --git a/crates/polars-io/src/ipc/ipc_file.rs b/crates/polars-io/src/ipc/ipc_file.rs index ec0cf8cf2ec0..c59e4c8f98a0 100644 --- a/crates/polars-io/src/ipc/ipc_file.rs +++ b/crates/polars-io/src/ipc/ipc_file.rs @@ -71,16 +71,16 @@ pub struct IpcReader { pub(super) projection: Option>, pub(crate) columns: Option>, pub(super) row_index: Option, - memmap: bool, + memory_map: bool, metadata: Option, schema: Option, } 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(()); @@ -131,7 +131,7 @@ impl IpcReader { /// 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 } @@ -142,7 +142,7 @@ impl IpcReader { predicate: Option>, verbose: bool, ) -> PolarsResult { - 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") } @@ -191,7 +191,7 @@ impl SerReader for IpcReader { columns: None, projection: None, row_index: None, - memmap: true, + memory_map: true, metadata: None, schema: None, } @@ -203,7 +203,7 @@ impl SerReader for IpcReader { } fn finish(mut self) -> PolarsResult { - 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)?, diff --git a/crates/polars-lazy/src/physical_plan/executors/scan/ipc.rs b/crates/polars-lazy/src/physical_plan/executors/scan/ipc.rs index 3e2852396dff..ea1836752ed5 100644 --- a/crates/polars-lazy/src/physical_plan/executors/scan/ipc.rs +++ b/crates/polars-lazy/src/physical_plan/executors/scan/ipc.rs @@ -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 diff --git a/crates/polars-lazy/src/scan/ipc.rs b/crates/polars-lazy/src/scan/ipc.rs index 41797db9a341..ca878b1e42d3 100644 --- a/crates/polars-lazy/src/scan/ipc.rs +++ b/crates/polars-lazy/src/scan/ipc.rs @@ -12,7 +12,7 @@ pub struct ScanArgsIpc { pub cache: bool, pub rechunk: bool, pub row_index: Option, - pub memmap: bool, + pub memory_map: bool, pub cloud_options: Option, } @@ -23,7 +23,7 @@ impl Default for ScanArgsIpc { cache: true, rechunk: false, row_index: None, - memmap: true, + memory_map: true, cloud_options: Default::default(), } } @@ -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( diff --git a/crates/polars-lazy/src/tests/io.rs b/crates/polars-lazy/src/tests/io.rs index e19be30d75c8..29e48fae16c5 100644 --- a/crates/polars-lazy/src/tests/io.rs +++ b/crates/polars-lazy/src/tests/io.rs @@ -415,7 +415,7 @@ fn test_ipc_globbing() -> PolarsResult<()> { cache: true, rechunk: false, row_index: None, - memmap: true, + memory_map: true, cloud_options: None, }, )? diff --git a/crates/polars-plan/src/logical_plan/options.rs b/crates/polars-plan/src/logical_plan/options.rs index 95c4e894e7f5..c646be5d869f 100644 --- a/crates/polars-plan/src/logical_plan/options.rs +++ b/crates/polars-plan/src/logical_plan/options.rs @@ -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)] diff --git a/py-polars/src/lazyframe/mod.rs b/py-polars/src/lazyframe/mod.rs index c106b14ba106..722b111aba2c 100644 --- a/py-polars/src/lazyframe/mod.rs +++ b/py-polars/src/lazyframe/mod.rs @@ -358,7 +358,7 @@ impl PyLazyFrame { cache, rechunk, row_index, - memmap: memory_map, + memory_map, #[cfg(feature = "cloud")] cloud_options, };