Package dev.roanh.gmark.query
Class Query
java.lang.Object
dev.roanh.gmark.query.Query
- All Implemented Interfaces:
OutputFormal
,OutputSQL
,OutputXML
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 TypeMethodDescriptionprivate static String
Converts a conjunct variable to SQL.int
getArity()
Gets the arity (number of projected variables) for this query.getBody()
Gets the query body for this query.int
Gets the number of conjuncts in the query body with the most conjuncts.Gets the selectivity of this query.getShape()
Gets the shape of this query.boolean
isBinary()
Checks if this query is binary.Converts this object to its formal logic form.toString()
void
writeSQL
(IndentWriter writer) Writes the SQL representation of this object to the given writer.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). -
body
The body for this query.
-
-
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
-
getShape
Gets the shape of this query.- Returns:
- The query shape.
-
getSelectivity
Gets the selectivity of this query.- Returns:
- The selectivity of this query.
-
getConjunctCount
public int getConjunctCount()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.
-
getBody
Gets the query body for this query.- Returns:
- The query body.
-
toFormalSyntax
Description copied from interface:OutputFormal
Converts this object to its formal logic form.- Specified by:
toFormalSyntax
in interfaceOutputFormal
- Returns:
- The formal representation of this object.
-
toString
-
writeXML
Description copied from interface:OutputXML
Writes this object as XML to the given writer. -
writeSQL
Description copied from interface:OutputSQL
Writes the SQL representation of this object to the given writer. -
conjunctVarToSQL
Converts a conjunct variable to SQL.- Parameters:
v
- 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.
-