Package dev.roanh.gmark.query
Class Query
java.lang.Object
dev.roanh.gmark.query.Query
Represents a generated query with a number of
projected variables and one or more query bodies.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionConstructs a new query with a single body and with the given project variables, selectivity and shape.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. -
Method Summary
Modifier and TypeMethodDescriptionint
getArity()
Gets the arity (number of projected variables) for this query.Gets all the query bodies for this query.int
Gets the number of bodies that make up this query.int
Gets the number of conjuncts in the query body with the most conjuncts.int
Gets the number of conjuncts in the query body with the least conjuncts.Gets all selectivities used by the bodies in this query.Gets all shapes used by the bodies in this query.boolean
hasSelectivity
(Selectivity selectivity) Checks if this query contains a query body with the given selectivity.boolean
hasShape
(QueryShape shape) Tests if any query body in this query has the given shape.boolean
isBinary()
Checks if this query is binary.toSQL()
Converts this object to an SQL query.toString()
void
writeXML
(IndentWriter writer) Writes this object as XML to the given writer.
-
Field Details
-
variables
The projected variables for this query (head, left hand side). -
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
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
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
Gets all shapes used by the bodies in this query.- Returns:
- All query body shapes.
-
hasSelectivity
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
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
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
-
toSQL
Description copied from interface:OutputSQL
Converts this object to an SQL query. -
writeXML
Description copied from interface:OutputXML
Writes this object as XML to the given writer.
-