Box the ConjoiningClauses in the enum ComputedTable to lower the size of that struct.

This commit is contained in:
Gregory Burd 2020-02-20 12:16:21 -05:00
parent b41bcf40f3
commit a8223d11c9
4 changed files with 19 additions and 13 deletions

View file

@ -209,9 +209,12 @@ macro_rules! def_from_option {
macro_rules! def_is { macro_rules! def_is {
($name: ident, $pat: pat) => { ($name: ident, $pat: pat) => {
pub fn $name(&self) -> bool { 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 /// Creates `as_$TYPE` helper functions for Value or SpannedValue, like
@ -231,9 +234,12 @@ macro_rules! def_as {
macro_rules! def_as_ref { macro_rules! def_as_ref {
($name: ident, $kind: path, $t: ty) => { ($name: ident, $kind: path, $t: ty) => {
pub fn $name(&self) -> Option<&$t> { 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 /// Creates `into_$TYPE` helper functions for Value or SpannedValue, like

View file

@ -66,7 +66,7 @@ impl ConjoiningClauses {
return Ok(()); return Ok(());
} }
let subquery = ComputedTable::Subquery(template); let subquery = ComputedTable::Subquery(Box::new(template));
self.wheres self.wheres
.add_intersection(ColumnConstraint::NotExists(subquery)); .add_intersection(ColumnConstraint::NotExists(subquery));
@ -256,7 +256,7 @@ mod testing {
john john
)), )),
ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( 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::Equals(d2v.clone(), john)),
ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists(
ComputedTable::Subquery(subquery), ComputedTable::Subquery(Box::new(subquery)),
)), )),
ColumnConstraintOrAlternation::Constraint(ColumnConstraint::Equals( ColumnConstraintOrAlternation::Constraint(ColumnConstraint::Equals(
d0e.clone(), d0e.clone(),
@ -467,7 +467,7 @@ mod testing {
right: QueryValue::TypedValue(TypedValue::Long(30)), right: QueryValue::TypedValue(TypedValue::Long(30)),
}), }),
ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists(
ComputedTable::Subquery(subquery) ComputedTable::Subquery(Box::new(subquery))
)), )),
]) ])
); );
@ -578,7 +578,7 @@ mod testing {
bill bill
)), )),
ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists(
ComputedTable::Subquery(subquery) ComputedTable::Subquery(Box::new(subquery))
)), )),
]) ])
); );
@ -662,7 +662,7 @@ mod testing {
bill bill
)), )),
ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists( ColumnConstraintOrAlternation::Constraint(ColumnConstraint::NotExists(
ComputedTable::Subquery(subquery) ComputedTable::Subquery(Box::new(subquery))
)), )),
]) ])
); );

View file

@ -32,7 +32,7 @@ pub enum DatomsTable {
/// A source of rows that isn't a named table -- typically a subquery or union. /// A source of rows that isn't a named table -- typically a subquery or union.
#[derive(PartialEq, Eq, Debug)] #[derive(PartialEq, Eq, Debug)]
pub enum ComputedTable { pub enum ComputedTable {
Subquery(::clauses::ConjoiningClauses), Subquery(Box<::clauses::ConjoiningClauses>),
Union { Union {
projection: BTreeSet<Variable>, projection: BTreeSet<Variable>,
type_extraction: BTreeSet<Variable>, type_extraction: BTreeSet<Variable>,

View file

@ -298,7 +298,7 @@ fn table_for_computed(computed: ComputedTable, alias: TableAlias) -> TableOrSubq
// datoms03.value_type_tag AS `?x_value_type_tag` // datoms03.value_type_tag AS `?x_value_type_tag`
let extract = cc.extracted_types let extract = cc.extracted_types
.get(var) .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()) ColumnOrExpression::Column(extract.clone())
}; };
let type_column = VariableColumn::VariableTypeTag(var.clone()); let type_column = VariableColumn::VariableTypeTag(var.clone());
@ -315,7 +315,7 @@ fn table_for_computed(computed: ComputedTable, alias: TableAlias) -> TableOrSubq
alias) alias)
} }
ComputedTable::Subquery(subquery) => { ComputedTable::Subquery(subquery) => {
TableOrSubquery::Subquery(Box::new(cc_to_exists(subquery))) TableOrSubquery::Subquery(Box::new(cc_to_exists(*subquery)))
} }
ComputedTable::NamedValues { names, values } => { ComputedTable::NamedValues { names, values } => {
// We assume column homogeneity, so we won't have any type tag columns. // We assume column homogeneity, so we won't have any type tag columns.