Interface QueryExecution

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
QueryExecutionAdapter, QueryExecutionCompat, QueryExecutionHTTP

public interface QueryExecution extends AutoCloseable
A interface for a single execution of a query.
  • Method Details

    • create

      static QueryExecution create(Query query, Dataset dataset)
      Create a local execution on a dataset for a given query
    • create

      static QueryExecution create(String query, Model model)
      Create a local execution on a dataset for a given query
    • create

      static QueryExecution create(String query, Dataset dataset)
      Create a local execution on a dataset for a given query
    • create

      static QueryExecution create(Query query, Model model)
      Create a local execution on a dataset for a given query
    • service

      static QueryExecution service(String endpointURL, Query query)
      Create a remote execution.
    • service

      static QueryExecutionHTTP service(String endpointURL, String queryString)
      Create a remote execution.
    • dataset

      static QueryExecutionDatasetBuilder dataset(Dataset dataset)
      Create a local execution builder on a dataset
    • model

      static QueryExecutionDatasetBuilder model(Model model)
      Create a local execution builder on a model
    • service

      static QueryExecutionHTTPBuilder service(String serviceURL)
      Create a remote execution builder going to an endpoint URL.
    • create

      Create a local execution builder
    • setInitialBinding

      @Deprecated void setInitialBinding(QuerySolution binding)
      Deprecated.
      Use QueryExecutionDatasetBuilder and set the initial binding before building.
      Set the initial association of variables and values. May not be supported by all QueryExecution implementations.

      The preferred way is to use QueryExecutionDatasetBuilder.substitution(QuerySolution) which is supported uniformly for local and remote queries.

      Parameters:
      binding -
    • setInitialBinding

      @Deprecated void setInitialBinding(Binding binding)
      Deprecated.
      Use QueryExecutionDatasetBuilder and set the initial binding before building.
      Set the initial association of variables and values. May not be supported by all QueryExecution implementations.

      The preferred way is to use QueryExecutionDatasetBuilder.substitution(Binding) which is supported uniformly for local and remote queries.

      Parameters:
      binding -
    • getDataset

      Dataset getDataset()
      The dataset against which the query will execute. May be null, implying it is expected that the query itself has a dataset description.
    • getContext

      Context getContext()
      The properties associated with a query execution - implementation specific parameters This includes Java objects (so it is not an RDF graph). Keys should be URIs as strings. May be null (this implementation does not provide any configuration).
    • getQuery

      Query getQuery()
      The query associated with a query execution. May be null (QueryExecution may have been created by other means)
    • getQueryString

      String getQueryString()
      The query as a string. This may be null (QueryExecution may have been created by other means). This may contain non-Jena extensions and can not be parsed by Jena. If getQuery() is not null, this is a corresponding string that parses to the same query.
    • execSelect

      ResultSet execSelect()
      Execute a SELECT query

      Important: The name of this method is somewhat of a misnomer in that depending on the underlying implementation this typically does not execute the SELECT query but rather answers a wrapper over an internal data structure that can be used to answer the query. In essence calling this method only returns a plan for executing this query which only gets evaluated when you actually start iterating over the results.

    • execConstruct

      Model execConstruct()
      Execute a CONSTRUCT query
    • execConstruct

      Model execConstruct(Model model)
      Execute a CONSTRUCT query, putting the statements into 'model'.
      Returns:
      Model The model argument for cascaded code.
    • execConstructTriples

      Iterator<Triple> execConstructTriples()
      Execute a CONSTRUCT query, returning the results as an iterator of Triple.

      Caution: This method may return duplicate Triples. This method may be useful if you only need the results for stream processing, as it can avoid having to place the results in a Model.

      Important: The name of this method is somewhat of a misnomer in that depending on the underlying implementation this typically does not execute the CONSTRUCT query but rather answers a wrapper over an internal data structure that can be used to answer the query. In essence calling this method only returns a plan for executing this query which only gets evaluated when you actually start iterating over the results.

      Returns:
      An iterator of Triple objects (possibly containing duplicates) generated by applying the CONSTRUCT template of the query to the bindings in the WHERE clause.
    • execConstructQuads

      Iterator<Quad> execConstructQuads()
      Execute a CONSTRUCT query, returning the results as an iterator of Quad.

      Caution: This method may return duplicate Quads. This method may be useful if you only need the results for stream processing, as it can avoid having to place the results in a Model.

      Returns:
      An iterator of Quad objects (possibly containing duplicates) generated by applying the CONSTRUCT template of the query to the bindings in the WHERE clause.

      See execConstructTriples() for usage and features.

    • execConstructDataset

      Dataset execConstructDataset()
      Execute a CONSTRUCT query, putting the statements into 'dataset'. This maybe an extended syntax query (if supported).
    • execConstructDataset

      Dataset execConstructDataset(Dataset dataset)
      Execute a CONSTRUCT query, putting the statements into 'dataset'. This maybe an extended syntax query (if supported).
    • execDescribe

      Model execDescribe()
      Execute a DESCRIBE query
    • execDescribe

      Model execDescribe(Model model)
      Execute a DESCRIBE query, putting the statements into 'model'.
      Returns:
      Model The model argument for cascaded code.
    • execDescribeTriples

      Iterator<Triple> execDescribeTriples()
      Execute a DESCRIBE query, returning the results as an iterator of Triple.

      Caution: This method may return duplicate Triples. This method may be useful if you only need the results for stream processing, as it can avoid having to place the results in a Model.

      Important: The name of this method is somewhat of a misnomer in that depending on the underlying implementation this typically does not execute the DESCRIBE query but rather answers a wrapper over an internal data structure that can be used to answer the query. In essence calling this method only returns a plan for executing this query which only gets evaluated when you actually start iterating over the results.

      Returns:
      An iterator of Triple objects (possibly containing duplicates) generated as the output of the DESCRIBE query.
    • execAsk

      boolean execAsk()
      Execute an ASK query
    • execJson

      JsonArray execJson()
      Execute a JSON query and return a json array
    • execJsonItems

      Iterator<JsonObject> execJsonItems()
      Execute a JSON query and return an interator
    • abort

      void abort()
      Stop in mid execution. This method can be called in parallel with other methods on the QueryExecution object. There is no guarantee that the concrete implementation actual will stop or that it will do so immediately. No operations on the query execution or any associated result set are permitted after this call and may cause exceptions to be thrown.
    • close

      void close()
      Close the query execution and stop query evaluation as soon as convenient. QueryExecution objects, and a ResultSet from execSelect(), can not be used once the QueryExecution is closed. Model results from execConstruct() and execDescribe() are still valid. It is important to close query execution objects in order to release resources such as working memory and to stop the query execution. Some storage subsystems require explicit ends of operations and this operation will cause those to be called where necessary. No operations on the query execution or any associated result set are permitted after this call.
      Specified by:
      close in interface AutoCloseable
    • isClosed

      boolean isClosed()
      Answer whether this QueryExecution object has been closed or not.
      Returns:
      boolean
    • setTimeout

      @Deprecated void setTimeout(long timeout, TimeUnit timeoutUnits)
      Deprecated.
      Use QueryExecution.create().timeout(....)...
      Set a timeout on the query execution. Processing will be aborted after the timeout (which starts when the appropriate exec call is made). Not all query execution systems support timeouts. A timeout of less than zero means no timeout.
      See Also:
    • setTimeout

      @Deprecated void setTimeout(long timeout)
      Deprecated.
      Use QueryExecution.create().timeout(....)...
      Set time, in milliseconds
      See Also:
    • setTimeout

      @Deprecated void setTimeout(long timeout1, TimeUnit timeUnit1, long timeout2, TimeUnit timeUnit2)
      Deprecated.
      Use QueryExecution.create().initialTimeout(timeout1, timeUnit1).overallTimeout(timeout, timeUnit2)...
      Set timeouts on the query execution; the first timeout refers to time to first result, the second refers to overall query execution after the first result. Processing will be aborted if a timeout expires. Not all query execution systems support timeouts. A timeout of less than zero means no timeout; this can be used for timeout1 or timeout2.
    • setTimeout

      @Deprecated void setTimeout(long timeout1, long timeout2)
      Deprecated.
      Use QueryExecution.create().initialTimeout(timeout1, timeUnit).overallTimeout(timeout, timeUnit)...
      Set time, in milliseconds
      See Also:
    • getTimeout1

      long getTimeout1()
      Return the first timeout (time to first result), in milliseconds: negative if unset
    • getTimeout2

      long getTimeout2()
      Return the second timeout (overall query execution after first result), in milliseconds: negative if unset