Class SailSourceConnection
- java.lang.Object
-
- org.eclipse.rdf4j.sail.helpers.AbstractSailConnection
-
- org.eclipse.rdf4j.sail.helpers.AbstractNotifyingSailConnection
-
- org.eclipse.rdf4j.sail.base.SailSourceConnection
-
- All Implemented Interfaces:
AutoCloseable
,FederatedServiceResolverClient
,InferencerConnection
,NotifyingSailConnection
,SailConnection
- Direct Known Subclasses:
ExtensibleStoreConnection
,LmdbStoreConnection
,MemoryStoreConnection
,NativeStoreConnection
public abstract class SailSourceConnection extends AbstractNotifyingSailConnection implements InferencerConnection, FederatedServiceResolverClient
ASailConnection
implementation that is based on anSailStore
.- Author:
- James Leigh
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.sail.helpers.AbstractSailConnection
connectionLock, updateLock, useConnectionLock
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SailSourceConnection(AbstractSail sail, SailStore store, EvaluationStrategyFactory evalStratFactory)
Creates a newSailConnection
, using the givenSailStore
to manage the state.protected
SailSourceConnection(AbstractSail sail, SailStore store, FederatedServiceResolver resolver)
Creates a newSailConnection
, using the givenSailStore
to manage the state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addInferredStatement(Resource subj, IRI pred, Value obj, Resource... contexts)
Adds an inferred statement to a specific context.void
addStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts)
The default implementation buffers added statements until the update operation is complete.void
clearInferred(Resource... contexts)
Removes all inferred statements from the specified/all contexts.protected void
clearInternal(Resource... contexts)
protected void
clearNamespacesInternal()
protected void
closeInternal()
protected void
commitInternal()
protected void
endUpdateInternal(UpdateContext op)
protected CloseableIteration<? extends BindingSet,QueryEvaluationException>
evaluateInternal(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred)
Explanation
explain(Explanation.Level level, TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred, int timeoutSeconds)
Explain how the TupleExpr will be (or has been) executed/evaluated by returning a TupleExpr (which may or may not be the provided TupleExpr) that has gone through zero or more of the stages prior to and also including execution as specified by the provided level.void
flushUpdates()
Flushes any pending updates to be processed and the resulting changes to be reported to registeredSailConnectionListener
s.protected CloseableIteration<? extends Resource,SailException>
getContextIDsInternal()
protected EvaluationStrategy
getEvaluationStrategy(Dataset dataset, TripleSource tripleSource)
FederatedServiceResolver
getFederatedServiceResolver()
Returns theFederatedServiceResolver
being used.protected String
getNamespaceInternal(String prefix)
protected CloseableIteration<? extends Namespace,SailException>
getNamespacesInternal()
protected CloseableIteration<? extends Statement,SailException>
getStatementsInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts)
protected void
prepareInternal()
boolean
removeInferredStatement(Resource subj, IRI pred, Value obj, Resource... contexts)
Removes an inferred statement from a specific context.protected void
removeNamespaceInternal(String prefix)
void
removeStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts)
The default implementation buffers removed statements until the update operation is complete.protected void
rollbackInternal()
void
setFederatedServiceResolver(FederatedServiceResolver resolver)
Sets theFederatedServiceResolver
to use.protected void
setNamespaceInternal(String prefix, String name)
void
setTransactionSettings(TransactionSetting... settings)
Pass any transaction-specific settings to the SailConnection.protected long
sizeInternal(Resource... contexts)
protected void
startTransactionInternal()
void
startUpdate(UpdateContext op)
Signals the start of an update operation.-
Methods inherited from class org.eclipse.rdf4j.sail.helpers.AbstractNotifyingSailConnection
addConnectionListener, hasConnectionListeners, notifyStatementAdded, notifyStatementRemoved, removeConnectionListener
-
Methods inherited from class org.eclipse.rdf4j.sail.helpers.AbstractSailConnection
addStatement, addStatementInternal, autoStartTransaction, begin, begin, clear, clearNamespaces, close, commit, endUpdate, evaluate, flush, getContextIDs, getExclusiveConnectionLock, getNamespace, getNamespaces, getSailBase, getSharedConnectionLock, getStatements, getTransactionIsolation, getTransactionLock, hasStatement, hasStatementInternal, isActive, isActiveOperation, isOpen, iterationClosed, pendingAdds, pendingRemovals, prepare, registerIteration, removeNamespace, removeStatements, removeStatementsInternal, rollback, setNamespace, setStatementsAdded, setStatementsRemoved, size, transactionActive, verifyIsActive, verifyIsOpen
-
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.sail.NotifyingSailConnection
addConnectionListener, removeConnectionListener
-
Methods inherited from interface org.eclipse.rdf4j.sail.SailConnection
addStatement, begin, begin, clear, clearNamespaces, close, commit, endUpdate, evaluate, flush, getContextIDs, getNamespace, getNamespaces, getStatements, hasStatement, isActive, isOpen, pendingRemovals, prepare, prepareQuery, removeNamespace, removeStatements, rollback, setNamespace, size
-
-
-
-
Constructor Detail
-
SailSourceConnection
protected SailSourceConnection(AbstractSail sail, SailStore store, FederatedServiceResolver resolver)
Creates a newSailConnection
, using the givenSailStore
to manage the state.- Parameters:
sail
-store
-resolver
- the FederatedServiceResolver to use with thedefault EvaluationStrategy
.
-
SailSourceConnection
protected SailSourceConnection(AbstractSail sail, SailStore store, EvaluationStrategyFactory evalStratFactory)
Creates a newSailConnection
, using the givenSailStore
to manage the state.- Parameters:
sail
-store
-evalStratFactory
- theEvaluationStrategyFactory
to use.
-
-
Method Detail
-
getFederatedServiceResolver
public FederatedServiceResolver getFederatedServiceResolver()
Returns theFederatedServiceResolver
being used.- Specified by:
getFederatedServiceResolver
in interfaceFederatedServiceResolverClient
- Returns:
- null if a custom
EvaluationStrategyFactory
is being used.
-
setFederatedServiceResolver
public void setFederatedServiceResolver(FederatedServiceResolver resolver)
Sets theFederatedServiceResolver
to use. If a customEvaluationStrategyFactory
is being used then this only has an effect if it implementsFederatedServiceResolverClient
.- Specified by:
setFederatedServiceResolver
in interfaceFederatedServiceResolverClient
- Parameters:
resolver
- The resolver to use.
-
getEvaluationStrategy
protected EvaluationStrategy getEvaluationStrategy(Dataset dataset, TripleSource tripleSource)
-
evaluateInternal
protected CloseableIteration<? extends BindingSet,QueryEvaluationException> evaluateInternal(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred) throws SailException
- Specified by:
evaluateInternal
in classAbstractSailConnection
- Throws:
SailException
-
explain
public Explanation explain(Explanation.Level level, TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred, int timeoutSeconds)
Description copied from interface:SailConnection
Explain how the TupleExpr will be (or has been) executed/evaluated by returning a TupleExpr (which may or may not be the provided TupleExpr) that has gone through zero or more of the stages prior to and also including execution as specified by the provided level.
This method is used by the Query interface.
WARNING: This method is experimental and is subject to change or removal without warning. There is currently only partial support for this method in RDF4J and and UnsupportedOperationException where support is lacking.
- Specified by:
explain
in interfaceSailConnection
- Parameters:
level
- the explanation level, eg. OPTIMIZEDtupleExpr
- The tuple expression to evaluate. Mutable.dataset
- The dataset to use for evaluating the query, null to use the Sail's default dataset.bindings
- A set of input parameters for the query evaluation. The keys reference variable names that should be bound to the value they map to.includeInferred
- Indicates whether inferred triples are to be considered in the query result. If false, no inferred statements are returned; if true, inferred statements are returned if availabletimeoutSeconds
- for explanations that require execution a timeout can be provided in seconds- Returns:
- The resulting tuple expression after being run through the specified level
-
closeInternal
protected void closeInternal() throws SailException
- Specified by:
closeInternal
in classAbstractSailConnection
- Throws:
SailException
-
getContextIDsInternal
protected CloseableIteration<? extends Resource,SailException> getContextIDsInternal() throws SailException
- Specified by:
getContextIDsInternal
in classAbstractSailConnection
- Throws:
SailException
-
getStatementsInternal
protected CloseableIteration<? extends Statement,SailException> getStatementsInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException
- Specified by:
getStatementsInternal
in classAbstractSailConnection
- Throws:
SailException
-
sizeInternal
protected long sizeInternal(Resource... contexts) throws SailException
- Specified by:
sizeInternal
in classAbstractSailConnection
- Throws:
SailException
-
getNamespacesInternal
protected CloseableIteration<? extends Namespace,SailException> getNamespacesInternal() throws SailException
- Specified by:
getNamespacesInternal
in classAbstractSailConnection
- Throws:
SailException
-
getNamespaceInternal
protected String getNamespaceInternal(String prefix) throws SailException
- Specified by:
getNamespaceInternal
in classAbstractSailConnection
- Throws:
SailException
-
setTransactionSettings
public void setTransactionSettings(TransactionSetting... settings)
Description copied from interface:SailConnection
Pass any transaction-specific settings to the SailConnection. This method needs to be called before the transaction isstarted
.Sail implementations can override this method to receive the transaction settings (to inspect and/or pass them along to any wrapped sail objects). Remember to call
super.setTransactionSettings(settings)
if you override this method.- Specified by:
setTransactionSettings
in interfaceSailConnection
- Parameters:
settings
- the transaction settings on which the next transaction operates. It may or may not contain the isolation level.
-
startTransactionInternal
protected void startTransactionInternal() throws SailException
- Specified by:
startTransactionInternal
in classAbstractSailConnection
- Throws:
SailException
-
prepareInternal
protected void prepareInternal() throws SailException
- Overrides:
prepareInternal
in classAbstractSailConnection
- Throws:
SailException
-
commitInternal
protected void commitInternal() throws SailException
- Specified by:
commitInternal
in classAbstractSailConnection
- Throws:
SailException
-
rollbackInternal
protected void rollbackInternal() throws SailException
- Specified by:
rollbackInternal
in classAbstractSailConnection
- Throws:
SailException
-
startUpdate
public void startUpdate(UpdateContext op) throws SailException
Description copied from interface:SailConnection
Signals the start of an update operation. The givenop
maybe passed to subsequentSailConnection.addStatement(UpdateContext, Resource, IRI, Value, Resource...)
orSailConnection.removeStatement(UpdateContext, Resource, IRI, Value, Resource...)
calls beforeSailConnection.endUpdate(UpdateContext)
is called.- Specified by:
startUpdate
in interfaceSailConnection
- Overrides:
startUpdate
in classAbstractSailConnection
- Throws:
SailException
-
addStatement
public void addStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException
Description copied from class:AbstractSailConnection
The default implementation buffers added statements until the update operation is complete.- Specified by:
addStatement
in interfaceSailConnection
- Overrides:
addStatement
in classAbstractSailConnection
- Parameters:
op
- operation properties of theUpdateExpr
operation producing these statements.subj
- The subject of the statement to add.pred
- The predicate of the statement to add.obj
- The object of the statement to add.contexts
- The context(s) to add the statement to. Note that this parameter is a vararg and as such is optional. If no contexts are specified, a context-less statement will be added.- Throws:
SailException
- If the statement could not be added, for example because no transaction is active.
-
removeStatement
public void removeStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException
Description copied from class:AbstractSailConnection
The default implementation buffers removed statements until the update operation is complete.- Specified by:
removeStatement
in interfaceSailConnection
- Overrides:
removeStatement
in classAbstractSailConnection
- Parameters:
op
- operation properties of theUpdateExpr
operation removing these statements.subj
- The subject of the statement that should be removed.pred
- The predicate of the statement that should be removed.obj
- The object of the statement that should be removed.contexts
- The context(s) from which to remove the statement. Note that this parameter is a vararg and as such is optional. If no contexts are specified the method operates on the entire repository. A null value can be used to match context-less statements.- Throws:
SailException
- If the statement could not be removed, for example because no transaction is active.
-
endUpdateInternal
protected void endUpdateInternal(UpdateContext op) throws SailException
- Overrides:
endUpdateInternal
in classAbstractSailConnection
- Throws:
SailException
-
addInferredStatement
public boolean addInferredStatement(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException
Description copied from interface:InferencerConnection
Adds an inferred statement to a specific context.- Specified by:
addInferredStatement
in interfaceInferencerConnection
- Parameters:
subj
- The subject of the statement to add.pred
- The predicate of the statement to add.obj
- The object of the statement to add.contexts
- The context(s) to add the statement to. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
SailException
- If the statement could not be added.
-
removeInferredStatement
public boolean removeInferredStatement(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException
Description copied from interface:InferencerConnection
Removes an inferred statement from a specific context.- Specified by:
removeInferredStatement
in interfaceInferencerConnection
- Parameters:
subj
- The subject of the statement that should be removed.pred
- The predicate of the statement that should be removed.obj
- The object of the statement that should be removed.contexts
- The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
SailException
- If the statement could not be removed.
-
clearInternal
protected void clearInternal(Resource... contexts) throws SailException
- Specified by:
clearInternal
in classAbstractSailConnection
- Throws:
SailException
-
clearInferred
public void clearInferred(Resource... contexts) throws SailException
Description copied from interface:InferencerConnection
Removes all inferred statements from the specified/all contexts. If no contexts are specified the method operates on the entire repository.- Specified by:
clearInferred
in interfaceInferencerConnection
- Parameters:
contexts
- The context(s) from which to remove the statements. Note that this parameter is a vararg and as such is optional. If no contexts are supplied the method operates on the entire repository.- Throws:
SailException
- If the statements could not be removed.
-
flushUpdates
public void flushUpdates() throws SailException
Description copied from interface:InferencerConnection
Flushes any pending updates to be processed and the resulting changes to be reported to registeredSailConnectionListener
s.- Specified by:
flushUpdates
in interfaceInferencerConnection
- Throws:
SailException
- If the updates could not be processed.
-
setNamespaceInternal
protected void setNamespaceInternal(String prefix, String name) throws SailException
- Specified by:
setNamespaceInternal
in classAbstractSailConnection
- Throws:
SailException
-
removeNamespaceInternal
protected void removeNamespaceInternal(String prefix) throws SailException
- Specified by:
removeNamespaceInternal
in classAbstractSailConnection
- Throws:
SailException
-
clearNamespacesInternal
protected void clearNamespacesInternal() throws SailException
- Specified by:
clearNamespacesInternal
in classAbstractSailConnection
- Throws:
SailException
-
-