From ec23852f80b6d2a22e296401896157e0590a2155 Mon Sep 17 00:00:00 2001 From: Denis Smirnov <sd@picodata.io> Date: Fri, 17 Dec 2021 18:50:32 +0700 Subject: [PATCH] refactoring: rename Plan::empty() to Plan::new() --- src/ir.rs | 8 +++++++- src/ir/distribution/tests.rs | 2 +- src/ir/operator/tests.rs | 14 +++++++------- src/ir/tests.rs | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/ir.rs b/src/ir.rs index 60a8c43b99..4bb91be567 100644 --- a/src/ir.rs +++ b/src/ir.rs @@ -87,6 +87,12 @@ pub struct Plan { top: Option<usize>, } +impl Default for Plan { + fn default() -> Self { + Self::new() + } +} + #[allow(dead_code)] impl Plan { /// Add relation to the plan. @@ -126,7 +132,7 @@ impl Plan { /// Constructor for an empty plan structure. #[must_use] - pub fn empty() -> Self { + pub fn new() -> Self { Plan { nodes: Nodes { arena: Vec::new() }, relations: None, diff --git a/src/ir/distribution/tests.rs b/src/ir/distribution/tests.rs index dc3ca3edff..c3b81b3be0 100644 --- a/src/ir/distribution/tests.rs +++ b/src/ir/distribution/tests.rs @@ -7,7 +7,7 @@ use std::path::Path; #[test] fn proj_preserve_dist_key() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg( "t", diff --git a/src/ir/operator/tests.rs b/src/ir/operator/tests.rs index 8df5bc57a4..4189245e48 100644 --- a/src/ir/operator/tests.rs +++ b/src/ir/operator/tests.rs @@ -10,7 +10,7 @@ use std::path::Path; #[test] fn scan_rel() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg( "t", @@ -47,7 +47,7 @@ fn scan_rel() { #[test] fn scan_rel_serialized() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg( "t", @@ -82,7 +82,7 @@ fn scan_rel_serialized() { #[test] fn projection() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg( "t", @@ -132,7 +132,7 @@ fn projection_serialize() { #[test] fn selection() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg( "t", @@ -184,7 +184,7 @@ fn selection_serialize() { #[test] fn union_all() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t1 = Table::new_seg("t1", vec![Column::new("a", Type::Number)], &["a"]).unwrap(); plan.add_rel(t1); @@ -199,7 +199,7 @@ fn union_all() { #[test] fn union_all_col_amount_mismatch() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t1 = Table::new_seg( "t1", @@ -227,7 +227,7 @@ fn union_all_col_amount_mismatch() { #[test] fn sub_query() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg( "t", diff --git a/src/ir/tests.rs b/src/ir/tests.rs index 3ad365474b..e26b0e74b4 100644 --- a/src/ir/tests.rs +++ b/src/ir/tests.rs @@ -34,7 +34,7 @@ fn plan_oor_top() { #[test] fn get_node() { - let mut plan = Plan::empty(); + let mut plan = Plan::new(); let t = Table::new_seg("t", vec![Column::new("a", Type::Boolean)], &["a"]).unwrap(); plan.add_rel(t); @@ -52,7 +52,7 @@ fn get_node() { #[test] fn get_node_oor() { - let plan = Plan::empty(); + let plan = Plan::new(); assert_eq!( QueryPlannerError::ValueOutOfRange, plan.get_node(42).unwrap_err() -- GitLab