Skip to content

Commit

Permalink
remove join-pruning and unneeded code
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Jan 5, 2022
1 parent a0aec94 commit 38cc09e
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 356 deletions.
41 changes: 0 additions & 41 deletions polars/polars-lazy/src/logical_plan/aexpr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,47 +362,6 @@ impl AExpr {
Wildcard => panic!("should be no wildcard at this point"),
}
}

/// Check if AExpr equality. The nodes may differ.
///
/// For instance: there can be two columns "foo" in the memory arena. These are equal,
/// but would have different node values.
#[cfg(feature = "private")]
pub(crate) fn eq(node_left: Node, node_right: Node, expr_arena: &Arena<AExpr>) -> bool {
use crate::logical_plan::iterator::ArenaExprIter;
let cmp = |(node_left, node_right)| {
use AExpr::*;
match (expr_arena.get(node_left), expr_arena.get(node_right)) {
(Alias(_, name_l), Alias(_, name_r)) => name_l == name_r,
(Column(name_l), Column(name_r)) => name_l == name_r,
(Literal(left), Literal(right)) => left == right,
(BinaryExpr { op: l, .. }, BinaryExpr { op: r, .. }) => l == r,
(Cast { data_type: l, .. }, Cast { data_type: r, .. }) => l == r,
(Sort { options: l, .. }, Sort { options: r, .. }) => l == r,
(SortBy { reverse: l, .. }, SortBy { reverse: r, .. }) => l == r,
(Shift { periods: l, .. }, Shift { periods: r, .. }) => l == r,
(
Slice {
offset: offset_l,
length: length_l,
..
},
Slice {
offset: offset_r,
length: length_r,
..
},
) => offset_l == offset_r && length_l == length_r,
(a, b) => std::mem::discriminant(a) == std::mem::discriminant(b),
}
};

expr_arena
.iter(node_left)
.zip(expr_arena.iter(node_right))
.map(|(tpll, tplr)| (tpll.0, tplr.0))
.all(cmp)
}
}

pub(crate) fn field_by_context(
Expand Down
75 changes: 0 additions & 75 deletions polars/polars-lazy/src/logical_plan/alp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,81 +186,6 @@ impl ALogicalPlan {
},
}
}

/// Check ALogicalPlan equality. The nodes may differ.
///
/// For instance: there can be two columns "foo" in the memory arena. These are equal,
/// but would have different node values.
#[cfg(feature = "private")]
pub(crate) fn eq(
node_left: Node,
node_right: Node,
lp_arena: &Arena<ALogicalPlan>,
expr_arena: &Arena<AExpr>,
) -> bool {
use crate::logical_plan::iterator::ArenaLpIter;
use std::fs::canonicalize;

let cmp = |(node_left, node_right)| {
use ALogicalPlan::*;
match (lp_arena.get(node_left), lp_arena.get(node_right)) {
#[cfg(feature = "csv-file")]
(CsvScan { path: path_a, .. }, CsvScan { path: path_b, .. }) => {
canonicalize(path_a).unwrap() == canonicalize(path_b).unwrap()
}
#[cfg(feature = "parquet")]
(ParquetScan { path: path_a, .. }, ParquetScan { path: path_b, .. }) => {
canonicalize(path_a).unwrap() == canonicalize(path_b).unwrap()
}
#[cfg(feature = "ipc")]
(IpcScan { path: path_a, .. }, IpcScan { path: path_b, .. }) => {
canonicalize(path_a).unwrap() == canonicalize(path_b).unwrap()
}
(DataFrameScan { df: df_a, .. }, DataFrameScan { df: df_b, .. }) => {
df_a.ptr_equal(df_b)
}
// the following don't affect the schema, but do affect the # of rows or the row order.
(Selection { predicate: l, .. }, Selection { predicate: r, .. }) => {
AExpr::eq(*l, *r, expr_arena)
}
(
Sort {
by_column: l,
reverse: r_l,
..
},
Sort {
by_column: r,
reverse: r_r,
..
},
) => l == r && r_l == r_r,
(Explode { columns: l, .. }, Explode { columns: r, .. }) => l == r,
(
Distinct {
maintain_order: l1,
subset: l2,
..
},
Distinct {
maintain_order: r1,
subset: r2,
..
},
) => l1 == r1 && l2 == r2,
(a, b) => {
std::mem::discriminant(a) == std::mem::discriminant(b)
&& a.schema(lp_arena) == b.schema(lp_arena)
}
}
};

lp_arena
.iter(node_left)
.zip(lp_arena.iter(node_right))
.map(|(tpll, tplr)| (tpll.0, tplr.0))
.all(cmp)
}
}

impl ALogicalPlan {
Expand Down
214 changes: 0 additions & 214 deletions polars/polars-lazy/src/logical_plan/optimizer/join_pruning.rs

This file was deleted.

2 changes: 0 additions & 2 deletions polars/polars-lazy/src/logical_plan/optimizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ pub(crate) mod aggregate_pushdown;
pub(crate) mod aggregate_scan_projections;
pub(crate) mod drop_nulls;
pub(crate) mod fast_projection;
#[cfg(feature = "private")]
pub(crate) mod join_pruning;
pub(crate) mod predicate_pushdown;
pub(crate) mod projection_pushdown;
pub(crate) mod simplify_expr;
Expand Down
24 changes: 0 additions & 24 deletions polars/polars-lazy/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,6 @@ use std::collections::HashSet;
use std::path::{Path, PathBuf};
use std::sync::Arc;

#[cfg(feature = "private")]
pub(crate) fn equal_aexprs(left: &[Node], right: &[Node], expr_arena: &Arena<AExpr>) -> bool {
left.iter()
.zip(right.iter())
.all(|(l, r)| AExpr::eq(*l, *r, expr_arena))
}

pub(crate) fn remove_duplicate_aexprs(exprs: &[Node], expr_arena: &Arena<AExpr>) -> Vec<Node> {
let mut unique = HashSet::with_capacity_and_hasher(exprs.len(), RandomState::new());
let mut new = Vec::with_capacity(exprs.len());
for node in exprs {
let mut can_insert = false;
for name in aexpr_to_root_names(*node, expr_arena) {
if unique.insert(name) {
can_insert = true
}
}
if can_insert {
new.push(*node)
}
}
new
}

pub(crate) trait PushNode {
fn push_node(&mut self, value: Node);
}
Expand Down

0 comments on commit 38cc09e

Please sign in to comment.