Package com.complexible.stardog.rdf4j

# Class StardogRepositoryConnection

java.lang.Object
org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection
com.complexible.stardog.rdf4j.StardogRepositoryConnection

All Implemented Interfaces:
  `AutoCloseable`, `org.eclipse.rdf4j.repository.RepositoryConnection`

public final class StardogRepositoryConnection extends org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection

Stardog-based implementation of an RDF4J RepositoryConnection. Leaving `autoCommit` turned ON will yield sub-optimal performance with Stardog because of the overhead of pushing many single statement transactions. It is therefore highly recommended to use the `begin()` and `commit()`/`rollback()` methods to group operations into transactions unless absolutely required by your application

These connections keep a local cache of changes which are not pushed until they exceed a threshold, or an action, such as a query or a commit, requires them to be pushed to the server. This minimizes the overhead of calling add or remove in a tight loop with small payloads and then committing the entire thing, those updates would then be pushed in as few chunks as possible.

All queries created via this connection will implement the accessors for a query's `maxQueryTime` as no ops. The methods will work in that they will not throw an `UnsupportedOperationException`, however, they are not supported by Stardog. Timeouts cannot be controlled on a per-query basis, they are global server options.

Each of the specific `prepare*Query` methods, such as `AbstractRepositoryConnection.prepareGraphQuery(org.eclipse.rdf4j.query.QueryLanguage, String)` will parse the query during invocation, but it will not be type checked until execution time. For example, you can provide a valid ASK query to `prepareGraphQuery` and it will not fail that you're using a boolean query as a graph query until its executed. This is similar to how HTTPRepository handles this situation.

Since:
  0.1
Version:
  5.0
Author:
  Michael Grove

- ## Field Summary

  ### Fields inherited from class org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection

  `logger`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `addWithoutCommit(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, org.eclipse.rdf4j.model.Resource... theContexts)`
  `void`
  `begin()`
  `void`
  `clearNamespaces()`
  `void`
  `close()`
  `void`
  `commit()`
  `void`
  `exportStatements(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, boolean theIncludeInferred, org.eclipse.rdf4j.rio.RDFHandler theRDFHandler, org.eclipse.rdf4j.model.Resource... theContexts)`
  `org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Resource>`
  `getContextIDs()`
  `String`
  `getNamespace(String s)`
  `org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Namespace>`
  `getNamespaces()`
  `org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Statement>`
  `getStatements(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, boolean theIncludeInferred, org.eclipse.rdf4j.model.Resource... theContexts)`
  `org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Statement>`
  `getStatements(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, org.eclipse.rdf4j.model.Resource... contexts)`
  `boolean`
  `hasStatement(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, boolean includeInferred, org.eclipse.rdf4j.model.Resource... contexts)`
  `boolean`
  `hasStatement(org.eclipse.rdf4j.model.Statement st, boolean includeInferred, org.eclipse.rdf4j.model.Resource... contexts)`
  `boolean`
  `isActive()`
  `org.eclipse.rdf4j.query.BooleanQuery`
  `prepareBooleanQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase)`
  `org.eclipse.rdf4j.query.GraphQuery`
  `prepareGraphQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase)`
  `org.eclipse.rdf4j.query.Query`
  `prepareQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase)`
  `org.eclipse.rdf4j.query.TupleQuery`
  `prepareTupleQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase)`
  `org.eclipse.rdf4j.query.Update`
  `prepareUpdate(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase)`
  `void`
  `removeNamespace(String thePrefix)`
  `protected void`
  `removeWithoutCommit(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, org.eclipse.rdf4j.model.Resource... theContexts)`
  `void`
  `rollback()`
  `void`
  `setIsolationLevel(org.eclipse.rdf4j.IsolationLevel level)`
  `void`
  `setNamespace(String thePrefix, String theNS)`
  `long`
  `size(org.eclipse.rdf4j.model.Resource... theContexts)`

  ### Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection

  `add, add, add, add, add, add, add, add, addWithoutCommit, begin, clear, conditionalCommit, conditionalRollback, export, getIsolationLevel, getParserConfig, getRepository, getValueFactory, isAutoCommit, isEmpty, isOpen, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, prepareUpdate, remove, remove, remove, remove, removeWithoutCommit, setAutoCommit, setParserConfig, startLocalTransaction`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.eclipse.rdf4j.repository.RepositoryConnection

  `add, add, add, add, add, add, add, add, begin, getStatements, hasStatement, prepare, prepareBooleanQuery, prepareGraphQuery, prepareQuery, prepareTupleQuery, prepareUpdate, remove, remove`

- ## Method Details

  - ### begin

    public void begin() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### isActive

    public boolean isActive() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### close

    public void close() throws org.eclipse.rdf4j.repository.RepositoryException
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `org.eclipse.rdf4j.repository.RepositoryConnection`
    Overrides:
      `close` in class `org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection`
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### setIsolationLevel

    public void setIsolationLevel(org.eclipse.rdf4j.IsolationLevel level) throws IllegalStateException
    Specified by:
      `setIsolationLevel` in interface `org.eclipse.rdf4j.repository.RepositoryConnection`
    Overrides:
      `setIsolationLevel` in class `org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection`
    Throws:
      `IllegalStateException`

  - ### addWithoutCommit

    protected void addWithoutCommit(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, org.eclipse.rdf4j.model.Resource... theContexts) throws org.eclipse.rdf4j.repository.RepositoryException
    Specified by:
      `addWithoutCommit` in class `org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection`
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### removeWithoutCommit

    protected void removeWithoutCommit(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, org.eclipse.rdf4j.model.Resource... theContexts) throws org.eclipse.rdf4j.repository.RepositoryException
    Specified by:
      `removeWithoutCommit` in class `org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection`
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### prepareQuery

    public org.eclipse.rdf4j.query.Query prepareQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase) throws org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `org.eclipse.rdf4j.query.MalformedQueryException`

  - ### prepareTupleQuery

    public org.eclipse.rdf4j.query.TupleQuery prepareTupleQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase) throws org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `org.eclipse.rdf4j.query.MalformedQueryException`

  - ### prepareGraphQuery

    public org.eclipse.rdf4j.query.GraphQuery prepareGraphQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase) throws org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `org.eclipse.rdf4j.query.MalformedQueryException`

  - ### prepareBooleanQuery

    public org.eclipse.rdf4j.query.BooleanQuery prepareBooleanQuery(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase) throws org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `org.eclipse.rdf4j.query.MalformedQueryException`

  - ### prepareUpdate

    public org.eclipse.rdf4j.query.Update prepareUpdate(org.eclipse.rdf4j.query.QueryLanguage theQueryLanguage, String theQuery, String theBase) throws org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.query.MalformedQueryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `org.eclipse.rdf4j.query.MalformedQueryException`

  - ### getContextIDs

    public org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Resource> getContextIDs() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### getStatements

    public org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Statement> getStatements(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, org.eclipse.rdf4j.model.Resource... contexts) throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### getStatements

    public org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Statement> getStatements(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, boolean theIncludeInferred, org.eclipse.rdf4j.model.Resource... theContexts) throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### hasStatement

    public boolean hasStatement(org.eclipse.rdf4j.model.Resource subj, org.eclipse.rdf4j.model.IRI pred, org.eclipse.rdf4j.model.Value obj, boolean includeInferred, org.eclipse.rdf4j.model.Resource... contexts) throws org.eclipse.rdf4j.repository.RepositoryException
    Specified by:
      `hasStatement` in interface `org.eclipse.rdf4j.repository.RepositoryConnection`
    Overrides:
      `hasStatement` in class `org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection`
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### hasStatement

    public boolean hasStatement(org.eclipse.rdf4j.model.Statement st, boolean includeInferred, org.eclipse.rdf4j.model.Resource... contexts)
    Specified by:
      `hasStatement` in interface `org.eclipse.rdf4j.repository.RepositoryConnection`
    Overrides:
      `hasStatement` in class `org.eclipse.rdf4j.repository.base.AbstractRepositoryConnection`

  - ### exportStatements

    public void exportStatements(org.eclipse.rdf4j.model.Resource theSubj, org.eclipse.rdf4j.model.IRI thePred, org.eclipse.rdf4j.model.Value theObj, boolean theIncludeInferred, org.eclipse.rdf4j.rio.RDFHandler theRDFHandler, org.eclipse.rdf4j.model.Resource... theContexts) throws org.eclipse.rdf4j.repository.RepositoryException, org.eclipse.rdf4j.rio.RDFHandlerException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `org.eclipse.rdf4j.rio.RDFHandlerException`

  - ### size

    public long size(org.eclipse.rdf4j.model.Resource... theContexts) throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### commit

    public void commit() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### rollback

    public void rollback() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### getNamespaces

    public org.eclipse.rdf4j.repository.RepositoryResult<org.eclipse.rdf4j.model.Namespace> getNamespaces() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### getNamespace

    public String getNamespace(String s) throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### setNamespace

    public void setNamespace(String thePrefix, String theNS) throws org.eclipse.rdf4j.repository.RepositoryException, NullPointerException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`
      `NullPointerException`

  - ### removeNamespace

    public void removeNamespace(String thePrefix) throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`

  - ### clearNamespaces

    public void clearNamespaces() throws org.eclipse.rdf4j.repository.RepositoryException
    Throws:
      `org.eclipse.rdf4j.repository.RepositoryException`