Skip to content

Commit

Permalink
refactor(rust!): rename memmap -> memory_map as like Python (#15642)
Browse files Browse the repository at this point in the history
  • Loading branch information
eitsupi committed Apr 14, 2024
1 parent 7341aee commit 81002ca
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
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
2 changes: 1 addition & 1 deletion crates/polars-lazy/src/physical_plan/executors/scan/ipc.rs
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

0 comments on commit 81002ca

Please sign in to comment.