Class QueryBody

java.lang.Object
dev.roanh.gmark.query.QueryBody
All Implemented Interfaces:
OutputXML

public class QueryBody extends Object implements OutputXML
Represents the body of a query, this is essentially the query without the projected head variables.
See Also:
  • Field Details

    • conjuncts

      private List<Conjunct> conjuncts
      The conjuncts in this query body.
    • selectivity

      private Selectivity selectivity
      The selectivity of this query body.
    • shape

      private QueryShape shape
      The shape of this query body.
  • Constructor Details

    • QueryBody

      public QueryBody(List<Conjunct> conjuncts, Selectivity selectivity, QueryShape shape) throws IllegalArgumentException
      Constructs a new query body with the given conjuncts, selectivity and shape.
      Parameters:
      conjuncts - The conjuncts for this query body.
      selectivity - The selectivity of this query body.
      shape - The shape of this query body.
      Throws:
      IllegalArgumentException - When the list of conjuncts is empty.
  • Method Details

    • getConjunctCount

      public int getConjunctCount()
      Gets the number of conjuncts in this query body.
      Returns:
      The number of conjuncts in this query body.
    • getMultiplicity

      public double getMultiplicity()
      Gets the multiplicity of this query body. This is computed as the fraction of all conjuncts that has a Kleene star above it.
      Returns:
      The multiplicity of this query body.
    • getSelectivity

      public Selectivity getSelectivity()
      Gets the selectivity of this query body.
      Returns:
      The selectivity of this query body.
    • getShape

      public QueryShape getShape()
      Gets the shape of this query body.
      Returns:
      The shape of this query body.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toSQL

      protected String toSQL(List<Variable> lhs)
      Converts this query body to SQL.
      Parameters:
      lhs - The projected head variables.
      Returns:
      The SQL form of this query body.
    • conjunctVarToSQL

      private static String conjunctVarToSQL(Variable var, Conjunct conj, Map<Conjunct,Integer> idMap)
      Converts a conjunct variable to SQL.
      Parameters:
      var - The variable to convert.
      conj - The conjunct this variable is a part of.
      idMap - A map storing the ID of each conjunct.
      Returns:
      The SQL version of this conjunct variable.
    • writeXML

      public void writeXML(IndentWriter writer)
      Description copied from interface: OutputXML
      Writes this object as XML to the given writer.
      Specified by:
      writeXML in interface OutputXML
      Parameters:
      writer - The writer to write to.