Class FedXConnection
- All Implemented Interfaces:
AutoCloseable, SailConnection
FederationEvalStrategy to evaluate provided queries.
Prior to evaluation various optimizations are performed, see
FedXOptimizer for further details.
Since 4.0 FedX supports write operations using the supplied WriteStrategy, e.g. by writing to a designated
federation member. Note: the WriteStrategy is initialized lazily upon first access to a write operation, see
getWriteStrategyInternal().
Implementation notes: - not all methods are implemented as of now
- Author:
- Andreas Schwarte
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA default implementation forAbstractSail. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddStatementInternal(Resource subj, IRI pred, Value obj, Resource... contexts) protected voidclearInternal(Resource... contexts) protected voidprotected voidprotected voidprotected CloseableIteration<? extends BindingSet> evaluateInternal(TupleExpr query, Dataset dataset, BindingSet bindings, boolean includeInferred) 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.protected CloseableIteration<? extends Resource> protected StringgetNamespaceInternal(String prefix) protected CloseableIteration<? extends Namespace> protected CloseableIteration<? extends Statement> getStatementsInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) protected WriteStrategyReturn the initializedwriteStrategy.protected booleanhasStatementInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource[] contexts) protected voidremoveNamespaceInternal(String prefix) protected voidremoveStatementsInternal(Resource subj, IRI pred, Value obj, Resource... contexts) protected voidprotected voidsetNamespaceInternal(String prefix, String name) voidsetTransactionSettings(TransactionSetting... settings) Pass any transaction-specific settings to the SailConnection.protected longsizeInternal(Resource... contexts) protected voidMethods inherited from class AbstractSailConnection
addStatement, addStatement, autoStartTransaction, begin, begin, bulkAddStatementsInternal, clear, clearNamespaces, close, commit, endUpdate, endUpdateInternal, evaluate, flush, getContextIDs, getNamespace, getNamespaces, getOwner, getSailBase, getStatements, getStatements, getStatementsInternal, getTransactionIsolation, hasActiveIterations, hasStatement, isActive, isActiveOperation, isOpen, iterationClosed, pendingAdds, prepare, prepareInternal, recordDataImportMetricsStatementsAdded, registerIteration, removeNamespace, removeStatement, removeStatements, rollback, setNamespace, setStatementsAdded, setStatementsRemoved, size, startUpdate, transactionActive, verifyIsActive, verifyIsOpen, waitForOtherOperationsModifier and TypeMethodDescriptionfinal voidaddStatement(Resource subj, IRI pred, Value obj, Resource... contexts) Adds a statement to the store.voidaddStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts) The default implementation buffers added statements until the update operation is complete.protected voidDeprecated.voidbegin()Begins a transaction requiringSailConnection.commit()orSailConnection.rollback()to be called to close the transaction.voidbegin(IsolationLevel isolationLevel) Begins a transaction with the specifiedIsolationLevellevel, requiringSailConnection.commit()orSailConnection.rollback()to be called to close the transaction.protected voidbulkAddStatementsInternal(Collection<? extends Statement> statements) final voidRemoves all statements from the specified/all contexts.final voidRemoves all namespace declarations from the repository.final voidclose()Closes the connection.final voidcommit()Commits any updates that have been performed since the last timeSailConnection.commit()orSailConnection.rollback()was called.final voidIndicates that the givenopwill not be used in any call again.protected voidfinal CloseableIteration<? extends BindingSet> evaluate(TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred) Evaluates the supplied TupleExpr on the data contained in this Sail object, using the (optional) dataset and supplied bindings as input parameters.voidflush()Flushes any pending updates and notify changes to listeners as appropriate.final CloseableIteration<? extends Resource> Returns the set of all unique context identifiers that are used to store statements.final StringgetNamespace(String prefix) Gets the namespace that is associated with the specified prefix, if any.final CloseableIteration<? extends Namespace> Gets the namespaces relevant to the data contained in this Sail object.getOwner()This is for internal use only.protected AbstractSailfinal CloseableIteration<? extends Statement> getStatements(StatementOrder order, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Gets all statements from the specified contexts that have a specific subject, predicate and/or object.final CloseableIteration<? extends Statement> getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Gets all statements from the specified contexts that have a specific subject, predicate and/or object.protected CloseableIteration<? extends Statement> getStatementsInternal(StatementOrder order, Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) protected IsolationLevelRetrieve the currently setIsolationLevel.booleanfinal booleanhasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) Determines if the store contains any statements from the specified contexts that have a specific subject, predicate and/or object.booleanisActive()Indicates if a transaction is currently active on the connection.protected booleanfinal booleanisOpen()Checks whether this SailConnection is open.protected voiditerationClosed(org.eclipse.rdf4j.sail.helpers.SailBaseIteration<?, ?> iter) Called bySailBaseIterationto indicate that it has been closed.protected booleanfinal voidprepare()Checks for an error state in the active transaction that would force the transaction to be rolled back.protected voidprotected final voidrecordDataImportMetricsStatementsAdded(Resource... contexts) protected <T, E extends Exception>
CloseableIteration<T> registerIteration(CloseableIteration<T> iter) Registers an iteration as active by wrapping it in aSailBaseIterationobject and adding it to the list of active iterations.final voidremoveNamespace(String prefix) Removes a namespace declaration by removing the association between a prefix and a namespace name.voidremoveStatement(UpdateContext op, Resource subj, IRI pred, Value obj, Resource... contexts) The default implementation buffers removed statements until the update operation is complete.final voidremoveStatements(Resource subj, IRI pred, Value obj, Resource... contexts) Removes all statements matching the specified subject, predicate and object from the repository.final voidrollback()Rolls back the transaction, discarding any uncommitted changes that have been made in this SailConnection.final voidsetNamespace(String prefix, String name) Sets the prefix for a namespace.protected voidprotected voidfinal longReturns the number of (explicit) statements in the store, or in specific contexts.voidSignals the start of an update operation.protected final booleanprotected voidVerifies if a transaction is currently active.protected voidvoidwaitForOtherOperations(boolean interrupt) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SailConnection
getComparator, getSupportedOrders, prepareQueryModifier and TypeMethodDescriptiondefault Comparator<Value> Different underlying datastructures may have different ways of ordering statements.default Set<StatementOrder> getSupportedOrders(Resource subj, IRI pred, Value obj, Resource... contexts) The underlying store may support some, but not all, statement orders based on the statement pattern.prepareQuery(QueryLanguage ql, Query.QueryType type, String query, String baseURI) Allows the SailConnection to bypass the standard query parser and provide its own internalTupleExprimplementation.
-
Field Details
-
federation
-
federationContext
-
-
Constructor Details
-
FedXConnection
- Throws:
SailException
-
-
Method Details
-
setTransactionSettings
Description copied from interface:SailConnectionPass 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:
setTransactionSettingsin interfaceSailConnection- Overrides:
setTransactionSettingsin classAbstractSailConnection- Parameters:
settings- the transaction settings on which the next transaction operates. It may or may not contain the isolation level.
-
evaluateInternal
protected CloseableIteration<? extends BindingSet> evaluateInternal(TupleExpr query, Dataset dataset, BindingSet bindings, boolean includeInferred) throws SailException - Specified by:
evaluateInternalin classAbstractSailConnection- Throws:
SailException
-
clearInternal
- Specified by:
clearInternalin classAbstractSailConnection- Throws:
SailException
-
clearNamespacesInternal
- Specified by:
clearNamespacesInternalin classAbstractSailConnection- Throws:
SailException
-
closeInternal
- Specified by:
closeInternalin classAbstractSailConnection- Throws:
SailException
-
commitInternal
- Specified by:
commitInternalin classAbstractSailConnection- Throws:
SailException
-
getContextIDsInternal
- Specified by:
getContextIDsInternalin classAbstractSailConnection- Throws:
SailException
-
getNamespaceInternal
- Specified by:
getNamespaceInternalin classAbstractSailConnection- Throws:
SailException
-
getNamespacesInternal
- Specified by:
getNamespacesInternalin classAbstractSailConnection- Throws:
SailException
-
getStatementsInternal
protected CloseableIteration<? extends Statement> getStatementsInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws SailException - Specified by:
getStatementsInternalin classAbstractSailConnection- Throws:
SailException
-
hasStatementInternal
protected boolean hasStatementInternal(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource[] contexts) - Overrides:
hasStatementInternalin classAbstractSailConnection
-
addStatementInternal
protected void addStatementInternal(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException - Specified by:
addStatementInternalin classAbstractSailConnection- Throws:
SailException
-
removeNamespaceInternal
- Specified by:
removeNamespaceInternalin classAbstractSailConnection- Throws:
SailException
-
removeStatementsInternal
protected void removeStatementsInternal(Resource subj, IRI pred, Value obj, Resource... contexts) throws SailException - Specified by:
removeStatementsInternalin classAbstractSailConnection- Throws:
SailException
-
rollbackInternal
- Specified by:
rollbackInternalin classAbstractSailConnection- Throws:
SailException
-
setNamespaceInternal
- Specified by:
setNamespaceInternalin classAbstractSailConnection- Throws:
SailException
-
sizeInternal
- Specified by:
sizeInternalin classAbstractSailConnection- Throws:
SailException
-
startTransactionInternal
- Specified by:
startTransactionInternalin classAbstractSailConnection- Throws:
SailException
-
getWriteStrategyInternal
Return the initializedwriteStrategy. If this has not been done yet,is returned. This method guarantees lazy initialization upon the first write operation on thisinvalid reference
WriteStrategy#initialize()FedXConnectioninstance.- Returns:
- the
WriteStrategy - Throws:
SailException
-
explain
public Explanation explain(Explanation.Level level, TupleExpr tupleExpr, Dataset dataset, BindingSet bindings, boolean includeInferred, int timeoutSeconds) Description copied from interface:SailConnectionExplain 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.
- 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
-
AbstractSailConnection.verifyIsActive()instead.