All Superinterfaces:
PQueryHeader, PTraceable
All Known Subinterfaces:
InitializablePQuery
All Known Implementing Classes:
BasePQuery

public interface PQuery extends PQueryHeader, PTraceable
Internal representation of a query / graph pattern (using a constraint system formalism), to be interpreted by a query evaluator (IQueryBackend). End-users of Refinery Intepreter should access a query as an IQuerySpecification instead.

PQuerys are definitions of queries usable inside pattern descriptions. Such description always has (a non-null) name. The query itself is defined as a (non-empty) set of PBody instances, the result is the disjunction of the single PBody instances.

A PQuery might be constructed from erroneous patterns or might be uninitialized - this is represented by its status.

Since:
0.8.0
  • Method Details

    • getDisjunctBodies

      PDisjunction getDisjunctBodies()
      Returns all bodies associated with the query in their canonical form. If called multiple times, the same set with the same contents will be returned.
    • getDirectReferredQueries

      Set<PQuery> getDirectReferredQueries()
      Returns all queries directly referred in the constraints. They are all required to evaluate this query
      Returns:
      a non-null, but possibly empty list of query definitions
    • getAllReferredQueries

      Set<PQuery> getAllReferredQueries()
      Returns all queries required to evaluate this query (transitively).
      Returns:
      a non-null, but possibly empty list of query definitions
    • getStatus

      PQuery.PQueryStatus getStatus()
      Returns the initialization status of the definition
    • getPProblems

      List<PProblem> getPProblems()
      Returns a list describing the problems that were found in this query.

      TODO: formulate invariant connecting getPProblems() and getStatus().

      Returns:
      a non-null, but possibly empty list of problems
    • checkMutability

      void checkMutability()
      Before a modification operation is executed, a mutability check is performed (via the getStatus() implementation, and in case of problems an IllegalStateException is thrown.
    • isMutable

      boolean isMutable()
      An option to check mutability of the query. It can be used to avoid getting an IllegalStateException by the execution of checkMutability().
      Returns:
      true if the query specification is still editable
    • getEvaluationHints

      QueryEvaluationHint getEvaluationHints()
      Optional hints regarding the query evaluation strategy, to be interpreted by the query engine.

      To ensure the possibility of external overrides, the evaluation engine should not directly consult this field, but use an IQueryBackendHintProvider instead.

    • getTypeGuarantees

      Set<TypeJudgement> getTypeGuarantees()
      Type information, expressed on query parameters, that all matches of the query are guaranteed to respect.

      At the very minimum, this should include the declared types of the parameters.

      The type judgement tuples shall contain the parameter index, NOT the PParameter object.

      Returns:
      a non-null set of type judgements that the query guarantees for its matches
    • ensureInitialized

      void ensureInitialized()
      If the query definition is uninitialized, initializes it.
      Throws:
      InterpreterRuntimeException - if initialization of query specification fails
    • publishedAs

      List<Object> publishedAs()
      Returns the end-user query specification API objects that wrap this query.

      Intended for traceability and debug purposes, not part of normal operation. Returned list is intended to be appended during query specification construction time.

      Returns:
      a non-null, but possibly empty list of query specification objects;