From a8223d11c9f0c68f9a1bb6905ae81945c940c859 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Thu, 20 Feb 2020 12:16:21 -0500 Subject: [PATCH] Box the ConjoiningClauses in the enum ComputedTable to lower the size of that struct. --- edn/src/types.rs | 14 ++++++++++---- query-algebrizer/src/clauses/not.rs | 12 ++++++------ query-algebrizer/src/types.rs | 2 +- query-projector/src/translate.rs | 4 ++-- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/edn/src/types.rs b/edn/src/types.rs index fbb1bf92..0388cb91 100644 --- a/edn/src/types.rs +++ b/edn/src/types.rs @@ -209,9 +209,12 @@ macro_rules! def_from_option { macro_rules! def_is { ($name: ident, $pat: pat) => { pub fn $name(&self) -> bool { - match *self { $pat => true, _ => false } + match *self { + $pat => true, + _ => false, + } } - } + }; } /// Creates `as_$TYPE` helper functions for Value or SpannedValue, like @@ -231,9 +234,12 @@ macro_rules! def_as { macro_rules! def_as_ref { ($name: ident, $kind: path, $t: ty) => { pub fn $name(&self) -> Option<&$t> { - match *self { $kind(ref v) => Some(v), _ => None } + match *self { + $kind(ref v) => Some(v), + _ => None, + } } - } + }; } /// Creates `into_$TYPE` helper functions for Value or SpannedValue, like diff --git a/query-algebrizer/src/clauses/not.rs b/query-algebrizer/src/clauses/not.rs index 2ba8117b..fd890245 100644 --- a/query-algebrizer/src/clauses/not.rs +++ b/query-algebrizer/src/clauses/not.rs @@ -66,7 +66,7 @@ impl ConjoiningClauses { return Ok(()); } - let subquery = ComputedTable::Subquery(template); + let subquery = ComputedTable::Subquery(Box::new(template)); self.wheres .add_intersection(ColumnConstraint::NotExists(subquery)); @@ -256,7 +256,7 @@ mod testing { john )), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( - ComputedTable::Subquery(subquery) + ComputedTable::Subquery(Box::new(subquery)) )), ]) ); @@ -355,7 +355,7 @@ mod testing { )), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::Equals(d2v.clone(), john)), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( - ComputedTable::Subquery(subquery), + ComputedTable::Subquery(Box::new(subquery)), )), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::Equals( d0e.clone(), @@ -467,7 +467,7 @@ mod testing { right: QueryValue::TypedValue(TypedValue::Long(30)), }), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( - ComputedTable::Subquery(subquery) + ComputedTable::Subquery(Box::new(subquery)) )), ]) ); @@ -578,7 +578,7 @@ mod testing { bill )), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( - ComputedTable::Subquery(subquery) + ComputedTable::Subquery(Box::new(subquery)) )), ]) ); @@ -662,7 +662,7 @@ mod testing { bill )), ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( - ComputedTable::Subquery(subquery) + ComputedTable::Subquery(Box::new(subquery)) )), ]) ); diff --git a/query-algebrizer/src/types.rs b/query-algebrizer/src/types.rs index 51baefb0..b96b0b3d 100644 --- a/query-algebrizer/src/types.rs +++ b/query-algebrizer/src/types.rs @@ -32,7 +32,7 @@ pub enum DatomsTable { /// A source of rows that isn't a named table -- typically a subquery or union. #[derive(PartialEq, Eq, Debug)] pub enum ComputedTable { - Subquery(::clauses::ConjoiningClauses), + Subquery(Box<::clauses::ConjoiningClauses>), Union { projection: BTreeSet, type_extraction: BTreeSet, diff --git a/query-projector/src/translate.rs b/query-projector/src/translate.rs index bc3cc102..425164dc 100644 --- a/query-projector/src/translate.rs +++ b/query-projector/src/translate.rs @@ -298,7 +298,7 @@ fn table_for_computed(computed: ComputedTable, alias: TableAlias) -> TableOrSubq // datoms03.value_type_tag AS `?x_value_type_tag` let extract = cc.extracted_types .get(var) - .expect("Expected variable to have a known type or an extracted type"); + .expect("Expected variable to have a known type, or an extracted type"); ColumnOrExpression::Column(extract.clone()) }; let type_column = VariableColumn::VariableTypeTag(var.clone()); @@ -315,7 +315,7 @@ fn table_for_computed(computed: ComputedTable, alias: TableAlias) -> TableOrSubq alias) } ComputedTable::Subquery(subquery) => { - TableOrSubquery::Subquery(Box::new(cc_to_exists(subquery))) + TableOrSubquery::Subquery(Box::new(cc_to_exists(*subquery))) } ComputedTable::NamedValues { names, values } => { // We assume column homogeneity, so we won't have any type tag columns.