Class Query

java.lang.Object
dev.roanh.gmark.query.Query
All Implemented Interfaces:
OutputSQL, OutputXML

public class Query extends Object implements OutputSQL, OutputXML
Represents a generated query with a number of projected variables and one or more query bodies.
  • Field Details

    • variables

      private List<Variable> variables
      The projected variables for this query (head, left hand side).
    • bodies

      private List<QueryBody> bodies
      All the bodies for this query. Note that currently only queries with a single body are ever generated.
  • Constructor Details

    • Query

      public Query(List<Conjunct> conjuncts, List<Variable> variables, Selectivity selectivity, QueryShape shape)
      Constructs a new query with a single body made up of the given list of conjuncts and with the given project variables, selectivity and shape.
      Parameters:
      conjuncts - The conjuncts for the query body.
      variables - The projected query variables.
      selectivity - The query body selectivity.
      shape - The query body shape.
    • Query

      public Query(QueryBody body, List<Variable> variables)
      Constructs a new query with a single body and with the given project variables, selectivity and shape.
      Parameters:
      body - The query body.
      variables - The projected query variables.
  • Method Details

    • hasShape

      public boolean hasShape(QueryShape shape)
      Tests if any query body in this query has the given shape.
      Parameters:
      shape - The shape to check for.
      Returns:
      True if this query contains a body with the given shape.
    • getShapes

      public Set<QueryShape> getShapes()
      Gets all shapes used by the bodies in this query.
      Returns:
      All query body shapes.
    • hasSelectivity

      public boolean hasSelectivity(Selectivity selectivity)
      Checks if this query contains a query body with the given selectivity.
      Parameters:
      selectivity - The selectivity to check for.
      Returns:
      True if this query contains a query body with the given selectivity.
    • getSelectivities

      public Set<Selectivity> getSelectivities()
      Gets all selectivities used by the bodies in this query.
      Returns:
      All query body selectivities.
    • getMinConjuncts

      public int getMinConjuncts()
      Gets the number of conjuncts in the query body with the least conjuncts.
      Returns:
      The minimum query body conjunct count.
    • getMaxConjuncts

      public int getMaxConjuncts()
      Gets the number of conjuncts in the query body with the most conjuncts.
      Returns:
      The maximum query body conjunct count.
    • isBinary

      public boolean isBinary()
      Checks if this query is binary. A query is binary when its arity is equal to 0.
      Returns:
      True if this query is binary.
    • getArity

      public int getArity()
      Gets the arity (number of projected variables) for this query.
      Returns:
      The arity for this query.
    • getBodies

      public List<QueryBody> getBodies()
      Gets all the query bodies for this query.
      Returns:
      All query bodies.
    • getBodyCount

      public int getBodyCount()
      Gets the number of bodies that make up this query.
      Returns:
      The number of bodies in this query.
    • toString

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

      public String toSQL()
      Description copied from interface: OutputSQL
      Converts this object to an SQL query.
      Specified by:
      toSQL in interface OutputSQL
      Returns:
      An SQL query representing this object.
    • 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.